gnu.xml.validation.datatype
Class SimpleType
- Datatype
An XML Schema simple type.
static int | ANY - The variety of the
anySimpleType datatype.
|
static int | ATOMIC - The atomic variety.
|
static int | ID_TYPE_ID - Indicates that RELAX NG compatibility processors should
treat this datatype as having ID semantics.
|
static int | ID_TYPE_IDREF - Indicates that RELAX NG compatibility processors should
treat this datatype as having IDREF semantics.
|
static int | ID_TYPE_IDREFS - Indicates that RELAX NG compatibility processors should
treat this datatype as having IDREFS semantics.
|
static int | ID_TYPE_NULL - Indicates that the datatype doesn't have ID/IDREF semantics.
|
static int | LIST - The list variety.
|
static int | UNION - The union variety.
|
Annotation | annotation - Optional annotation.
|
SimpleType | baseType - If this datatype has been derived by restriction, then the component
from which it was derived.
|
Set<E> | facets - The facets of this simple type.
|
int | fundamentalFacets - The fundamental facets of this simple type.
|
int | variety - The variety of this simple type.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
ANY
public static final int ANY
The variety of the anySimpleType
datatype.
ATOMIC
public static final int ATOMIC
The atomic variety.
ID_TYPE_ID
public static final int ID_TYPE_ID
Indicates that RELAX NG compatibility processors should
treat this datatype as having ID semantics.
This value is one of the possible return values of the
Datatype.getIdType()
method.
ID_TYPE_IDREF
public static final int ID_TYPE_IDREF
Indicates that RELAX NG compatibility processors should
treat this datatype as having IDREF semantics.
This value is one of the possible return values of the
Datatype.getIdType()
method.
ID_TYPE_IDREFS
public static final int ID_TYPE_IDREFS
Indicates that RELAX NG compatibility processors should
treat this datatype as having IDREFS semantics.
This value is one of the possible return values of the
Datatype.getIdType()
method.
ID_TYPE_NULL
public static final int ID_TYPE_NULL
Indicates that the datatype doesn't have ID/IDREF semantics.
This value is one of the possible return values of the
Datatype.getIdType()
method.
LIST
public static final int LIST
The list variety.
UNION
public static final int UNION
The union variety.
baseType
public final SimpleType baseType
If this datatype has been derived by restriction, then the component
from which it was derived.
fundamentalFacets
public int fundamentalFacets
The fundamental facets of this simple type.
variety
public final int variety
The variety of this simple type.
checkValid
public void checkValid(String value,
ValidationContext context)
throws DatatypeException
Similar to the isValid method but throws an exception with diagnosis
in case of errors.
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.
createStreamingValidator
public DatatypeStreamingValidator createStreamingValidator(ValidationContext context)
Creates an instance of a streaming validator for this type.
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
context
- 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.
createValue
public Object createValue(String literal,
ValidationContext context)
Converts lexcial value and the current context to the corresponding
value object.
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
context
- 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.
- null
when the given lexical value is not a valid lexical
value for this type.
getIdType
public int getIdType()
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.
- getIdType in interface Datatype
isContextDependent
public boolean isContextDependent()
- isContextDependent in interface Datatype
- 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).
sameValue
public boolean sameValue(Object value1,
Object value2)
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.
- sameValue in interface Datatype
- true if two value objects are considered equal according to
the definition of this datatype; false if otherwise.
valueHashCode
public int valueHashCode(Object value)
Computes the hash code for a value object,
which is consistent with the sameValue method.
- valueHashCode in interface Datatype
- hash code for the specified value object.
SimpleType.java --
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.