|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.thaiopensource.datatype.xsd.DatatypeBase
abstract class DatatypeBase
Field Summary | |
---|---|
(package private) static int |
WHITE_SPACE_COLLAPSE
|
(package private) static int |
WHITE_SPACE_PRESERVE
|
(package private) static int |
WHITE_SPACE_REPLACE
|
private int |
whiteSpace
|
Fields inherited from interface org.relaxng.datatype.Datatype |
---|
ID_TYPE_ID, ID_TYPE_IDREF, ID_TYPE_IDREFS, ID_TYPE_NULL |
Constructor Summary | |
---|---|
DatatypeBase()
|
|
DatatypeBase(int whiteSpace)
|
Method Summary | |
---|---|
(package private) boolean |
allowsValue(String str,
ValidationContext vc)
|
boolean |
alwaysValid()
|
void |
checkValid(String str,
ValidationContext vc)
Similar to the isValid method but throws an exception with diagnosis in case of errors. |
private static int |
collapseStart(String s)
|
private static String |
collapseWhiteSpace(String s)
|
DatatypeStreamingValidator |
createStreamingValidator(ValidationContext vc)
Creates an instance of a streaming validator for this type. |
Object |
createValue(String str,
ValidationContext vc)
Converts lexcial value and the current context to the corresponding value object. |
int |
getIdType()
Checks if the ID/IDREF semantics is associated with this datatype. |
(package private) Measure |
getMeasure()
|
(package private) OrderRelation |
getOrderRelation()
|
(package private) DatatypeBase |
getPrimitive()
|
(package private) abstract Object |
getValue(String str,
ValidationContext vc)
|
(package private) int |
getWhiteSpace()
|
boolean |
isContextDependent()
Checks if this datatype may need a context object for the validation. |
boolean |
isValid(String str,
ValidationContext vc)
Checks if the specified 'literal' matches this Datatype with respect to the current context. |
(package private) abstract boolean |
lexicallyAllows(String str)
|
(package private) String |
normalizeWhiteSpace(String str)
|
private static String |
replaceWhiteSpace(String s)
|
boolean |
sameValue(Object value1,
Object value2)
Tests the equality of two value objects which were originally created by the createValue method of this object. |
int |
valueHashCode(Object value)
Computes the hash code for a value object, which is consistent with the sameValue method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final int whiteSpace
static final int WHITE_SPACE_PRESERVE
static final int WHITE_SPACE_REPLACE
static final int WHITE_SPACE_COLLAPSE
Constructor Detail |
---|
DatatypeBase()
DatatypeBase(int whiteSpace)
Method Detail |
---|
abstract boolean lexicallyAllows(String str)
int getWhiteSpace()
public boolean isValid(String str, ValidationContext vc)
Datatype
isValid
in interface Datatype
str
- the lexical representation to be checked.vc
- If this datatype is context-dependent
(i.e. the Datatype.isContextDependent()
method returns true),
then the caller must provide a non-null valid context object.
Otherwise, the caller can pass null.
public void checkValid(String str, ValidationContext vc) throws DatatypeException
Datatype
If the specified 'literal' is a valid lexical representation for this datatype, then this method must return without throwing any exception. If not, the callee must throw an exception (with diagnosis message, if possible.)
The application can use this method to provide detailed error message to users. This method is kept separate from the isValid method to achieve higher performance during normal validation.
checkValid
in interface Datatype
DatatypeException
- If the given literal is invalid, then this exception is thrown.
If the callee supports error diagnosis, then the exception should
contain a diagnosis message.public Object createValue(String str, ValidationContext vc)
Datatype
The caller cannot generally assume that the value object is
a meaningful Java object. For example, the caller cannot expect
this method to return java.lang.Number
type for
the "integer" type of XML Schema Part 2.
Also, the caller cannot assume that the equals method and
the hashCode method of the value object are consistent with
the semantics of the datatype. For that purpose, the sameValue
method and the valueHashCode method have to be used. Note that
this means you cannot use classes like
java.util.Hashtable
to store the value objects.
The returned value object should be used solely for the sameValue and valueHashCode methods.
createValue
in interface Datatype
vc
- If this datatype is context-dependent
(when the Datatype.isContextDependent()
method returns true),
then the caller must provide a non-null valid context object.
Otherwise, the caller can pass null.
final String normalizeWhiteSpace(String str)
boolean allowsValue(String str, ValidationContext vc)
abstract Object getValue(String str, ValidationContext vc)
OrderRelation getOrderRelation()
Measure getMeasure()
private static final String collapseWhiteSpace(String s)
private static final int collapseStart(String s)
private static final String replaceWhiteSpace(String s)
DatatypeBase getPrimitive()
public boolean isContextDependent()
Datatype
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.
isContextDependent
in interface Datatype
public boolean alwaysValid()
alwaysValid
in interface Datatype2
public int getIdType()
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.
getIdType
in interface Datatype
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
.public int valueHashCode(Object value)
Datatype
valueHashCode
in interface Datatype
public boolean sameValue(Object value1, Object value2)
Datatype
sameValue
in interface Datatype
public DatatypeStreamingValidator createStreamingValidator(ValidationContext vc)
Datatype
By using streaming validators instead of the isValid method, the caller can avoid keeping the entire string, which is sometimes quite big, in memory.
createStreamingValidator
in interface Datatype
vc
- If this datatype is context-dependent
(i.e. the Datatype.isContextDependent()
method returns true),
then the caller must provide a non-null valid context object.
Otherwise, the caller can pass null.
The callee may keep a reference to this context object
only while the returned streaming validator is being used.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |