|
|||||||||
Home >> All >> com >> sun >> xacml >> [ attr overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
com.sun.xacml.attr
Class DateAttribute

java.lang.Objectcom.sun.xacml.attr.AttributeValue
com.sun.xacml.attr.DateAttribute
- All Implemented Interfaces:
- com.sun.xacml.cond.Evaluatable
- public class DateAttribute
- extends AttributeValue
Representation of an xs:date value. This class supports parsing
xs:date 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). |
private static java.util.Calendar |
gmtCalendar
Calendar for GMT |
(package private) static int |
HOURS_PER_DAY
Number of hours in a day (shared by other classes in this package) |
static java.lang.String |
identifier
Official name of this type |
private static java.net.URI |
identifierURI
URI version of name for this type |
(package private) static long |
MILLIS_PER_DAY
Number of milliseconds in a day (shared by other classes in this package) |
(package private) static int |
MILLIS_PER_HOUR
Number of milliseconds in an hour (shared by other classes in this package) |
(package private) static int |
MILLIS_PER_MINUTE
Number of milliseconds in a minute (shared by other classes in this package) |
(package private) static int |
MILLIS_PER_SECOND
Number of milliseconds per second (shared by other classes in this package) |
(package private) static int |
MINUTES_PER_HOUR
Number of minutes in an hour (shared by other classes in this package) |
(package private) static int |
NANOS_PER_MILLI
Number of nanoseconds per millisecond (shared by other classes in this package) |
(package private) static int |
NANOS_PER_SECOND
Number of nanoseconds per second (shared by other classes in this package) |
(package private) static int |
SECONDS_PER_MINUTE
Number of seconds in a minute (shared by other classes in this package) |
private static java.text.DateFormat |
simpleParser
Parser for dates with no time zones |
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. |
private java.util.Date |
value
The instant (in GMT) at which the specified date began (midnight) in the specified time zone. |
private static java.text.DateFormat |
zoneParser
Parser for dates with RFC 822 time zones (like +0300) |
Fields inherited from class com.sun.xacml.attr.AttributeValue |
|
Constructor Summary | |
DateAttribute()
Creates a new TimeAttribute that represents
the current date in the default time zone. |
|
DateAttribute(java.util.Date date,
int timeZone,
int defaultedTimeZone)
Creates a new DateAttribute that represents
the date 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. |
private java.lang.String |
formatDateWithTZ()
Encodes the value of this object as an xsi:date. |
int |
getDefaultedTimeZone()
Gets the time zone actually used for this object (if it was originally unspecified, the default time zone used). |
static DateAttribute |
getInstance(org.w3c.dom.Node root)
Returns a new DateAttribute that represents
the xs:date at a particular DOM node. |
static DateAttribute |
getInstance(java.lang.String value)
Returns a new DateAttribute that represents
the xs:date value indicated by the string provided. |
int |
getTimeZone()
Gets the specified time zone of this object (or TZ_UNSPECIFIED if unspecified). |
java.util.Date |
getValue()
Gets the date 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 timeZone,
int defaultedTimeZone)
Initialization code shared by constructors. |
private static void |
initParsers()
Initialize the parser objects. |
private static java.util.Date |
strictParse(java.text.DateFormat parser,
java.lang.String str)
Parse a String using a DateFormat parser, requiring that the entire String be consumed by the parser. |
java.lang.String |
toString()
Converts to a String representation. |
(package private) static java.lang.String |
zeroPadInt(int intValue,
int minDigits)
Converts an integer to a base 10 string and pads it with zeros on the left until it has at least the specified number of digits. |
(package private) static java.lang.String |
zeroPadIntString(java.lang.String unpadded,
int minDigits)
Takes a String representation of an integer (an optional sign followed by digits) and pads it with zeros on the left until it has at least the specified number of digits. |
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.
simpleParser
private static java.text.DateFormat simpleParser
- Parser for dates with no time zones
This field is only initialized if needed (by initParsers()).
NOTE: This object should only be accessed from code that has synchronized on it, since SimpleDateFormat objects are not thread-safe. If this is causing performance problems, we could easily make this a method variable in methods that use it instead of a class field. But that would mean we'd need to spend a lot more time creating these objects.
zoneParser
private static java.text.DateFormat zoneParser
- Parser for dates with RFC 822 time zones (like +0300)
This field is only initialized if needed (by initParsers()).
NOTE: This object should only be accessed from code that has a lock on it, since SimpleDateFormat objects are not thread-safe.
gmtCalendar
private static java.util.Calendar gmtCalendar
- Calendar for GMT
NOTE: This object should only be accessed from code that has a lock on it, since Calendar objects are not generally thread-safe.
NANOS_PER_MILLI
static final int NANOS_PER_MILLI
- Number of nanoseconds per millisecond
(shared by other classes in this package)
- See Also:
- Constant Field Values
MILLIS_PER_SECOND
static final int MILLIS_PER_SECOND
- Number of milliseconds per second
(shared by other classes in this package)
- See Also:
- Constant Field Values
SECONDS_PER_MINUTE
static final int SECONDS_PER_MINUTE
- Number of seconds in a minute
(shared by other classes in this package)
- See Also:
- Constant Field Values
MINUTES_PER_HOUR
static final int MINUTES_PER_HOUR
- Number of minutes in an hour
(shared by other classes in this package)
- See Also:
- Constant Field Values
HOURS_PER_DAY
static final int HOURS_PER_DAY
- Number of hours in a day
(shared by other classes in this package)
- See Also:
- Constant Field Values
NANOS_PER_SECOND
static final int NANOS_PER_SECOND
- Number of nanoseconds per second
(shared by other classes in this package)
- See Also:
- Constant Field Values
MILLIS_PER_MINUTE
static final int MILLIS_PER_MINUTE
- Number of milliseconds in a minute
(shared by other classes in this package)
- See Also:
- Constant Field Values
MILLIS_PER_HOUR
static final int MILLIS_PER_HOUR
- Number of milliseconds in an hour
(shared by other classes in this package)
- See Also:
- Constant Field Values
MILLIS_PER_DAY
static final long MILLIS_PER_DAY
- Number of milliseconds in a day
(shared by other classes in this package)
- 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
value
private java.util.Date value
- The instant (in GMT) at which the specified date began (midnight)
in the specified time zone. If no time zone was specified,
the local time zone is used.
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 |
DateAttribute
public DateAttribute()
- Creates a new
TimeAttribute
that represents the current date in the default time zone.
DateAttribute
public DateAttribute(java.util.Date date, int timeZone, int defaultedTimeZone)
- Creates a new
DateAttribute
that represents the date supplied.
Method Detail |
init
private void init(java.util.Date date, int timeZone, int defaultedTimeZone)
- Initialization code shared by constructors.
getInstance
public static DateAttribute getInstance(org.w3c.dom.Node root) throws java.text.ParseException
- Returns a new
DateAttribute
that represents the xs:date at a particular DOM node.
getInstance
public static DateAttribute getInstance(java.lang.String value) throws java.text.ParseException
- Returns a new
DateAttribute
that represents the xs:date value indicated by the string provided.
strictParse
private static java.util.Date strictParse(java.text.DateFormat parser, java.lang.String str) throws java.text.ParseException
- Parse a String using a DateFormat parser, requiring that
the entire String be consumed by the parser. On success,
return a Date. On failure, throw a ParseException.
Synchronize on the parser object when using it, since we assume they're the shared static objects in this class.
initParsers
private static void initParsers()
- Initialize the parser objects.
getValue
public java.util.Date getValue()
- Gets the date represented by this object. The return value is
a
Date
object representing the instant at which the specified date began (midnight) in the time zone.NOTE: The
Date
object is cloned before it is returned to avoid unauthorized changes.
getTimeZone
public int getTimeZone()
- Gets the specified 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.
Two
DateAttribute
s are equal if and only if the instant on which the date began is equal. This means that they must have the same time zone.
hashCode
public int hashCode()
- Returns the hashcode value used to index and compare this object with
others of the same type.
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 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 classAttributeValue
formatDateWithTZ
private java.lang.String formatDateWithTZ()
- Encodes the value of this object as an xsi:date.
Only for use when the time zone is specified.
zeroPadIntString
static java.lang.String zeroPadIntString(java.lang.String unpadded, int minDigits)
- Takes a String representation of an integer (an optional
sign followed by digits) and pads it with zeros on the left
until it has at least the specified number of digits.
Note that this function will work for an integer of
any size: int, long, etc.
zeroPadInt
static java.lang.String zeroPadInt(int intValue, int minDigits)
- Converts an integer to a base 10 string and pads it with
zeros on the left until it has at least the specified
number of digits. Note that the length of the resulting
string will be greater than minDigits if the number is
negative since the string will start with a minus sign.
|
|||||||||
Home >> All >> com >> sun >> xacml >> [ attr overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |