Class Conversions


  • public final class Conversions
    extends java.lang.Object
    Utilities for conversion of schema standard datatypes.
    Author:
    Dennis M. Sosnoski
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Conversions()
      Non-constructor for class with no instances.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String checkCollapse​(java.lang.String text)
      Check collapsed whitespace value.
      static java.lang.String checkName​(java.lang.String text, java.lang.String tname, ValidationContext vctx, java.lang.Object obj)
      Validate Name value.
      static java.lang.String checkNCName​(java.lang.String text, java.lang.String tname, ValidationContext vctx, java.lang.Object obj)
      Check NCName value.
      static java.lang.String checkNMTOKEN​(java.lang.String text, java.lang.String tname, ValidationContext vctx, java.lang.Object obj)
      Check NMTOKEN value.
      static java.lang.String checkNormalizedString​(java.lang.String text, java.lang.String tname, ValidationContext vctx, java.lang.Object obj)
      Validate normalized string value.
      static java.lang.String checkToken​(java.lang.String text, java.lang.String tname, ValidationContext vctx, java.lang.Object obj)
      Validate token value.
      static java.lang.String convertAnyUri​(java.lang.String text, ValidationContext vctx)
      Validate and convert anyURI value.
      private static java.lang.String convertCollapsed​(java.lang.String text, int index)
      Convert collapsed string value.
      static int convertEnumeration​(java.lang.String text, EnumSet eset, java.lang.String name, IUnmarshallingContext ictx)
      Validate and convert enumeration attribute value.
      static java.lang.String convertName​(java.lang.String text, int index, java.lang.String tname, ValidationContext vctx, java.lang.Object obj)
      Convert Name value with validation.
      private static java.lang.String convertNCName​(java.lang.String text, int index, java.lang.String tname, ValidationContext vctx, java.lang.Object obj)
      Convert NCName value with validation.
      private static java.lang.String convertNMTOKEN​(java.lang.String text, int index, java.lang.String tname, ValidationContext vctx, java.lang.Object obj)
      Convert NMTOKEN value with validation.
      private static java.lang.String convertNormalizedString​(java.lang.String text, int index, java.lang.String tname, ValidationContext vctx, java.lang.Object obj)
      Convert normalized string value with validation.
      private static java.lang.String convertToken​(java.lang.String text, int index, java.lang.String tname, ValidationContext vctx, java.lang.Object obj)
      Convert token-type value with validation.
      static java.lang.String deserializeName​(java.lang.String text, ValidationContext vctx, java.lang.Object obj)
      Deserialize Name value.
      static java.lang.String deserializeNCName​(java.lang.String text, ValidationContext vctx, java.lang.Object obj)
      Deserialize NCName value.
      static java.lang.String deserializeNMTOKEN​(java.lang.String text, ValidationContext vctx, java.lang.Object obj)
      Deserialize NMTOKEN value.
      static java.lang.String deserializeNormalizedString​(java.lang.String text, ValidationContext vctx, java.lang.Object obj)
      Deserialize normalized string value.
      static java.lang.String deserializeToken​(java.lang.String text, ValidationContext vctx, java.lang.Object obj)
      Deserialize token value.
      • Methods inherited from class java.lang.Object

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

      • NAMEINIT_CHARACTER_TYPES

        public static final int NAMEINIT_CHARACTER_TYPES
        Character types allowed as initial characters of a name.
        See Also:
        Constant Field Values
      • NAMEFOLLOW_CHARACTER_TYPES

        public static final int NAMEFOLLOW_CHARACTER_TYPES
        Character types allowed as non-initial characters of a name.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Conversions

        private Conversions()
        Non-constructor for class with no instances.
    • Method Detail

      • convertNormalizedString

        private static java.lang.String convertNormalizedString​(java.lang.String text,
                                                                int index,
                                                                java.lang.String tname,
                                                                ValidationContext vctx,
                                                                java.lang.Object obj)
        Convert normalized string value with validation. This handles the actual conversion of a normalized string value. The first character to be dropped must have been found prior to this call.
        Parameters:
        text - value to be converted
        index - first character offset to be dropped from result
        tname - type name
        vctx - validation context
        obj - object being validated
        Returns:
        normalized string value (null if nonrecoverable error)
      • checkNormalizedString

        public static java.lang.String checkNormalizedString​(java.lang.String text,
                                                             java.lang.String tname,
                                                             ValidationContext vctx,
                                                             java.lang.Object obj)
        Validate normalized string value. This checks the text and, if necessary, converts it to valid form.
        Parameters:
        text - value to be converted
        tname - type name
        vctx - validation context
        obj - object being validated
        Returns:
        normalized string value (null if nonrecoverable error)
      • deserializeNormalizedString

        public static java.lang.String deserializeNormalizedString​(java.lang.String text,
                                                                   ValidationContext vctx,
                                                                   java.lang.Object obj)
        Deserialize normalized string value. This validates the text and, if necessary, converts it to standard form.
        Parameters:
        text - value to be converted (may be null)
        vctx - validation context
        obj - object being validated
        Returns:
        normalized string value (null if input null, or nonrecoverable error)
      • convertToken

        private static java.lang.String convertToken​(java.lang.String text,
                                                     int index,
                                                     java.lang.String tname,
                                                     ValidationContext vctx,
                                                     java.lang.Object obj)
        Convert token-type value with validation. This handles the actual conversion of a value with no leading or trailing spaces, no non-space whitespaces, . The first character to be dropped must have been found prior to this call.
        Parameters:
        text - value to be converted
        index - first character offset to be dropped from result
        tname - type name
        vctx - validation context
        obj - object being validated
        Returns:
        token value (null if nonrecoverable error)
      • checkToken

        public static java.lang.String checkToken​(java.lang.String text,
                                                  java.lang.String tname,
                                                  ValidationContext vctx,
                                                  java.lang.Object obj)
        Validate token value. This validates the text and, if necessary, converts it to standard form.
        Parameters:
        text - value to be converted (may be null)
        tname - type name
        vctx - validation context
        obj - object being validated
        Returns:
        token value (null if nonrecoverable error)
      • deserializeToken

        public static java.lang.String deserializeToken​(java.lang.String text,
                                                        ValidationContext vctx,
                                                        java.lang.Object obj)
        Deserialize token value. This validates the text and, if necessary, converts it to standard form.
        Parameters:
        text - value to be converted (may be null)
        vctx - validation context
        obj - object being validated
        Returns:
        token value (null if input null, or nonrecoverable error)
      • convertCollapsed

        private static java.lang.String convertCollapsed​(java.lang.String text,
                                                         int index)
        Convert collapsed string value. The first character to be collapsed must must have been found prior to this call.
        Parameters:
        text - value to be converted
        index - first character offset to be dropped from result
        Returns:
        normalized string value
      • convertName

        public static java.lang.String convertName​(java.lang.String text,
                                                   int index,
                                                   java.lang.String tname,
                                                   ValidationContext vctx,
                                                   java.lang.Object obj)
        Convert Name value with validation. This handles the actual conversion of a Name value by dropping illegal characters. It should only be called when error recovery is enabled. The first character to be dropped must have been found prior to this call.
        Parameters:
        text - value to be converted
        index - first character offset to be dropped from result
        tname - type name
        vctx - validation context
        obj - object being validated
        Returns:
        Name value (null if nonrecoverable error)
      • checkName

        public static java.lang.String checkName​(java.lang.String text,
                                                 java.lang.String tname,
                                                 ValidationContext vctx,
                                                 java.lang.Object obj)
        Validate Name value. This validates the text and, if necessary, converts it to valid form by dropping illegal characters (only if error recovery is enabled).
        Parameters:
        text - value to be converted (may be null)
        tname - type name
        vctx - validation context
        obj - object being validated
        Returns:
        Name value (null if nonrecoverable error)
      • deserializeName

        public static java.lang.String deserializeName​(java.lang.String text,
                                                       ValidationContext vctx,
                                                       java.lang.Object obj)
        Deserialize Name value. This validates the text and, if necessary, converts it to valid form by dropping illegal characters (only if error recovery is enabled).
        Parameters:
        text - value to be converted (may be null)
        vctx - validation context
        obj - object being validated
        Returns:
        Name value (null if input null, or nonrecoverable error)
      • convertNCName

        private static java.lang.String convertNCName​(java.lang.String text,
                                                      int index,
                                                      java.lang.String tname,
                                                      ValidationContext vctx,
                                                      java.lang.Object obj)
        Convert NCName value with validation. This handles the actual conversion of an NCName value by dropping illegal characters. It should only be called when error recovery is enabled. The first character to be dropped must have been found prior to this call.
        Parameters:
        text - value to be converted
        index - first character offset to be dropped from result
        tname - type name
        vctx - validation context
        obj - object being validated
        Returns:
        NCName value
      • checkNCName

        public static java.lang.String checkNCName​(java.lang.String text,
                                                   java.lang.String tname,
                                                   ValidationContext vctx,
                                                   java.lang.Object obj)
        Check NCName value. This validates the text and, if necessary, converts it to valid form by dropping illegal characters (only if error recovery is enabled).
        Parameters:
        text - value to be converted (may be null)
        tname - type name
        vctx - validation context
        obj - object being validated
        Returns:
        NCName value (null if nonrecoverable error)
      • deserializeNCName

        public static java.lang.String deserializeNCName​(java.lang.String text,
                                                         ValidationContext vctx,
                                                         java.lang.Object obj)
        Deserialize NCName value. This validates the text and, if necessary, converts it to valid form by dropping illegal characters (only if error recovery is enabled).
        Parameters:
        text - value to be converted (may be null)
        vctx - validation context
        obj - object being validated
        Returns:
        NCName value (null if input null, or nonrecoverable error)
      • convertNMTOKEN

        private static java.lang.String convertNMTOKEN​(java.lang.String text,
                                                       int index,
                                                       java.lang.String tname,
                                                       ValidationContext vctx,
                                                       java.lang.Object obj)
        Convert NMTOKEN value with validation. This handles the actual conversion of an NMTOKEN value by dropping illegal characters. It should only be called when error recovery is enabled. The first character to be dropped must have been found prior to this call.
        Parameters:
        text - value to be converted
        index - first character offset to be dropped from result
        tname - type name
        vctx - validation context
        obj - object being validated
        Returns:
        NMTOKEN value
      • checkNMTOKEN

        public static java.lang.String checkNMTOKEN​(java.lang.String text,
                                                    java.lang.String tname,
                                                    ValidationContext vctx,
                                                    java.lang.Object obj)
        Check NMTOKEN value. This validates the text and, if necessary, converts it to valid form by dropping illegal characters (only if error recovery is enabled).
        Parameters:
        text - value to be converted (may be null)
        tname - type name
        vctx - validation context
        obj - object being validated
        Returns:
        NMTOKEN value (null if nonrecoverable error)
      • deserializeNMTOKEN

        public static java.lang.String deserializeNMTOKEN​(java.lang.String text,
                                                          ValidationContext vctx,
                                                          java.lang.Object obj)
        Deserialize NMTOKEN value. This validates the text and, if necessary, converts it to valid form by dropping illegal characters (only if error recovery is enabled).
        Parameters:
        text - value to be converted (may be null)
        vctx - validation context
        obj - object being validated
        Returns:
        NMTOKEN value (null if input null, or nonrecoverable error)
      • checkCollapse

        public static java.lang.String checkCollapse​(java.lang.String text)
        Check collapsed whitespace value. This checks the text and, if necessary, converts it to standard form.
        Parameters:
        text - value to be converted (may be null)
        Returns:
        collapsed value
      • convertAnyUri

        public static java.lang.String convertAnyUri​(java.lang.String text,
                                                     ValidationContext vctx)
        Validate and convert anyURI value.
        Parameters:
        text - value to be converted (may be null)
        vctx - validation context
        Returns:
        normalized string value (null if input null, or error)
      • convertEnumeration

        public static int convertEnumeration​(java.lang.String text,
                                             EnumSet eset,
                                             java.lang.String name,
                                             IUnmarshallingContext ictx)
        Validate and convert enumeration attribute value.
        Parameters:
        text - value to be converted (may be null)
        eset - enumeration set
        name - attribute name
        ictx - unmarshalling context
        Returns:
        converted value