JBoss port of sunxacml 2.0.5-redhat-1

org.jboss.security.xacml.sunxacml.attr
Class TimeAttribute

java.lang.Object
  extended by org.jboss.security.xacml.sunxacml.attr.AttributeValue
      extended by org.jboss.security.xacml.sunxacml.attr.TimeAttribute
All Implemented Interfaces:
Evaluatable, Expression

public class TimeAttribute
extends AttributeValue

Representation of an xs:time value. This class supports parsing xs:time values. All objects of this class are immutable and thread-safe. The Date objects returned are not, but these objects are cloned before being returned.

Since:
1.0
Author:
Steve Hanna, Seth Proctor

Field Summary
static String identifier
          Official name of this type
static int TZ_UNSPECIFIED
          Time zone value that indicates that the time zone was not specified.
 
Constructor Summary
TimeAttribute()
          Creates a new TimeAttribute that represents the current time in the current time zone.
TimeAttribute(Date time)
          Creates a new TimeAttribute that represents the given time but uses the default timezone and offset values.
TimeAttribute(Date time, int nanoseconds, int timeZone, int defaultedTimeZone)
          Creates a new TimeAttribute that represents the time supplied.
 
Method Summary
 String encode()
          Encodes the value in a form suitable for including in XML data like a request or an obligation.
 boolean equals(Object o)
          Returns true if the input is an instance of this class and if its value equals the value contained in this class.
 int getDefaultedTimeZone()
          Gets the time zone actually used for this object (if it was originally unspecified, the default time zone used).
static TimeAttribute getInstance(Node root)
          Returns a new TimeAttribute that represents the xs:time at a particular DOM node.
static TimeAttribute getInstance(String value)
          Returns a new TimeAttribute that represents the xs:time value indicated by the string provided.
 long getMilliseconds()
          Gets the number of milliseconds since midnight GMT that this attribute value represents.
 int getNanoseconds()
          Gets the nanoseconds of this object.
 int getTimeZone()
          Gets the time zone of this object (or TZ_UNSPECIFIED if unspecified).
 Date getValue()
          Gets the time represented by this object.
 int hashCode()
          Returns the hashcode value used to index and compare this object with others of the same type.
 String toString()
          Converts to a String representation.
 
Methods inherited from class org.jboss.security.xacml.sunxacml.attr.AttributeValue
encode, encode, encodeWithTags, evaluate, evaluatesToBag, getChildren, getType, isBag, returnsBag
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

identifier

public static final String identifier
Official name of this type

See Also:
Constant Field Values

TZ_UNSPECIFIED

public static final int TZ_UNSPECIFIED
Time zone value that indicates that the time zone was not specified.

See Also:
Constant Field Values
Constructor Detail

TimeAttribute

public TimeAttribute()
Creates a new TimeAttribute that represents the current time in the current time zone.


TimeAttribute

public TimeAttribute(Date time)
Creates a new TimeAttribute that represents the given time but uses the default timezone and offset values.

Parameters:
time - a Date object representing the specified time down to second resolution. This date should have a date of 01/01/1970. If it does not, such a date will be forced. If this object has non-zero milliseconds, they are combined with the nanoseconds parameter.

TimeAttribute

public TimeAttribute(Date time,
                     int nanoseconds,
                     int timeZone,
                     int defaultedTimeZone)
Creates a new TimeAttribute that represents the time supplied.

Parameters:
time - a Date object representing the specified time down to second resolution. This date should have a date of 01/01/1970. If it does not, such a date will be forced. If this object has non-zero milliseconds, they are combined with the nanoseconds parameter.
nanoseconds - the number of nanoseconds beyond the Date specified in the date parameter
timeZone - the time zone specified for this object (or TZ_UNSPECIFIED if unspecified). The offset to GMT, in minutes.
defaultedTimeZone - the time zone actually used for this object, which must be specified. The offset to GMT, in minutes.
Method Detail

getInstance

public static TimeAttribute getInstance(Node root)
                                 throws ParsingException,
                                        NumberFormatException,
                                        ParseException
Returns a new TimeAttribute that represents the xs:time at a particular DOM node.

Parameters:
root - the Node that contains the desired value
Returns:
a new TimeAttribute representing the appropriate value (null if there is a parsing error)
Throws:
ParsingException
NumberFormatException
ParseException

getInstance

public static TimeAttribute getInstance(String value)
                                 throws ParsingException,
                                        NumberFormatException,
                                        ParseException
Returns a new TimeAttribute that represents the xs:time value indicated by the string provided.

Parameters:
value - a string representing the desired value
Returns:
a new TimeAttribute representing the desired value (null if there is a parsing error)
Throws:
ParsingException - if any problems occurred while parsing
NumberFormatException
ParseException

getValue

public Date getValue()
Gets the time represented by this object. The return value is a Date object representing the specified time down to second resolution with a date of January 1, 1970. Subsecond values are handled by the getNanoseconds method.

Specified by:
getValue in class AttributeValue
Returns:
a Date object representing the time represented by this object

getMilliseconds

public long getMilliseconds()
Gets the number of milliseconds since midnight GMT that this attribute value represents. This is the same time returned by getValue, and likewise the milliseconds are provided with second resolution.

Returns:
milliseconds since midnight GMT

getNanoseconds

public int getNanoseconds()
Gets the nanoseconds of this object.

Returns:
the number of nanoseconds

getTimeZone

public int getTimeZone()
Gets the time zone of this object (or TZ_UNSPECIFIED if unspecified).

Returns:
the offset to GMT in minutes (positive or negative)

getDefaultedTimeZone

public int getDefaultedTimeZone()
Gets the time zone actually used for this object (if it was originally unspecified, the default time zone used).

Returns:
the offset to GMT in minutes (positive or negative)

equals

public boolean equals(Object o)
Returns true if the input is an instance of this class and if its value equals the value contained in this class.

Overrides:
equals in class Object
Parameters:
o - the object to compare
Returns:
true if this object and the input represent the same value

hashCode

public int hashCode()
Returns the hashcode value used to index and compare this object with others of the same type. Typically this is the hashcode of the backing data object.

Overrides:
hashCode in class Object
Returns:
the object's hashcode value

toString

public String toString()
Converts to a String representation.

Overrides:
toString in class Object
Returns:
the String representation

encode

public String encode()
Encodes the value in a form suitable for including in XML data like a request or an obligation. This returns a time value that could in turn be used by the factory to create a new instance with the same value.

Specified by:
encode in class AttributeValue
Returns:
a String form of the value

JBoss port of sunxacml 2.0.5-redhat-1

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.