SunTM's XACML Implementation for JavaTM

com.sun.xacml.attr
Class DateTimeAttribute

java.lang.Object
  extended bycom.sun.xacml.attr.AttributeValue
      extended bycom.sun.xacml.attr.DateTimeAttribute
All Implemented Interfaces:
Evaluatable

public class DateTimeAttribute
extends AttributeValue

Representation of an xs:dateTime value. This class supports parsing xs:dateTime 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

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
DateTimeAttribute()
          Creates a new DateTimeAttribute that represents the current date in the default time zone.
DateTimeAttribute(Date date, int nanoseconds, int timeZone, int defaultedTimeZone)
          Creates a new DateTimeAttribute that represents the date 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 DateTimeAttribute getInstance(Node root)
          Returns a new DateTimeAttribute that represents the xs:dateTime at a particular DOM node.
static DateTimeAttribute getInstance(String value)
          Returns a new DateTimeAttribute that represents the xs:dateTime value indicated by the string provided.
 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 date and 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 com.sun.xacml.attr.AttributeValue
encode, encode, encodeWithTags, evaluate, evaluatesToBag, getChildren, getType, isBag
 
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

DateTimeAttribute

public DateTimeAttribute()
Creates a new DateTimeAttribute that represents the current date in the default time zone.


DateTimeAttribute

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

Parameters:
date - a Date object representing the specified date and time down to second resolution. 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 (if it was originally unspecified, the default time zone used). The offset to GMT, in minutes.
Method Detail

getInstance

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

Parameters:
root - the Node that contains the desired value
Returns:
a new DateTimeAttribute representing the appropriate value
Throws:
ParsingException - if any problems occurred while parsing
NumberFormatException
ParseException

getInstance

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

Parameters:
value - a string representing the desired value
Returns:
a new DateTimeAttribute representing the desired value
Throws:
ParsingException - if the text is formatted incorrectly
NumberFormatException - if the nanosecond format is incorrect
ParseException

getValue

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

NOTE: The Date object is cloned before it is returned to avoid unauthorized changes.

Returns:
a Date object representing the date and time represented by this object

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.

Two DateTimeAttributes are equal if and only if the dates and times represented are identical (down to the nanosecond).

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.

Returns:
the object's hashcode value

toString

public String toString()
Converts to a String representation.

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 must return a 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

Sun's XACML Implementation Version 1.2

Copyright 2003-2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

Sun, Sun Microsystems, the Sun Logo, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.