Package org.exolab.castor.xml.schema
Class Facet
- java.lang.Object
-
- org.exolab.castor.xml.schema.Structure
-
- org.exolab.castor.xml.schema.Annotated
-
- org.exolab.castor.xml.schema.Facet
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
MaxExclusive,MaxInclusive,MinExclusive,MinInclusive
public class Facet extends Annotated
Represents the base type for XML Schema Facets- Version:
- $Revision: 7492 $ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $
- Author:
- Keith Visco
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringENUMERATIONstatic java.lang.StringFRACTIONDIGITSstatic java.lang.StringLENGTHstatic java.lang.StringMAX_EXCLUSIVEstatic java.lang.StringMAX_INCLUSIVEstatic java.lang.StringMAX_LENGTHstatic java.lang.StringMIN_EXCLUSIVEstatic java.lang.StringMIN_INCLUSIVEstatic java.lang.StringMIN_LENGTHstatic java.lang.StringPATTERNstatic java.lang.StringPRECISIONstatic java.lang.StringTOTALDIGITSstatic java.lang.StringWHITESPACEstatic java.lang.StringWHITESPACE_COLLAPSEstatic java.lang.StringWHITESPACE_PRESERVEstatic java.lang.StringWHITESPACE_REPLACE-
Fields inherited from class org.exolab.castor.xml.schema.Structure
ANNOTATION, ANYTYPE, APPINFO, ATTRIBUTE, ATTRIBUTE_GROUP, COMPLEX_CONTENT, COMPLEX_TYPE, DOCUMENTATION, ELEMENT, FACET, GROUP, IDENTITY_FIELD, IDENTITY_SELECTOR, KEY, KEYREF, LIST, MODELGROUP, MODELGROUP_REF, REDEFINE, SCHEMA, SIMPLE_CONTENT, SIMPLE_TYPE, UNION, UNIQUE, UNKNOWN, WILDCARD
-
-
Constructor Summary
Constructors Constructor Description Facet(java.lang.String name, java.lang.String value)Creates a new Facet with the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckConstraints(java.util.Enumeration localFacets, java.util.Enumeration baseFacets)Checks the constraints on the current facet against the other local facets of the same derived data type and facets of the base data type.java.lang.StringgetName()Returns the name of this Facet.SimpleTypegetOwningType()Returns the owningSimpleTypeinstance.shortgetStructureType()Returns the type of this Schema Structure.java.lang.StringgetValue()Returns the character (String) representation of this facet.booleanisMultivalued()Returns true if this Facet can occur more than once, such as the "enumeration" facet.booleanoverridesBase(Facet baseFacet)Checks whether the current facet overrides a facet of the base data type.voidsetOwningType(SimpleType owningType)Sets the owningSimpleTypeinstance.java.math.BigDecimaltoBigDecimal()Returns aBigDecimalrepresentation of the value of this facet.bytetoByte()Returns a byte representation of the value of this facet.doubletoDouble()Returns a double representation of the value of this facet.floattoFloat()Returns a double representation of the value of this facet.inttoInt()Returns an int representation of the value of this facet.longtoLong()Returns a long representation of the value of this facet.shorttoShort()Returns an short representation of the value of this facet.voidvalidate()Checks the validity of this Schema defintion.-
Methods inherited from class org.exolab.castor.xml.schema.Annotated
addAnnotation, getAnnotations, removeAnnotation
-
-
-
-
Field Detail
-
ENUMERATION
public static final java.lang.String ENUMERATION
- See Also:
- Constant Field Values
-
LENGTH
public static final java.lang.String LENGTH
- See Also:
- Constant Field Values
-
PATTERN
public static final java.lang.String PATTERN
- See Also:
- Constant Field Values
-
PRECISION
public static final java.lang.String PRECISION
- See Also:
- Constant Field Values
-
MAX_EXCLUSIVE
public static final java.lang.String MAX_EXCLUSIVE
- See Also:
- Constant Field Values
-
MAX_INCLUSIVE
public static final java.lang.String MAX_INCLUSIVE
- See Also:
- Constant Field Values
-
MIN_EXCLUSIVE
public static final java.lang.String MIN_EXCLUSIVE
- See Also:
- Constant Field Values
-
MIN_INCLUSIVE
public static final java.lang.String MIN_INCLUSIVE
- See Also:
- Constant Field Values
-
MAX_LENGTH
public static final java.lang.String MAX_LENGTH
- See Also:
- Constant Field Values
-
MIN_LENGTH
public static final java.lang.String MIN_LENGTH
- See Also:
- Constant Field Values
-
WHITESPACE
public static final java.lang.String WHITESPACE
- See Also:
- Constant Field Values
-
TOTALDIGITS
public static final java.lang.String TOTALDIGITS
- See Also:
- Constant Field Values
-
FRACTIONDIGITS
public static final java.lang.String FRACTIONDIGITS
- See Also:
- Constant Field Values
-
WHITESPACE_PRESERVE
public static final java.lang.String WHITESPACE_PRESERVE
- See Also:
- Constant Field Values
-
WHITESPACE_REPLACE
public static final java.lang.String WHITESPACE_REPLACE
- See Also:
- Constant Field Values
-
WHITESPACE_COLLAPSE
public static final java.lang.String WHITESPACE_COLLAPSE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of this Facet.- Returns:
- the name of this Facet
-
getValue
public java.lang.String getValue()
Returns the character (String) representation of this facet.- Returns:
- the value of this facet
-
isMultivalued
public boolean isMultivalued()
Returns true if this Facet can occur more than once, such as the "enumeration" facet.- Returns:
- true if this Facet can occur more than once.
-
toInt
public int toInt() throws java.lang.NumberFormatExceptionReturns an int representation of the value of this facet.- Returns:
- an int representation of the value of this facet
- Throws:
java.lang.NumberFormatException- if the value fails to parse as a int.
-
toLong
public long toLong() throws java.lang.NumberFormatExceptionReturns a long representation of the value of this facet.- Returns:
- a long representation of the value of this facet
- Throws:
java.lang.NumberFormatException- if the value fails to parse as a long.
-
toShort
public short toShort() throws java.lang.NumberFormatExceptionReturns an short representation of the value of this facet.- Returns:
- an short representation of the value of this facet
- Throws:
java.lang.NumberFormatException- if the value fails to parse as a short.
-
toFloat
public float toFloat() throws java.lang.NumberFormatExceptionReturns a double representation of the value of this facet.- Returns:
- a double representation of the value of this facet
- Throws:
java.lang.NumberFormatException- if the value fails to parse as a float.
-
toDouble
public double toDouble() throws java.lang.NumberFormatExceptionReturns a double representation of the value of this facet.- Returns:
- a double representation of the value of this facet
- Throws:
java.lang.NumberFormatException- if the value fails to parse as a double.
-
toByte
public byte toByte() throws java.lang.NumberFormatExceptionReturns a byte representation of the value of this facet.- Returns:
- a byte representation of the value of this facet
- Throws:
java.lang.NumberFormatException- if the value fails to parse as a byte.
-
toBigDecimal
public java.math.BigDecimal toBigDecimal() throws java.lang.NumberFormatExceptionReturns aBigDecimalrepresentation of the value of this facet.- Returns:
- a
BigDecimalrepresentation of the value of this facet - Throws:
java.lang.NumberFormatException- if the value cannot be parsed as number
-
getStructureType
public short getStructureType()
Returns the type of this Schema Structure.- Specified by:
getStructureTypein classStructure- Returns:
- the type of this Schema Structure
-
validate
public void validate() throws ValidationExceptionChecks the validity of this Schema defintion.- Specified by:
validatein classStructure- Throws:
ValidationException- when this Schema definition is invalid.
-
overridesBase
public boolean overridesBase(Facet baseFacet)
Checks whether the current facet overrides a facet of the base data type. This does generally happen when a data type is derived by restriction and it therefore has facet(s), which are more restrictive than the ones of the base data type.This method is used for merging facets of the base and derived types, in order to create an effective set of facets for the derived type.
It's important to note that this method does not perform any validity checks. Validation must be generally performed before trying to merge facets of the base and derived types.
- Parameters:
baseFacet- a facet of the base data type- Returns:
true, if the current facet overridesbaseFacet;false, otherwise.- See Also:
checkConstraints(Enumeration,Enumeration),SimpleType.getEffectiveFacets()
-
checkConstraints
public void checkConstraints(java.util.Enumeration localFacets, java.util.Enumeration baseFacets) throws SchemaExceptionChecks the constraints on the current facet against the other local facets of the same derived data type and facets of the base data type. Validation is performed according to the rules defined in "XML Schema Part 2: Datatypes Second Edition" document.- Parameters:
localFacets- local facets of the data typebaseFacets- merged facets of the base data type- Throws:
SchemaException- when the current facet does not satisfy schema component validation constraints
-
setOwningType
public void setOwningType(SimpleType owningType)
Sets the owningSimpleTypeinstance.- Parameters:
owningType- The owningSimpleTypeinstance.
-
getOwningType
public SimpleType getOwningType()
Returns the owningSimpleTypeinstance.- Returns:
- The owning
SimpleTypeinstance.
-
-