## com.saxonica.schema
Class Facet

    java.lang.Object
      com.saxonica.schema.Facet

All Implemented Interfaces:
  java.io.Serializable

Direct Known Subclasses:
  AssertionFacet, DigitsFacet, EnumerationFacet, EnumerationFacetSet, LengthFacet, PatternFacet, ValueRangeFacet, WhitespaceFacet

    public abstract class Facet

extends java.lang.Object
implements java.io.Serializable

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 java.lang.String` `ASSERT`
`static java.lang.String` `ENUMERATION`
`static java.lang.String` `FRACTIONDIGITS`
`static java.lang.String` `LENGTH`
`static java.lang.String` `MAX_EXCLUSIVE`
`static java.lang.String` `MAX_INCLUSIVE`
`static java.lang.String` `MAX_LENGTH`
`static java.lang.String` `MIN_EXCLUSIVE`
`static java.lang.String` `MIN_INCLUSIVE`
`static java.lang.String` `MIN_LENGTH`
`static java.lang.String` `PATTERN`
`static java.lang.String` `TOTALDIGITS`
`static java.lang.String` `WHITESPACE`

Constructor Summary
`Facet()`

Method Summary
`void` `checkFacetRestriction(UserSimpleType type, SimpleType base)` Check that this facet is legal when used on a type derived by restriction
`abstract java.lang.String` `getName()` Returns the name of this Facet
`abstract java.lang.String` `getValue()` Returns the lexical representation of this facet
`int` `getWhitespaceAction()` Get the whitespace action required by this facet: one of PRESERVE, REPLACE, or COLLAPSE.
`static boolean` `isFacetName(java.lang.String name)` Test whether a given string is one of the recognized facet names
`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
`static Facet` `makeFacet(java.lang.String name, java.lang.String value, SchemaAwareConfiguration config, NamespaceResolver resolver)` Factory method: creates a new Facet with the given name
`void` `serializeFacet(SchemaModelSerializer serializer)` Serialize this facet
`void` `setFixed(boolean fixed)` Set whether the facet is defined as fixed
`abstract void` `setValue(java.lang.String value)` Set the string value of the facet
`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.
`boolean` `testListValue(Value value)` Test whether a list value conforms to this facet.
`long` `toLong()` Returns the numeric value of this facet

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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

### 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

### ASSERT

    public static final java.lang.String ASSERT

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

### setValue

    public abstract void setValue(java.lang.String value)
                           throws SchemaException

  Set the string value of the facet

  Parameters:
    `value` - the string value of the facet
  Throws:
    `java.lang.UnsupportedOperationException` - for facets that have no lexica value, specifically the facet containing the collected enumeration values
    `SchemaException` - if the value is not valid for this facet on this type

### setFixed

    public void setFixed(boolean fixed)

  Set whether the facet is defined as fixed

  Parameters:
    `fixed` - true if the facet is fixed

### getName

    public abstract java.lang.String getName()

  Returns the name of this Facet

  Returns:
    the name of this Facet

### getValue

    public abstract java.lang.String getValue()

  Returns the lexical representation of this facet

  Returns:
    the value of this facet

### toLong

    public long toLong()
                throws java.lang.NumberFormatException

  Returns the numeric value of this facet

  Returns:
    a long representation of the value of this facet
  Throws:
    `java.lang.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

  Parameters:
    `base` - the base type
  Returns:
    true if the facet is present on this type and not on the base type

### 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

### testListValue

    public boolean testListValue(Value value)

  Test whether a list value conforms to this facet. This is used only for the enumeration and assertion facets.

  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

  Parameters:
    `count` - the actual length of the list
  Returns:
    true if the facet allows a list of this length, otherwise false

### 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.

  Returns:
    the whitespace action, by default PRESERVE

### serializeFacet

    public void serializeFacet(SchemaModelSerializer serializer)
                        throws XPathException

  Serialize this facet

  Parameters:
    `serializer` - receives the content for serialization
  Throws:
    `XPathException`

### isFacetName

    public static boolean isFacetName(java.lang.String name)

  Test whether a given string is one of the recognized facet names

  Parameters:
    `name` - a candidate facet name, for example "totalDigits"
  Returns:
    true if the name is recognized as a facet name

### makeFacet

    public static Facet makeFacet(java.lang.String name,
                                  java.lang.String value,
                                  SchemaAwareConfiguration config,
                                  NamespaceResolver resolver)
                           throws SchemaException

  Factory method: creates a new Facet with the given name

  Parameters:
    `name` - the name of the Facet
    `value` - the value of the Facet
    `config` - the Saxon configuration
    `resolver` - a namespace resolver used for resolving prefixes in namespace-sensitive enumeration values
  Returns:
    the constructed facet
  Throws:
    `SchemaException`

Copyright (c) Saxonica Limited. All rights reserved.