Class Facet

    • Constructor Summary

      Constructors 
      Constructor Description
      Facet()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void checkFacetRestriction​(UserSimpleType type, SimpleType base, SchemaCompiler compiler)
      Check that this facet is legal when used on a type derived by restriction
      java.lang.String getConstraintName()
      Get the name of the XSD constraint associated with this facet
      abstract FunctionItem getFacetAsFunctionItem()
      Get a function item that represents this Facet schema component.
      java.lang.String getMessage()
      Get the message to be used when this facet is violated.
      abstract java.lang.String getName()
      Returns the name of this Facet
      abstract UnicodeString getValue()
      Returns the lexical representation of the value of this facet
      int getWhitespaceAction()
      Get the whitespace action required by this facet: one of PRESERVE, REPLACE, or COLLAPSE.
      boolean isConstraining()
      Ask whether this is a constraining facet (as distinct from a pre-lexical facet)
      static boolean isFacetName​(java.lang.String name, int xsdVersion)
      Test whether a given string is one of the recognized facet names
      boolean isFixed()
      Ask whether 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, EnterpriseConfiguration config, NamespaceResolver resolver)
      Factory method: creates a new Facet with the given name
      void serializeFacet​(SchemaModelSerializer serializer)
      Serialize this facet when externalizing the schema component model
      void setFixed​(boolean fixed)
      Say whether the facet is defined as fixed
      void setMessage​(java.lang.String message)
      Set the message to be used when this facet is violated.
      abstract 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​(AtomicSequence value)
      Test whether a list value conforms to this facet.
      long toLong()
      Returns the numeric value of this facet, for facets where this is appropriate
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Facet

        public Facet()
    • Method Detail

      • setFixed

        public void setFixed​(boolean fixed)
        Say whether the facet is defined as fixed
        Parameters:
        fixed - true if the facet is fixed
      • isFixed

        public boolean isFixed()
        Ask whether the facet is defined in the schema with fixed="true"
        Returns:
        true if fixed
      • isConstraining

        public boolean isConstraining()
        Ask whether this is a constraining facet (as distinct from a pre-lexical facet)
        Returns:
        true if this is a constraining facet
      • setMessage

        public void setMessage​(java.lang.String message)
        Set the message to be used when this facet is violated. If no message is supplied, a generic message is constructed, for example "the value does not match the pattern XYZ".
        Parameters:
        message - the message to be used
      • getMessage

        public java.lang.String getMessage()
        Get the message to be used when this facet is violated.
        Returns:
        the message, if one has been set, or null otherwise
      • getName

        public abstract java.lang.String getName()
        Returns the name of this Facet
        Returns:
        the name of this Facet
      • getConstraintName

        public java.lang.String getConstraintName()
        Get the name of the XSD constraint associated with this facet
        Returns:
        the XSD constraint name, for example cvc-maxExclusive-valid
      • getValue

        public abstract UnicodeString getValue()
        Returns the lexical representation of the value of this facet
        Returns:
        the value of this facet, as a string
      • toLong

        public long toLong()
                    throws java.lang.NumberFormatException
        Returns the numeric value of this facet, for facets where this is appropriate
        Returns:
        a long representation of the value of this facet
        Throws:
        java.lang.NumberFormatException - if the value is not numeric
      • 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 abstract 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​(AtomicSequence 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 when externalizing the schema component model
        Parameters:
        serializer - receives the content for serialization
        Throws:
        XPathException - if an error occurs writing the value to the output
      • isFacetName

        public static boolean isFacetName​(java.lang.String name,
                                          int xsdVersion)
        Test whether a given string is one of the recognized facet names
        Parameters:
        name - a candidate facet name, for example "totalDigits"
        xsdVersion - either XSD10 or XSD11
        Returns:
        true if the name is recognized as a facet name in the selected version of the XSD specification
      • getFacetAsFunctionItem

        public abstract FunctionItem getFacetAsFunctionItem()
        Get a function item that represents this Facet schema component.
      • makeFacet

        public static Facet makeFacet​(java.lang.String name,
                                      java.lang.String value,
                                      EnterpriseConfiguration 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 - if an error is found