Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.sun.xacml.attr
Class TimeAttribute  view TimeAttribute download TimeAttribute.java

java.lang.Object
  extended bycom.sun.xacml.attr.AttributeValue
      extended bycom.sun.xacml.attr.TimeAttribute
All Implemented Interfaces:
com.sun.xacml.cond.Evaluatable

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

Field Summary
private  int defaultedTimeZone
          The time zone actually used for this object (if it was originally unspecified, the default time zone used).
private static java.lang.RuntimeException earlyException
          RuntimeException that wraps an Exception thrown during the creation of identifierURI, null if none.
private  java.lang.String encodedValue
          Cached encoded value (null if not cached yet).
static java.lang.String identifier
          Official name of this type
private static java.net.URI identifierURI
          URI version of name for this type
private  int nanoseconds
          The number of nanoseconds beyond the time given by the timeGMT field.
private  long timeGMT
          The time that this object represents in second resolution, in milliseconds GMT, with zero being midnight.
private  int timeZone
          The time zone specified for this object (or TZ_UNSPECIFIED if unspecified).
static int TZ_UNSPECIFIED
          Time zone value that indicates that the time zone was not specified.
 
Fields inherited from class com.sun.xacml.attr.AttributeValue
 
Constructor Summary
TimeAttribute()
          Creates a new TimeAttribute that represents the current time in the current time zone.
TimeAttribute(java.util.Date date, int nanoseconds, int timeZone, int defaultedTimeZone)
          Creates a new TimeAttribute that represents the time supplied.
 
Method Summary
 java.lang.String encode()
          Encodes the value in a form suitable for including in XML data like a request or an obligation.
 boolean equals(java.lang.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(org.w3c.dom.Node root)
          Returns a new TimeAttribute that represents the xs:time at a particular DOM node.
static TimeAttribute getInstance(java.lang.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).
 java.util.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.
private  void init(java.util.Date date, int nanoseconds, int timeZone, int defaultedTimeZone)
          Initialization code shared by constructors.
 java.lang.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 java.lang.String identifier
Official name of this type

See Also:
Constant Field Values

identifierURI

private static java.net.URI identifierURI
URI version of name for this type

This field is initialized by a static initializer so that we can catch any exceptions thrown by URI(String) and transform them into a RuntimeException, since this should never happen but should be reported properly if it ever does.

This object is used for synchronization whenever we need protection across this whole class.


earlyException

private static java.lang.RuntimeException earlyException
RuntimeException that wraps an Exception thrown during the creation of identifierURI, null if none.


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

timeGMT

private long timeGMT
The time that this object represents in second resolution, in milliseconds GMT, with zero being midnight. If no time zone was specified, the local time zone is used to convert to milliseconds relative to GMT.


nanoseconds

private int nanoseconds
The number of nanoseconds beyond the time given by the timeGMT field. The XML Query document says that fractional seconds must be supported down to at least 100 nanosecond resolution. The Date class only supports milliseconds, so we include here support for nanosecond resolution.


timeZone

private int timeZone
The time zone specified for this object (or TZ_UNSPECIFIED if unspecified). The offset to GMT, in minutes.


defaultedTimeZone

private int 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.


encodedValue

private java.lang.String encodedValue
Cached encoded value (null if not cached yet).

Constructor Detail

TimeAttribute

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


TimeAttribute

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

Method Detail

init

private void init(java.util.Date date,
                  int nanoseconds,
                  int timeZone,
                  int defaultedTimeZone)
Initialization code shared by constructors.


getInstance

public static TimeAttribute getInstance(org.w3c.dom.Node root)
                                 throws com.sun.xacml.ParsingException,
                                        java.lang.NumberFormatException,
                                        java.text.ParseException
Returns a new TimeAttribute that represents the xs:time at a particular DOM node.


getInstance

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


getValue

public java.util.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 55 method.


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.


getNanoseconds

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


getTimeZone

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


getDefaultedTimeZone

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


equals

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


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.


toString

public java.lang.String toString()
Converts to a String representation.


encode

public java.lang.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