com.thaiopensource.datatype.xsd
Class ListDatatype

java.lang.Object
  extended by com.thaiopensource.datatype.xsd.DatatypeBase
      extended by com.thaiopensource.datatype.xsd.ListDatatype
All Implemented Interfaces:
Datatype2, Measure, Datatype

 class ListDatatype
extends DatatypeBase
implements Measure


Field Summary
private  DatatypeBase itemType
           
 
Fields inherited from class com.thaiopensource.datatype.xsd.DatatypeBase
WHITE_SPACE_COLLAPSE, WHITE_SPACE_PRESERVE, WHITE_SPACE_REPLACE
 
Fields inherited from interface org.relaxng.datatype.Datatype
ID_TYPE_ID, ID_TYPE_IDREF, ID_TYPE_IDREFS, ID_TYPE_NULL
 
Constructor Summary
ListDatatype(DatatypeBase itemType)
           
 
Method Summary
(package private)  boolean allowsValue(String str, ValidationContext vc)
           
 int getIdType()
          Checks if the ID/IDREF semantics is associated with this datatype.
 int getLength(Object obj)
           
(package private)  Measure getMeasure()
           
(package private)  Object getValue(String str, ValidationContext vc)
           
 boolean isContextDependent()
          Checks if this datatype may need a context object for the validation.
(package private)  boolean lexicallyAllows(String str)
           
 boolean sameValue(Object obj1, Object obj2)
          Tests the equality of two value objects which were originally created by the createValue method of this object.
 int valueHashCode(Object obj)
          Computes the hash code for a value object, which is consistent with the sameValue method.
 
Methods inherited from class com.thaiopensource.datatype.xsd.DatatypeBase
alwaysValid, checkValid, createStreamingValidator, createValue, getOrderRelation, getPrimitive, getWhiteSpace, isValid, normalizeWhiteSpace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itemType

private final DatatypeBase itemType
Constructor Detail

ListDatatype

ListDatatype(DatatypeBase itemType)
Method Detail

getValue

Object getValue(String str,
                ValidationContext vc)
Specified by:
getValue in class DatatypeBase

lexicallyAllows

boolean lexicallyAllows(String str)
Specified by:
lexicallyAllows in class DatatypeBase

allowsValue

boolean allowsValue(String str,
                    ValidationContext vc)
Overrides:
allowsValue in class DatatypeBase

getMeasure

Measure getMeasure()
Overrides:
getMeasure in class DatatypeBase

getLength

public int getLength(Object obj)
Specified by:
getLength in interface Measure

isContextDependent

public boolean isContextDependent()
Description copied from interface: Datatype
Checks if this datatype may need a context object for the validation.

The callee must return true even when the context is not always necessary. (For example, the "QName" type doesn't need a context object when validating unprefixed string. But nonetheless QName must return true.)

XSD's string and short types are examples of context-independent datatypes. Its QName and ENTITY types are examples of context-dependent datatypes.

When a datatype is context-independent, then the Datatype.isValid(java.lang.String, org.relaxng.datatype.ValidationContext) method, the Datatype.checkValid(java.lang.String, org.relaxng.datatype.ValidationContext) method, the Datatype.createStreamingValidator(org.relaxng.datatype.ValidationContext) method and the Datatype.createValue(java.lang.String, org.relaxng.datatype.ValidationContext) method can be called without providing a context object.

Specified by:
isContextDependent in interface Datatype
Overrides:
isContextDependent in class DatatypeBase
Returns:
true if this datatype is context-dependent (it needs a context object sometimes); false if this datatype is context-independent (it never needs a context object).

getIdType

public int getIdType()
Description copied from interface: Datatype
Checks if the ID/IDREF semantics is associated with this datatype.

This method is introduced to support the RELAX NG DTD compatibility spec. (Of course it's always free to use this method for other purposes.)

If you are implementing a datatype library and have no idea about the "RELAX NG DTD compatibility" thing, just return ID_TYPE_NULL is fine.

Specified by:
getIdType in interface Datatype
Overrides:
getIdType in class DatatypeBase
Returns:
If this datatype doesn't have any ID/IDREF semantics, it returns Datatype.ID_TYPE_NULL. If it has such a semantics (for example, XSD:ID, XSD:IDREF and comp:ID type), then it returns Datatype.ID_TYPE_ID, Datatype.ID_TYPE_IDREF or Datatype.ID_TYPE_IDREFS.

valueHashCode

public int valueHashCode(Object obj)
Description copied from interface: Datatype
Computes the hash code for a value object, which is consistent with the sameValue method.

Specified by:
valueHashCode in interface Datatype
Overrides:
valueHashCode in class DatatypeBase
Returns:
hash code for the specified value object.

sameValue

public boolean sameValue(Object obj1,
                         Object obj2)
Description copied from interface: Datatype
Tests the equality of two value objects which were originally created by the createValue method of this object. The behavior is undefined if objects not created by this type are passed. It is the caller's responsibility to ensure that value objects belong to this type.

Specified by:
sameValue in interface Datatype
Overrides:
sameValue in class DatatypeBase
Returns:
true if two value objects are considered equal according to the definition of this datatype; false if otherwise.