com.saxonica.schema
Class Facet

java.lang.Object
  extended by com.saxonica.schema.Facet
All Implemented Interfaces:
SerializableSchemaComponent, Serializable
Direct Known Subclasses:
DigitsFacet, EnumerationFacet, EnumerationFacetSet, LengthFacet, PatternFacet, ValueRangeFacet, WhitespaceFacet

public abstract class Facet
extends Object
implements Serializable, SerializableSchemaComponent

Represents an XML Schema Facet. Most facets are represented by subclasses of this class, the only exception is whiteSpace.

See Also:
Serialized Form

Field Summary
static String ENUMERATION
           
static String FRACTIONDIGITS
           
static String LENGTH
           
static String MAX_EXCLUSIVE
           
static String MAX_INCLUSIVE
           
static String MAX_LENGTH
           
static String MIN_EXCLUSIVE
           
static String MIN_INCLUSIVE
           
static String MIN_LENGTH
           
static String PATTERN
           
static String TOTALDIGITS
           
static String WHITESPACE
           
 
Fields inherited from interface com.saxonica.schema.SerializableSchemaComponent
ALL_COMPOSITOR, ATOMIC_TYPE, ATTRIBUTE_DECL, ATTRIBUTE_GROUP, ATTRIBUTE_GROUP_REF, ATTRIBUTE_USE, ATTRIBUTE_WILDCARD, CHOICE_COMPOSITOR, COMPLEX_TYPE, ELEMENT_DECL, ELEMENT_PARTICLE, ELEMENT_WILDCARD, FACET, KEY, KEYREF, LIST_TYPE, MODEL_GROUP, MODEL_GROUP_REF, NOTATION, SEQUENCE_COMPOSITOR, UNION_TYPE, UNIQUE
 
Constructor Summary
Facet()
           
 
Method Summary
 boolean appliesToWholeList()
          Test whether this is a facet that can be used to test the normalized value of a list type.
 void checkFacetRestriction(UserSimpleType type, SimpleType base)
          Check that this facet is legal when used on a type derived by restriction
 int getComponentTypeCode()
          Get a unique number identifying the type of component
 String getName()
          Returns the name of this Facet
 String getValue()
          Returns the character (String) representation of this facet
 int getWhitespaceAction()
          Get the whitespace action required by this facet: one of PRESERVE, REPLACE, or COLLAPSE.
 boolean isFixed()
          Test if the facet is defined in the schema with fixed="true"
 boolean isNewlyIntroduced(SimpleType base)
          Test whether this facet is newly introduced on this type, that is, whether it is absent from the base type
 void serialize(SchemaSerializer serializer)
          Serialize the schema component
 void setFixed(boolean fixed)
          Set whether the facet is defined as fixed
 boolean testAtomicValue(AtomicValue value)
          Test whether an atomic value conforms to this facet
 boolean testLength(int count)
          Test whether the length of a list conforms to this facet.
 long toLong()
          Returns the numeric value of this facet
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENUMERATION

public static final String ENUMERATION
See Also:
Constant Field Values

LENGTH

public static final String LENGTH
See Also:
Constant Field Values

PATTERN

public static final String PATTERN
See Also:
Constant Field Values

MAX_EXCLUSIVE

public static final String MAX_EXCLUSIVE
See Also:
Constant Field Values

MAX_INCLUSIVE

public static final String MAX_INCLUSIVE
See Also:
Constant Field Values

MIN_EXCLUSIVE

public static final String MIN_EXCLUSIVE
See Also:
Constant Field Values

MIN_INCLUSIVE

public static final String MIN_INCLUSIVE
See Also:
Constant Field Values

MAX_LENGTH

public static final String MAX_LENGTH
See Also:
Constant Field Values

MIN_LENGTH

public static final String MIN_LENGTH
See Also:
Constant Field Values

WHITESPACE

public static final String WHITESPACE
See Also:
Constant Field Values

TOTALDIGITS

public static final String TOTALDIGITS
See Also:
Constant Field Values

FRACTIONDIGITS

public static final String FRACTIONDIGITS
See Also:
Constant Field Values
Constructor Detail

Facet

public Facet()
Method Detail

isFixed

public boolean isFixed()
Test if the facet is defined in the schema with fixed="true"

Returns:
true if fixed

setFixed

public void setFixed(boolean fixed)
Set whether the facet is defined as fixed

Parameters:
fixed - true if the facet is fixed

getName

public String getName()
Returns the name of this Facet

Returns:
the name of this Facet

getValue

public String getValue()
Returns the character (String) representation of this facet

Returns:
the value of this facet

toLong

public long toLong()
            throws NumberFormatException
Returns the numeric value of this facet

Returns:
a long representation of the value of this facet
Throws:
NumberFormatException

checkFacetRestriction

public void checkFacetRestriction(UserSimpleType type,
                                  SimpleType base)
                           throws SchemaException,
                                  ValidationException
Check that this facet is legal when used on a type derived by restriction

Parameters:
type - the type on which the facet is defined
base - the type from which the restricted type is derived
Throws:
SchemaException - if the facet is not legal
ValidationException

isNewlyIntroduced

public boolean isNewlyIntroduced(SimpleType base)
Test whether this facet is newly introduced on this type, that is, whether it is absent from the base type


appliesToWholeList

public boolean appliesToWholeList()
Test whether this is a facet that can be used to test the normalized value of a list type. (Specifically, this is true only for pattern facets and enumeration facets)


testAtomicValue

public boolean testAtomicValue(AtomicValue value)
Test whether an atomic value conforms to this facet

Parameters:
value - the value to be tested
Returns:
true if the value conforms; false if it doesn't conform, or if the test fails

testLength

public boolean testLength(int count)
Test whether the length of a list conforms to this facet. Always true except for length facets


getWhitespaceAction

public int getWhitespaceAction()
Get the whitespace action required by this facet: one of PRESERVE, REPLACE, or COLLAPSE. Returns a dummy value of PRESERVE for facets other than whitespace facets.


serialize

public void serialize(SchemaSerializer serializer)
               throws IOException
Serialize the schema component

Specified by:
serialize in interface SerializableSchemaComponent
Throws:
IOException

getComponentTypeCode

public int getComponentTypeCode()
Get a unique number identifying the type of component

Specified by:
getComponentTypeCode in interface SerializableSchemaComponent


Copyright (C) Michael H. Kay. All rights reserved.