Class SDOXMLHelperDelegate

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

    public class SDOXMLHelperDelegate
    extends 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)
    • Constructor Detail

      • SDOXMLHelperDelegate

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

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

      • setTimeZone

        public void setTimeZone​(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​(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:
        RuntimeException - for errors in XML parsing or implementation-specific validation.
      • load

        public commonj.sdo.helper.XMLDocument load​(InputStream inputStream)
                                            throws 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:
        IOException - for stream exceptions.
        RuntimeException - for errors in XML parsing or implementation-specific validation.
      • load

        public commonj.sdo.helper.XMLDocument load​(InputStream inputStream,
                                                   String locationURI,
                                                   Object options)
                                            throws 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:
        IOException - for stream exceptions.
        RuntimeException - for errors in XML parsing or implementation-specific validation.
      • load

        public commonj.sdo.helper.XMLDocument load​(InputSource inputSource,
                                                   String locationURI,
                                                   Object options)
                                            throws 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:
        IOException - for stream exceptions.
        RuntimeException - for errors in XML parsing or implementation-specific validation.
      • load

        public commonj.sdo.helper.XMLDocument load​(Reader inputReader,
                                                   String locationURI,
                                                   Object options)
                                            throws 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:
        IOException - for stream exceptions.
        RuntimeException - for errors in XML parsing or implementation-specific validation.
      • load

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

        public String save​(commonj.sdo.DataObject dataObject,
                           String rootElementURI,
                           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:
        IllegalArgumentException - if the dataObject tree is not closed or has no container.
      • save

        public void save​(commonj.sdo.DataObject dataObject,
                         String rootElementURI,
                         String rootElementName,
                         OutputStream outputStream)
                  throws XMLMarshalException,
                         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:
        IOException - for stream exceptions.
        IllegalArgumentException - if the dataObject tree is not closed or has no container.
        XMLMarshalException
      • save

        public void save​(commonj.sdo.helper.XMLDocument xmlDocument,
                         OutputStream outputStream,
                         Object options)
                  throws 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:
        IOException - for stream exceptions.
        IllegalArgumentException - if the dataObject tree is not closed or has no container.
      • save

        public void save​(commonj.sdo.helper.XMLDocument xmlDocument,
                         Writer outputWriter,
                         Object options)
                  throws 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:
        IOException - for stream exceptions.
        IllegalArgumentException - if the dataObject tree is not closed or has no container.
      • save

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

        public commonj.sdo.helper.XMLDocument createDocument​(commonj.sdo.DataObject dataObject,
                                                             String rootElementURI,
                                                             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