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

Quick Search    Search Deep

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

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

public class YearMonthDurationAttribute
extends AttributeValue

Representation of an xf:yearMonthDuration value. This class supports parsing xd:yearMonthDuration 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 static java.math.BigInteger big12
          Static BigInteger values.
private static java.math.BigInteger bigMaxLong
           
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 int GROUP_MONTHS
          The index of the capturing group for the number of months.
private static int GROUP_SIGN
          The index of the capturing group for the negative sign.
private static int GROUP_YEARS
          The index of the capturing group for the number of years.
static java.lang.String identifier
          Official name of this type
private static java.net.URI identifierURI
          URI version of name for this type
private  long months
          Number of months
private  boolean negative
          Negative flag.
private static java.util.regex.Pattern pattern
          A shared Pattern object, only initialized if needed
private static java.lang.String patternString
          Regular expression for yearMonthDuration (a la java.util.regex)
private  long totalMonths
          Total number of months (used for equals)
private  long years
          Number of years
 
Fields inherited from class com.sun.xacml.attr.AttributeValue
 
Constructor Summary
YearMonthDurationAttribute(boolean negative, long years, long months)
          Creates a new YearMonthDurationAttribute that represents the duration 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.
static YearMonthDurationAttribute getInstance(org.w3c.dom.Node root)
          Returns a new YearMonthDurationAttribute that represents the xf:yearMonthDuration at a particular DOM node.
static YearMonthDurationAttribute getInstance(java.lang.String value)
          Returns a new YearMonthDurationAttribute that represents the xf:yearMonthDuration value indicated by the string provided.
 long getMonths()
          Gets the number of months.
 long getYears()
          Gets the number of years.
 int hashCode()
          Returns the hashcode value used to index and compare this object with others of the same type.
 boolean isNegative()
          Returns true if the duration is negative.
private static long parseGroup(java.util.regex.Matcher matcher, int groupNumber)
          Returns the long value for the capturing group groupNumber.
 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.


earlyException

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


patternString

private static final java.lang.String patternString
Regular expression for yearMonthDuration (a la java.util.regex)

See Also:
Constant Field Values

GROUP_SIGN

private static final int GROUP_SIGN
The index of the capturing group for the negative sign.

See Also:
Constant Field Values

GROUP_YEARS

private static final int GROUP_YEARS
The index of the capturing group for the number of years.

See Also:
Constant Field Values

GROUP_MONTHS

private static final int GROUP_MONTHS
The index of the capturing group for the number of months.

See Also:
Constant Field Values

big12

private static java.math.BigInteger big12
Static BigInteger values. We only use these if one of the components is bigger than Integer.MAX_LONG and we want to detect overflow, so we don't initialize these until they're needed.


bigMaxLong

private static java.math.BigInteger bigMaxLong

pattern

private static java.util.regex.Pattern pattern
A shared Pattern object, only initialized if needed


negative

private boolean negative
Negative flag. true if duration is negative, false otherwise


years

private long years
Number of years


months

private long months
Number of months


totalMonths

private long totalMonths
Total number of months (used for equals)


encodedValue

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

Constructor Detail

YearMonthDurationAttribute

public YearMonthDurationAttribute(boolean negative,
                                  long years,
                                  long months)
                           throws java.lang.IllegalArgumentException
Creates a new YearMonthDurationAttribute that represents the duration supplied.

Method Detail

getInstance

public static YearMonthDurationAttribute getInstance(org.w3c.dom.Node root)
                                              throws com.sun.xacml.ParsingException
Returns a new YearMonthDurationAttribute that represents the xf:yearMonthDuration at a particular DOM node.


parseGroup

private static long parseGroup(java.util.regex.Matcher matcher,
                               int groupNumber)
                        throws java.lang.NumberFormatException
Returns the long value for the capturing group groupNumber. This method takes a Matcher that has been used to match a Pattern against a String, fetches the value for the specified capturing group, converts that value to an long, and returns the value. If that group did not match, 0 is returned. If the matched value is not a valid long, NumberFormatException is thrown.


getInstance

public static YearMonthDurationAttribute getInstance(java.lang.String value)
                                              throws com.sun.xacml.ParsingException
Returns a new YearMonthDurationAttribute that represents the xf:yearMonthDuration value indicated by the string provided.


isNegative

public boolean isNegative()
Returns true if the duration is negative.


getYears

public long getYears()
Gets the number of years.


getMonths

public long getMonths()
Gets the number of months.


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 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