com.saxonica.schema
Class EnumerationFacet

java.lang.Object
  extended by com.saxonica.schema.Facet
      extended by com.saxonica.schema.EnumerationFacet
All Implemented Interfaces:
Serializable

public class EnumerationFacet
extends Facet

Represents a single enumeration facet defined on a simple type. Note that unlike other facets, a value cannot be validated against a single enumeration facet; for this reason all the individual enumeration facets are assembled into an EnumerationFacetSet which is a pseudo-facet used to perform the validation.

See Also:
Serialized Form

Constructor Summary
EnumerationFacet()
           
 
Method Summary
 void checkFacetRestriction(UserSimpleType type, SimpleType base, SchemaCompiler compiler)
          Check that this facet is legal when used on a type derived by restriction
 String getName()
          Get the name of this facet
 NamespaceResolver getNamespaceContext()
          Get the namespace context of the value
 Value getTypedValue(SimpleType type, Configuration config)
          Get the typed value of the enumeration value
 String getValue()
          Returns the lexical representation of this facet
 void setNamespaceContext(NamespaceResolver map)
          Save the namespace context for this enumeration value.
 void setValue(String value)
          Set the value of this facet
 boolean testAtomicValue(AtomicValue value)
          Test whether an atomic value conforms to this facet
 
Methods inherited from class com.saxonica.schema.Facet
getMessage, getWhitespaceAction, isConstraining, isFacetName, isFixed, isNewlyIntroduced, makeFacet, serializeFacet, setFixed, setMessage, testLength, testListValue, toLong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumerationFacet

public EnumerationFacet()
Method Detail

getName

public String getName()
Get the name of this facet

Specified by:
getName in class Facet
Returns:
"enumeration"

getValue

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

Specified by:
getValue in class Facet
Returns:
the value of this facet

getNamespaceContext

public NamespaceResolver getNamespaceContext()
Get the namespace context of the value

Returns:
the namespace context from the xs:enumeration element that defined the value

setValue

public void setValue(String value)
Set the value of this facet

Parameters:
value - the raw enumeration value as written in the schema

getTypedValue

public Value getTypedValue(SimpleType type,
                           Configuration config)
                    throws SchemaException,
                           UnresolvedReferenceException
Get the typed value of the enumeration value

Parameters:
type - the simple type containing this facet
Returns:
the enumeration value as written, converted to the simple type on which it appears. If the value is not valid against the type, throws a SchemaException
Throws:
SchemaException
UnresolvedReferenceException

checkFacetRestriction

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

Overrides:
checkFacetRestriction in class Facet
Parameters:
base - the type from which the restricted type is derived
compiler -
type - the type on which the facet is defined
Throws:
SchemaException - if the facet value is not legal given the base type
UnresolvedReferenceException

setNamespaceContext

public void setNamespaceContext(NamespaceResolver map)
Save the namespace context for this enumeration value. For internal use only.

Parameters:
map - a NamespaceResolver mapping namespace prefixes (as strings) onto namespace URIs (as strings)

testAtomicValue

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

Specified by:
testAtomicValue in class 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. The implementation of this method is called only while testing whether the enumeration values themselves conform to the type, so it always returns true.


Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.