Class SDOXSDHelperDelegate

  • All Implemented Interfaces:
    commonj.sdo.helper.XSDHelper, SDOXSDHelper

    public class SDOXSDHelperDelegate
    extends java.lang.Object
    implements SDOXSDHelper

    Purpose: Provides access to additional information when the Type or Property is defined by an XML Schema (XSD)..

    Responsibilities:

    • Define methods defines Types from an XSD.
    • Generate methods an XSD from Types.
    • Other Methods return null/false otherwise or if the information is unavailable.
    • Field Summary

      • Fields inherited from interface commonj.sdo.helper.XSDHelper

        INSTANCE
    • Constructor Summary

      Constructors 
      Constructor Description
      SDOXSDHelperDelegate​(commonj.sdo.helper.HelperContext aContext)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addGlobalProperty​(javax.xml.namespace.QName qname, commonj.sdo.Property prop, boolean isElement)
      INTERNAL:
      java.util.Map buildAppInfoMap​(java.util.List appInfoElements)
      INTERNAL:
      java.util.List define​(java.io.InputStream xsdInputStream, java.lang.String schemaLocation)
      Define XML Schema as Types.
      java.util.List define​(java.io.Reader xsdReader, java.lang.String schemaLocation)
      Define XML Schema as Types.
      java.util.List define​(java.io.Reader xsdReader, SchemaResolver schemaResolver)
      Define XML Schema as Types.
      java.util.List define​(java.lang.String xsd)
      Define the XML Schema as Types.
      java.util.List define​(javax.xml.transform.Source xsdSource, SchemaResolver schemaResolver)
      INTERNAL:
      java.lang.String generate​(java.util.List types)
      Generate an XML Schema Declaration (XSD) from Types.
      java.lang.String generate​(java.util.List types, java.util.Map namespaceToSchemaLocation)
      Generate an XML Schema Declaration (XSD) from Types.
      java.lang.String generate​(java.util.List types, SchemaLocationResolver schemaLocationResolver)
      INTERNAL:
      java.lang.String getAppinfo​(commonj.sdo.Property property, java.lang.String source)
      Return the content of the appinfo declared for this Property and source.
      java.lang.String getAppinfo​(commonj.sdo.Type type, java.lang.String source)
      Return the appinfo declared for this Type and source.
      commonj.sdo.Property getGlobalProperty​(java.lang.String uri, java.lang.String propertyName, boolean isElement)
      Returns the Property defined by the named global element or attribute in the targetNamespace uri, or null if not found.
      commonj.sdo.Property getGlobalProperty​(javax.xml.namespace.QName qname, boolean isElement)
      INTERNAL:
      commonj.sdo.helper.HelperContext getHelperContext()
      INTERNAL: Return the helperContext that this instance is associated with.
      java.lang.String getLocalName​(commonj.sdo.Property property)
      Returns the local name as declared in the XSD.
      java.lang.String getLocalName​(commonj.sdo.Type type)
      Returns the local name as declared in the XSD.
      java.lang.String getNamespaceURI​(commonj.sdo.Property property)
      Returns the namespace URI as declared in the XSD.
      java.lang.String getNamespaceURI​(commonj.sdo.Type type)
      Returns the namespace URI as declared in the XSD.
      java.lang.String getStringFromAppInfoElement​(org.w3c.dom.Element appInfo)  
      boolean isAttribute​(commonj.sdo.Property property)
      Returns true if the property is declared as an attribute in the XSD.
      boolean isElement​(commonj.sdo.Property property)
      Returns true if the property is declared as an element in the XSD.
      boolean isMixed​(commonj.sdo.Type type)
      Returns true if the Type is declared to contain mixed content.
      boolean isXSD​(commonj.sdo.Type type)
      Indicates if this helper contains XSD information for the specified type.
      void reset()
      INTERNAL:
      void setGlobalAttributes​(java.util.Map globalAttributes)
      Assign a map of properties representing global attributes keyed on QName
      void setGlobalElements​(java.util.Map globalElements)
      Assign a map of properties representing global elements keyed on QName
      void setHelperContext​(commonj.sdo.helper.HelperContext helperContext)
      INTERNAL: Set the helperContext that this instance is associated with.
      • Methods inherited from class java.lang.Object

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

      • SDOXSDHelperDelegate

        public SDOXSDHelperDelegate​(commonj.sdo.helper.HelperContext aContext)
    • Method Detail

      • getLocalName

        public java.lang.String getLocalName​(commonj.sdo.Type type)
        Returns the local name as declared in the XSD.
        Specified by:
        getLocalName in interface commonj.sdo.helper.XSDHelper
        Parameters:
        type - to return local name for.
        Returns:
        the local name as declared in the XSD.
      • getLocalName

        public java.lang.String getLocalName​(commonj.sdo.Property property)
        Returns the local name as declared in the XSD.
        Specified by:
        getLocalName in interface commonj.sdo.helper.XSDHelper
        Parameters:
        property - to return local name for.
        Returns:
        the local name as declared in the XSD.
      • getNamespaceURI

        public java.lang.String getNamespaceURI​(commonj.sdo.Type type)
        Returns the namespace URI as declared in the XSD.
        Parameters:
        type - to return namespace URI for.
        Returns:
        the namespace URI as declared in the XSD.
      • getNamespaceURI

        public java.lang.String getNamespaceURI​(commonj.sdo.Property property)
        Returns the namespace URI as declared in the XSD.
        Specified by:
        getNamespaceURI in interface commonj.sdo.helper.XSDHelper
        Parameters:
        property - to return namespace URI for.
        Returns:
        the namespace URI as declared in the XSD.
      • isAttribute

        public boolean isAttribute​(commonj.sdo.Property property)
        Returns true if the property is declared as an attribute in the XSD. Returns false if not known or for advanced cases. It is possible for both isAttribute and isElement to return false but they will not both return true.
        Specified by:
        isAttribute in interface commonj.sdo.helper.XSDHelper
        Parameters:
        property - to identify if an attribute.
        Returns:
        true if the property is declared as an attribute in the XSD.
      • isElement

        public boolean isElement​(commonj.sdo.Property property)
        Returns true if the property is declared as an element in the XSD. Returns false if not known or for advanced cases. It is possible for both isAttribute and isElement to return false but they will not both return true.
        Specified by:
        isElement in interface commonj.sdo.helper.XSDHelper
        Parameters:
        property - to identify if an element.
        Returns:
        true if the property is declared as an element in the XSD.
      • isMixed

        public boolean isMixed​(commonj.sdo.Type type)
        Returns true if the Type is declared to contain mixed content. A DataObject's mixed content values are typically accessed via a Sequence.
        Specified by:
        isMixed in interface commonj.sdo.helper.XSDHelper
        Parameters:
        type - to identify if mixed content.
        Returns:
        true if the Type is declared to contain mixed content.
      • isXSD

        public boolean isXSD​(commonj.sdo.Type type)
        Indicates if this helper contains XSD information for the specified type.
        Specified by:
        isXSD in interface commonj.sdo.helper.XSDHelper
        Parameters:
        type - the type.
        Returns:
        true if this helper contains XSD information for the specified type.
      • getGlobalProperty

        public commonj.sdo.Property getGlobalProperty​(java.lang.String uri,
                                                      java.lang.String propertyName,
                                                      boolean isElement)
        Returns the Property defined by the named global element or attribute in the targetNamespace uri, or null if not found.
        Specified by:
        getGlobalProperty in interface commonj.sdo.helper.XSDHelper
        Parameters:
        uri - The uri of the targetNamespace.
        propertyName - The name of the global property.
        isElement - is true for global elements, false for global attributes.
        Returns:
        the Property defined by the named global element or attribute in the targetNamespace uri, or null if not found.
      • getGlobalProperty

        public commonj.sdo.Property getGlobalProperty​(javax.xml.namespace.QName qname,
                                                      boolean isElement)
        Description copied from interface: SDOXSDHelper
        INTERNAL:
        Specified by:
        getGlobalProperty in interface SDOXSDHelper
        Returns:
      • getAppinfo

        public java.lang.String getAppinfo​(commonj.sdo.Type type,
                                           java.lang.String source)
        Return the appinfo declared for this Type and source. The appinfo start and end tags and content are returned. The xml namespace context is preserved in the appinfo element. If more than one appinfo with the same source is declared on the same Type their contents are concatenated.
        Specified by:
        getAppinfo in interface commonj.sdo.helper.XSDHelper
        Parameters:
        type - the type with the appinfo declaration
        source - the source of the appinfo declaration.
        Returns:
        the appinfo declared for this Type and source.
      • getAppinfo

        public java.lang.String getAppinfo​(commonj.sdo.Property property,
                                           java.lang.String source)
        Return the content of the appinfo declared for this Property and source. If the property is defined by ref= the appinfo of the referenced element or attribute is included. The appinfo start and end tags and content are returned. The xml namespace context is preserved in the appinfo element. If more than one appinfo with the same source is declared on the same Type their contents are concatenated.
        Specified by:
        getAppinfo in interface commonj.sdo.helper.XSDHelper
        Parameters:
        property - the Property with the appinfo declaration
        source - the source of the appinfo declaration.
        Returns:
        the appinfo declared for this Property and source.
      • define

        public java.util.List define​(java.lang.String xsd)
        Define the XML Schema as Types. The Types are available through TypeHelper and DataGraph getType() methods. Same as define(new StringReader(xsd), null)
        Specified by:
        define in interface commonj.sdo.helper.XSDHelper
        Parameters:
        xsd - the XML Schema.
        Returns:
        the defined Types.
        Throws:
        java.lang.IllegalArgumentException - if the Types could not be defined.
      • define

        public java.util.List define​(java.io.Reader xsdReader,
                                     java.lang.String schemaLocation)
        Define XML Schema as Types. The Types are available through TypeHelper and DataGraph getType() methods.
        Specified by:
        define in interface commonj.sdo.helper.XSDHelper
        Parameters:
        xsdReader - reader to an XML Schema.
        schemaLocation - the URI of the location of the schema, used for processing relative imports and includes. May be null if not used.
        Returns:
        the defined Types.
        Throws:
        java.lang.IllegalArgumentException - if the Types could not be defined.
      • define

        public java.util.List define​(java.io.Reader xsdReader,
                                     SchemaResolver schemaResolver)
        Define XML Schema as Types. The Types are available through TypeHelper and DataGraph getType() methods.
        Parameters:
        xsdReader - reader to an XML Schema.
        schemaResolver - the URI of the location of the schema, used for processing relative imports and includes. May be null if not used.
        Returns:
        the defined Types.
        Throws:
        java.lang.IllegalArgumentException - if the Types could not be defined.
      • define

        public java.util.List define​(javax.xml.transform.Source xsdSource,
                                     SchemaResolver schemaResolver)
        Description copied from interface: SDOXSDHelper
        INTERNAL:
        Specified by:
        define in interface SDOXSDHelper
        Returns:
      • define

        public java.util.List define​(java.io.InputStream xsdInputStream,
                                     java.lang.String schemaLocation)
        Define XML Schema as Types. The Types are available through TypeHelper and DataGraph getType() methods.
        Specified by:
        define in interface commonj.sdo.helper.XSDHelper
        Parameters:
        xsdInputStream - input stream to an XML Schema.
        schemaLocation - the URI of the location of the schema, used for processing relative imports and includes. May be null if not used.
        Returns:
        the defined Types.
        Throws:
        java.lang.IllegalArgumentException - if the Types could not be defined.
      • generate

        public java.lang.String generate​(java.util.List types)
        Generate an XML Schema Declaration (XSD) from Types. Same as generate(types, null);
        Specified by:
        generate in interface commonj.sdo.helper.XSDHelper
        Parameters:
        types - a List containing the Types
        Returns:
        a String containing the generated XSD.
        Throws:
        java.lang.IllegalArgumentException - if the XSD could not be generated.
      • generate

        public java.lang.String generate​(java.util.List types,
                                         java.util.Map namespaceToSchemaLocation)
        Generate an XML Schema Declaration (XSD) from Types. Round trip from SDO to XSD to SDO is supported. Round trip from XSD to SDO to XSD is not supported. Use the original schema if one exists instead of generating a new one, as the generated XSD validates a different set of documents than the original XSD. Generating an XSD does not affect the XSDHelper or the Types. The Types must all have the same URI. The result is a String containing the generated XSD. All Types referenced with the same URI will be generated in the XSD and the list will be expanded to include all types generated. Any Types referenced with other URIs will cause imports to be produced as appropriate. Imports will include a schemaLocation if a Map is provided with an entry of the form key=import target namespace, value=schemaLocation
        Specified by:
        generate in interface commonj.sdo.helper.XSDHelper
        Parameters:
        types - a List containing the Types
        namespaceToSchemaLocation - map of target namespace to schema locations or null
        Returns:
        a String containing the generated XSD.
        Throws:
        java.lang.IllegalArgumentException - if the XSD could not be generated.
      • setGlobalAttributes

        public void setGlobalAttributes​(java.util.Map globalAttributes)
        Assign a map of properties representing global attributes keyed on QName
        Parameters:
        globalAttributes - a Map of global elements keyed on QName
      • setGlobalElements

        public void setGlobalElements​(java.util.Map globalElements)
        Assign a map of properties representing global elements keyed on QName
        Parameters:
        globalElements - a Map of global elements keyed on QName
      • buildAppInfoMap

        public java.util.Map buildAppInfoMap​(java.util.List appInfoElements)
        INTERNAL:
        Specified by:
        buildAppInfoMap in interface SDOXSDHelper
        Returns:
      • getHelperContext

        public commonj.sdo.helper.HelperContext getHelperContext()
        Description copied from interface: SDOXSDHelper
        INTERNAL: Return the helperContext that this instance is associated with.
        Specified by:
        getHelperContext in interface SDOXSDHelper
        Returns:
      • setHelperContext

        public void setHelperContext​(commonj.sdo.helper.HelperContext helperContext)
        Description copied from interface: SDOXSDHelper
        INTERNAL: Set the helperContext that this instance is associated with.
        Specified by:
        setHelperContext in interface SDOXSDHelper
      • getStringFromAppInfoElement

        public java.lang.String getStringFromAppInfoElement​(org.w3c.dom.Element appInfo)
      • addGlobalProperty

        public void addGlobalProperty​(javax.xml.namespace.QName qname,
                                      commonj.sdo.Property prop,
                                      boolean isElement)
        INTERNAL:
        Specified by:
        addGlobalProperty in interface SDOXSDHelper
        Parameters:
        qname -
        prop -
        isElement - Register the given property with the given qname.