Class SDOXMLHelperDelegate

  • All Implemented Interfaces:
    commonj.sdo.helper.XMLHelper, SDOXMLHelper
    Direct Known Subclasses:
    JAXBXMLHelper

    public class SDOXMLHelperDelegate
    extends java.lang.Object
    implements SDOXMLHelper

    Purpose: Helper to XML documents into DataObects and DataObjects into XML documents.

    Responsibilities:

    • Load methods create commonj.sdo.XMLDocument objects from XML (unmarshal)
    • Save methods create XML from commonj.sdo.XMLDocument and commonj.sdo.DataObject objects (marshal)
    • Field Summary

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

        INSTANCE
    • Constructor Summary

      Constructors 
      Constructor Description
      SDOXMLHelperDelegate​(commonj.sdo.helper.HelperContext aContext)  
      SDOXMLHelperDelegate​(commonj.sdo.helper.HelperContext aContext, java.lang.ClassLoader aClassLoader)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDescriptors​(java.util.List types)
      INTERNAL:
      commonj.sdo.helper.XMLDocument createDocument​(commonj.sdo.DataObject dataObject, java.lang.String rootElementURI, java.lang.String rootElementName)
      Creates an XMLDocument with the specified XML rootElement for the DataObject.
      commonj.sdo.helper.HelperContext getHelperContext()
      INTERNAL: Return the helperContext that this instance is associated with.
      SDOClassLoader getLoader()
      INTERNAL:
      Project getTopLinkProject()
      INTERNAL:
      XMLContext getXmlContext()
      INTERNAL:
      org.eclipse.persistence.internal.oxm.XMLConversionManager getXmlConversionManager()
      INTERNAL:
      XMLMarshaller getXmlMarshaller()
      INTERNAL:
      XMLUnmarshaller getXmlUnmarshaller()
      INTERNAL:
      void initializeDescriptor​(XMLDescriptor descriptor)  
      commonj.sdo.helper.XMLDocument load​(java.io.InputStream inputStream)
      Creates and returns an XMLDocument from the inputStream.
      commonj.sdo.helper.XMLDocument load​(java.io.InputStream inputStream, java.lang.String locationURI, java.lang.Object options)
      Creates and returns an XMLDocument from the inputStream.
      commonj.sdo.helper.XMLDocument load​(java.io.Reader inputReader, java.lang.String locationURI, java.lang.Object options)
      Creates and returns an XMLDocument from the inputReader.
      commonj.sdo.helper.XMLDocument load​(java.lang.String inputString)
      Creates and returns an XMLDocument from the input String.
      commonj.sdo.helper.XMLDocument load​(javax.xml.transform.Source source, java.lang.String locationURI, java.lang.Object options)  
      commonj.sdo.helper.XMLDocument load​(org.xml.sax.InputSource inputSource, java.lang.String locationURI, java.lang.Object options)
      Creates and returns an XMLDocument from the inputSource.
      void reset()
      INTERNAL:
      java.lang.String save​(commonj.sdo.DataObject dataObject, java.lang.String rootElementURI, java.lang.String rootElementName)
      Returns the DataObject saved as an XML document with the specified root element.
      void save​(commonj.sdo.DataObject dataObject, java.lang.String rootElementURI, java.lang.String rootElementName, java.io.OutputStream outputStream)
      Saves the DataObject as an XML document with the specified root element.
      void save​(commonj.sdo.helper.XMLDocument xmlDocument, java.io.OutputStream outputStream, java.lang.Object options)
      Serializes an XMLDocument as an XML document into the outputStream.
      void save​(commonj.sdo.helper.XMLDocument xmlDocument, java.io.Writer outputWriter, java.lang.Object options)
      Serializes an XMLDocument as an XML document into the outputWriter.
      void save​(commonj.sdo.helper.XMLDocument xmlDocument, javax.xml.transform.Result result, java.lang.Object options)  
      void serialize​(commonj.sdo.helper.XMLDocument xmlDocument, java.io.OutputStream outputStream, java.lang.Object options)  
      void setHelperContext​(commonj.sdo.helper.HelperContext helperContext)
      INTERNAL: Set the helperContext that this instance is associated with.
      void setLoader​(SDOClassLoader loader)
      INTERNAL:
      void setTimeZone​(java.util.TimeZone timeZone)
      The specified TimeZone will be used for all String to date object conversions.
      void setTimeZoneQualified​(boolean timeZoneQualified)
      By setting this flag to true the marshalled date objects marshalled to the XML schema types time and dateTime will be qualified by a time zone.
      void setTopLinkProject​(Project toplinkProject)
      INTERNAL:
      void setXmlContext​(XMLContext xmlContext)
      INTERNAL:
      void setXmlMarshaller​(XMLMarshaller xmlMarshaller)
      INTERNAL:
      void setXmlUnmarshaller​(XMLUnmarshaller xmlUnmarshaller)
      INTERNAL:
      • Methods inherited from class java.lang.Object

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

      • SDOXMLHelperDelegate

        public SDOXMLHelperDelegate​(commonj.sdo.helper.HelperContext aContext)
      • SDOXMLHelperDelegate

        public SDOXMLHelperDelegate​(commonj.sdo.helper.HelperContext aContext,
                                    java.lang.ClassLoader aClassLoader)
    • Method Detail

      • setTimeZone

        public void setTimeZone​(java.util.TimeZone timeZone)
        The specified TimeZone will be used for all String to date object conversions. By default the TimeZone from the JVM is used.
        Specified by:
        setTimeZone in interface SDOXMLHelper
      • setTimeZoneQualified

        public void setTimeZoneQualified​(boolean timeZoneQualified)
        By setting this flag to true the marshalled date objects marshalled to the XML schema types time and dateTime will be qualified by a time zone. By default time information is not time zone qualified.
        Specified by:
        setTimeZoneQualified in interface SDOXMLHelper
      • load

        public commonj.sdo.helper.XMLDocument load​(java.lang.String inputString)
        Creates and returns an XMLDocument from the input String. By default does not perform XSD validation. Same as load(new StringReader(inputString), null, null);
        Specified by:
        load in interface commonj.sdo.helper.XMLHelper
        Parameters:
        inputString - specifies the String to read from
        Returns:
        the new XMLDocument loaded
        Throws:
        java.lang.RuntimeException - for errors in XML parsing or implementation-specific validation.
      • load

        public commonj.sdo.helper.XMLDocument load​(java.io.InputStream inputStream)
                                            throws java.io.IOException
        Creates and returns an XMLDocument from the inputStream. The InputStream will be closed after reading. By default does not perform XSD validation. Same as load(inputStream, null, null);
        Specified by:
        load in interface commonj.sdo.helper.XMLHelper
        Parameters:
        inputStream - specifies the InputStream to read from
        Returns:
        the new XMLDocument loaded
        Throws:
        java.io.IOException - for stream exceptions.
        java.lang.RuntimeException - for errors in XML parsing or implementation-specific validation.
      • load

        public commonj.sdo.helper.XMLDocument load​(java.io.InputStream inputStream,
                                                   java.lang.String locationURI,
                                                   java.lang.Object options)
                                            throws java.io.IOException
        Creates and returns an XMLDocument from the inputStream. The InputStream will be closed after reading. By default does not perform XSD validation.
        Specified by:
        load in interface commonj.sdo.helper.XMLHelper
        Parameters:
        inputStream - specifies the InputStream to read from
        locationURI - specifies the URI of the document for relative schema locations
        options - implementation-specific options.
        Returns:
        the new XMLDocument loaded
        Throws:
        java.io.IOException - for stream exceptions.
        java.lang.RuntimeException - for errors in XML parsing or implementation-specific validation.
      • load

        public commonj.sdo.helper.XMLDocument load​(org.xml.sax.InputSource inputSource,
                                                   java.lang.String locationURI,
                                                   java.lang.Object options)
                                            throws java.io.IOException
        Creates and returns an XMLDocument from the inputSource. The InputSource will be closed after reading. By default does not perform XSD validation.
        Specified by:
        load in interface SDOXMLHelper
        Parameters:
        inputSource - specifies the InputSource to read from
        locationURI - specifies the URI of the document for relative schema locations
        options - implementation-specific options.
        Returns:
        the new XMLDocument loaded
        Throws:
        java.io.IOException - for stream exceptions.
        java.lang.RuntimeException - for errors in XML parsing or implementation-specific validation.
      • load

        public commonj.sdo.helper.XMLDocument load​(java.io.Reader inputReader,
                                                   java.lang.String locationURI,
                                                   java.lang.Object options)
                                            throws java.io.IOException
        Creates and returns an XMLDocument from the inputReader. The InputStream will be closed after reading. By default does not perform XSD validation.
        Specified by:
        load in interface commonj.sdo.helper.XMLHelper
        Parameters:
        inputReader - specifies the Reader to read from
        locationURI - specifies the URI of the document for relative schema locations
        options - implementation-specific options.
        Returns:
        the new XMLDocument loaded
        Throws:
        java.io.IOException - for stream exceptions.
        java.lang.RuntimeException - for errors in XML parsing or implementation-specific validation.
      • load

        public commonj.sdo.helper.XMLDocument load​(javax.xml.transform.Source source,
                                                   java.lang.String locationURI,
                                                   java.lang.Object options)
                                            throws java.io.IOException
        Specified by:
        load in interface commonj.sdo.helper.XMLHelper
        Throws:
        java.io.IOException
      • save

        public java.lang.String save​(commonj.sdo.DataObject dataObject,
                                     java.lang.String rootElementURI,
                                     java.lang.String rootElementName)
        Returns the DataObject saved as an XML document with the specified root element. Same as StringWriter stringWriter = new StringWriter(); save(createDocument(dataObject, rootElementURI, rootElementName), stringWriter, null); stringWriter.toString();
        Specified by:
        save in interface commonj.sdo.helper.XMLHelper
        Parameters:
        dataObject - specifies DataObject to be saved
        rootElementURI - the Target Namespace URI of the root XML element
        rootElementName - the Name of the root XML element
        Returns:
        the saved XML document as a string
        Throws:
        java.lang.IllegalArgumentException - if the dataObject tree is not closed or has no container.
      • save

        public void save​(commonj.sdo.DataObject dataObject,
                         java.lang.String rootElementURI,
                         java.lang.String rootElementName,
                         java.io.OutputStream outputStream)
                  throws XMLMarshalException,
                         java.io.IOException
        Saves the DataObject as an XML document with the specified root element. Same as save(createDocument(dataObject, rootElementURI, rootElementName), outputStream, null);
        Specified by:
        save in interface commonj.sdo.helper.XMLHelper
        Parameters:
        dataObject - specifies DataObject to be saved
        rootElementURI - the Target Namespace URI of the root XML element
        rootElementName - the Name of the root XML element
        outputStream - specifies the OutputStream to write to.
        Throws:
        java.io.IOException - for stream exceptions.
        java.lang.IllegalArgumentException - if the dataObject tree is not closed or has no container.
        XMLMarshalException
      • serialize

        public void serialize​(commonj.sdo.helper.XMLDocument xmlDocument,
                              java.io.OutputStream outputStream,
                              java.lang.Object options)
                       throws java.io.IOException
        Specified by:
        serialize in interface SDOXMLHelper
        Throws:
        java.io.IOException
      • save

        public void save​(commonj.sdo.helper.XMLDocument xmlDocument,
                         java.io.OutputStream outputStream,
                         java.lang.Object options)
                  throws java.io.IOException
        Serializes an XMLDocument as an XML document into the outputStream. If the DataObject's Type was defined by an XSD, the serialization will follow the XSD. Otherwise the serialization will follow the format as if an XSD were generated as defined by the SDO specification. The OutputStream will be flushed after writing. Does not perform validation to ensure compliance with an XSD.
        Specified by:
        save in interface commonj.sdo.helper.XMLHelper
        Parameters:
        xmlDocument - specifies XMLDocument to be saved
        outputStream - specifies the OutputStream to write to.
        options - implementation-specific options.
        Throws:
        java.io.IOException - for stream exceptions.
        java.lang.IllegalArgumentException - if the dataObject tree is not closed or has no container.
      • save

        public void save​(commonj.sdo.helper.XMLDocument xmlDocument,
                         java.io.Writer outputWriter,
                         java.lang.Object options)
                  throws java.io.IOException
        Serializes an XMLDocument as an XML document into the outputWriter. If the DataObject's Type was defined by an XSD, the serialization will follow the XSD. Otherwise the serialization will follow the format as if an XSD were generated as defined by the SDO specification. The OutputStream will be flushed after writing. Does not perform validation to ensure compliance with an XSD.
        Specified by:
        save in interface commonj.sdo.helper.XMLHelper
        Parameters:
        xmlDocument - specifies XMLDocument to be saved
        outputWriter - specifies the Writer to write to.
        options - implementation-specific options.
        Throws:
        java.io.IOException - for stream exceptions.
        java.lang.IllegalArgumentException - if the dataObject tree is not closed or has no container.
      • save

        public void save​(commonj.sdo.helper.XMLDocument xmlDocument,
                         javax.xml.transform.Result result,
                         java.lang.Object options)
                  throws java.io.IOException
        Specified by:
        save in interface commonj.sdo.helper.XMLHelper
        Throws:
        java.io.IOException
      • createDocument

        public commonj.sdo.helper.XMLDocument createDocument​(commonj.sdo.DataObject dataObject,
                                                             java.lang.String rootElementURI,
                                                             java.lang.String rootElementName)
        Creates an XMLDocument with the specified XML rootElement for the DataObject.
        Specified by:
        createDocument in interface commonj.sdo.helper.XMLHelper
        Parameters:
        dataObject - specifies DataObject to be saved
        rootElementURI - the Target Namespace URI of the root XML element
        rootElementName - the Name of the root XML element
        Returns:
        XMLDocument a new XMLDocument set with the specified parameters.
      • getHelperContext

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

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

        public org.eclipse.persistence.internal.oxm.XMLConversionManager getXmlConversionManager()
        Description copied from interface: SDOXMLHelper
        INTERNAL:
        Specified by:
        getXmlConversionManager in interface SDOXMLHelper