Package com.saxonica.ee.schema

## Class ValueConstraint

- java.lang.Object
- - com.saxonica.ee.schema.ValueConstraint

-     public class ValueConstraint
      extends java.lang.Object

  A value constraint represents the default or fixed value of an element declaration, attribute declaration, or attribute use

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `ValueConstraint.Variety` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ValueConstraint​(ValueConstraint.Variety variety, java.lang.String lexicalForm)` | Constructor; supplies the lexical form of the value as a string.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Sequence` | `asFunction()` | For use with the saxon:schema extension function, return the value constraint in the form of a function
    `java.lang.Comparable` | `getComparisonKey()` | Get a comparison key that can be used for comparing values
    `java.lang.String` | `getLexicalForm()` | Returns the lexical form of the value
    `AtomicSequence` | `getValue()` | Gets the value as a typed value.
    `ValueConstraint.Variety` | `getVariety()` | Get the variety of the constraint (fixed or default)
    `void` | `serialize​(SchemaModelSerializer serializer)` | Serialize the value constraint
    `boolean` | `testFixedValue​(Configuration config, java.lang.CharSequence value, SimpleType type, NamespaceResolver resolver)` | Test that the actual value of an element or attribute conforms to the required fixed value

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ValueConstraint

          public ValueConstraint​(ValueConstraint.Variety variety,
                                 java.lang.String lexicalForm)

      Constructor; supplies the lexical form of the value as a string. The typed value will initially be set to the lexical form as an instance of UntypedAtomic.

  - ### Method Detail

    - #### getVariety

          public ValueConstraint.Variety getVariety()

      Get the variety of the constraint (fixed or default)
      Returns:
        the variety

    - #### getLexicalForm

          public java.lang.String getLexicalForm()

      Returns the lexical form of the value
      Returns:
        the fixed or default value defined by this component. The value returned is the value after whitespace normalization is applied to the value as written in the source schema.

    - #### getValue

          public AtomicSequence getValue()

      Gets the value as a typed value.
      Returns:
        the value. This will initially be saved as an UntypedAtomicValue; later, when the type is known, it will be converted to the correct type

    - #### getComparisonKey

          public java.lang.Comparable getComparisonKey()

      Get a comparison key that can be used for comparing values
      Returns:
        a comparison key

    - #### asFunction

          public Sequence asFunction()

      For use with the saxon:schema extension function, return the value constraint in the form of a function
      Returns:
        a function whose result gives details of the value constraint

    - #### testFixedValue

          public boolean testFixedValue​(Configuration config,
                                        java.lang.CharSequence value,
                                        SimpleType type,
                                        NamespaceResolver resolver)
                                 throws ValidationException

      Test that the actual value of an element or attribute conforms to the required fixed value
      Parameters:
        `config` - the Saxon configuration
        `value` - the actual value
        `type` - the required type
        `resolver` - a namespace resolver, in case QNames are involved
      Returns:
        true if the value is OK, otherwise false
      Throws:
        `ValidationException` - if the value is not valid as an instance of the type

    - #### serialize

          public void serialize​(SchemaModelSerializer serializer)
                         throws XPathException

      Serialize the value constraint
      Throws:
        `XPathException`