Class DatatypeFactory


  • public class DatatypeFactory
    extends java.lang.Object
    Datatype object factory.

    Applications should use this class to get and derive DataType objects. All methods are static.

    Derivation by restriction should be done by using TypeIncubator.

    • Field Detail

      • builtinType

        private static final java.util.Map builtinType
        a map that contains built in types. To speed up the boot process, only a handful types are added at the first time.
    • Constructor Detail

      • DatatypeFactory

        private DatatypeFactory()
    • Method Detail

      • deriveByList

        public static XSDatatype deriveByList​(java.lang.String nsUri,
                                              java.lang.String newTypeName,
                                              XSDatatype itemType)
                                       throws org.relaxng.datatype.DatatypeException
        derives a new type by list. See http://www.w3.org/TR/xmlschema-2#derivation-by-list for what "derivation by list" means.
        Parameters:
        nsUri - ,newTypeName (URI,local) pair as the name of the new type. it can be set to null for an anonymous type.
        itemType - Type of the list item. It must be an atom type which is implemented in this package or derived from types implemented in this package. You cannot use your own DataType implementation here.
        Returns:
        always return non-null value. If error occurs, then an exception will be thrown.
        Throws:
        org.relaxng.datatype.DatatypeException - this exception is thrown when the derivation is illegal. For example, when you try to derive a type from non-atom type.
      • deriveByList

        public static XSDatatype deriveByList​(java.lang.String newTypeName,
                                              XSDatatype itemType)
                                       throws org.relaxng.datatype.DatatypeException
        Deprecated.
        Throws:
        org.relaxng.datatype.DatatypeException
      • deriveByUnion

        public static XSDatatype deriveByUnion​(java.lang.String nsUri,
                                               java.lang.String newTypeName,
                                               XSDatatype[] memberTypes)
                                        throws org.relaxng.datatype.DatatypeException
        derives a new type by union. See http://www.w3.org/TR/xmlschema-2#derivation-by-union for what "derivation by union" means.
        Parameters:
        newTypeName - name of the new type. it can be set to null to indicate an anonymous type.
        memberTypes - Types of the union member. It can be any type that implements DataType.
        Throws:
        org.relaxng.datatype.DatatypeException - this exception is thrown when the derivation is illegal.
      • deriveByUnion

        public static XSDatatype deriveByUnion​(java.lang.String newTypeName,
                                               XSDatatype[] memberTypes)
                                        throws org.relaxng.datatype.DatatypeException
        Deprecated.
        Throws:
        org.relaxng.datatype.DatatypeException
      • deriveByUnion

        public static XSDatatype deriveByUnion​(java.lang.String newTypeName,
                                               java.util.Collection memberTypes)
                                        throws org.relaxng.datatype.DatatypeException
        Deprecated.
        Throws:
        org.relaxng.datatype.DatatypeException
      • deriveByUnion

        public static XSDatatype deriveByUnion​(java.lang.String nsUri,
                                               java.lang.String newTypeName,
                                               java.util.Collection memberTypes)
                                        throws org.relaxng.datatype.DatatypeException
        Throws:
        org.relaxng.datatype.DatatypeException
      • add

        private static void add​(java.util.Map m,
                                XSDatatypeImpl type)
      • getTypeByName

        public static XSDatatype getTypeByName​(java.lang.String dataTypeName)
                                        throws org.relaxng.datatype.DatatypeException
        obtain a built-in DataType object by its name. For example, you can pass somethings like "token", "gYear", etc.
        Returns:
        A non-null valid datatype object.
        Throws:
        org.relaxng.datatype.DatatypeException - If the type name is undefined.
      • createBuiltinList

        private static XSDatatypeImpl createBuiltinList​(java.lang.String name,
                                                        XSDatatypeImpl item)
                                                 throws org.relaxng.datatype.DatatypeException
        Throws:
        org.relaxng.datatype.DatatypeException
      • createInitialBuiltinTypesMap

        private static java.util.Map createInitialBuiltinTypesMap()
        creates a map that contains frequently-used built-in types