Class SDOXMLHelperDelegate
- java.lang.Object
-
- org.eclipse.persistence.sdo.helper.delegates.SDOXMLHelperDelegate
-
- All Implemented Interfaces:
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 Summary
Constructors Constructor Description SDOXMLHelperDelegate(HelperContext aContext)
SDOXMLHelperDelegate(HelperContext aContext, ClassLoader aClassLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDescriptors(List types)
INTERNAL:XMLDocument
createDocument(DataObject dataObject, String rootElementURI, String rootElementName)
Creates an XMLDocument with the specified XML rootElement for the DataObject.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)
XMLDocument
load(InputStream inputStream)
Creates and returns an XMLDocument from the inputStream.XMLDocument
load(InputStream inputStream, String locationURI, Object options)
Creates and returns an XMLDocument from the inputStream.XMLDocument
load(Reader inputReader, String locationURI, Object options)
Creates and returns an XMLDocument from the inputReader.XMLDocument
load(String inputString)
Creates and returns an XMLDocument from the input String.XMLDocument
load(Source source, String locationURI, Object options)
Creates and returns an XMLDocument from the inputSource.XMLDocument
load(InputSource inputSource, String locationURI, Object options)
Creates and returns an XMLDocument from the inputSource.void
reset()
INTERNAL:String
save(DataObject dataObject, String rootElementURI, String rootElementName)
Returns the DataObject saved as an XML document with the specified root element.void
save(DataObject dataObject, String rootElementURI, String rootElementName, OutputStream outputStream)
Saves the DataObject as an XML document with the specified root element.void
save(XMLDocument xmlDocument, OutputStream outputStream, Object options)
Serializes an XMLDocument as an XML document into the outputStream.void
save(XMLDocument xmlDocument, Writer outputWriter, Object options)
Serializes an XMLDocument as an XML document into the outputWriter.void
save(XMLDocument xmlDocument, Result result, Object options)
Serializes an XMLDocument as an XML document into the outputResult in a serialization technology independent format (as specified in javax.xml.transform).void
serialize(XMLDocument xmlDocument, OutputStream outputStream, Object options)
void
setHelperContext(HelperContext helperContext)
INTERNAL: Set the helperContext that this instance is associated with.void
setLoader(SDOClassLoader loader)
INTERNAL:void
setTimeZone(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:
-
-
-
Constructor Detail
-
SDOXMLHelperDelegate
public SDOXMLHelperDelegate(HelperContext aContext)
-
SDOXMLHelperDelegate
public SDOXMLHelperDelegate(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 interfaceSDOXMLHelper
-
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 interfaceSDOXMLHelper
-
load
public 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 interfaceXMLHelper
- 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 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 interfaceXMLHelper
- 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 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 interfaceXMLHelper
- Parameters:
inputStream
- specifies the InputStream to read fromlocationURI
- specifies the URI of the document for relative schema locationsoptions
- 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 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 interfaceSDOXMLHelper
- Parameters:
inputSource
- specifies the InputSource to read fromlocationURI
- specifies the URI of the document for relative schema locationsoptions
- 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 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 interfaceXMLHelper
- Parameters:
inputReader
- specifies the Reader to read fromlocationURI
- specifies the URI of the document for relative schema locationsoptions
- 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 XMLDocument load(Source source, String locationURI, Object options) throws IOException
Description copied from interface:XMLHelper
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 interfaceXMLHelper
- Parameters:
source
- specifies the Source to read fromlocationURI
- specifies the URI of the document for relative schema locationsoptions
- implementation-specific options.- Returns:
- the new XMLDocument loaded
- Throws:
IOException
- for stream exceptions.
-
save
public String save(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 interfaceXMLHelper
- Parameters:
dataObject
- specifies DataObject to be savedrootElementURI
- the Target Namespace URI of the root XML elementrootElementName
- 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(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 interfaceXMLHelper
- Parameters:
dataObject
- specifies DataObject to be savedrootElementURI
- the Target Namespace URI of the root XML elementrootElementName
- the Name of the root XML elementoutputStream
- specifies the OutputStream to write to.- Throws:
IOException
- for stream exceptions.IllegalArgumentException
- if the dataObject tree is not closed or has no container.XMLMarshalException
-
serialize
public void serialize(XMLDocument xmlDocument, OutputStream outputStream, Object options) throws IOException
- Specified by:
serialize
in interfaceSDOXMLHelper
- Throws:
IOException
-
save
public void save(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 interfaceXMLHelper
- Parameters:
xmlDocument
- specifies XMLDocument to be savedoutputStream
- 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(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 interfaceXMLHelper
- Parameters:
xmlDocument
- specifies XMLDocument to be savedoutputWriter
- 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(XMLDocument xmlDocument, Result result, Object options) throws IOException
Description copied from interface:XMLHelper
Serializes an XMLDocument as an XML document into the outputResult in a serialization technology independent format (as specified in javax.xml.transform). The OutputResult will be flushed after writing. Does not perform validation to ensure compliance with an XSD.- Specified by:
save
in interfaceXMLHelper
- Parameters:
xmlDocument
- specifies XMLDocument to be savedresult
- specifies Result to be savedoptions
- implementation-specific options.- Throws:
IOException
- for stream exceptions.
-
createDocument
public XMLDocument createDocument(DataObject dataObject, String rootElementURI, String rootElementName)
Creates an XMLDocument with the specified XML rootElement for the DataObject.- Specified by:
createDocument
in interfaceXMLHelper
- Parameters:
dataObject
- specifies DataObject to be savedrootElementURI
- the Target Namespace URI of the root XML elementrootElementName
- the Name of the root XML element- Returns:
- XMLDocument a new XMLDocument set with the specified parameters.
-
setLoader
public void setLoader(SDOClassLoader loader)
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
setLoader
in interfaceSDOXMLHelper
-
getLoader
public SDOClassLoader getLoader()
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
getLoader
in interfaceSDOXMLHelper
- Returns:
-
setXmlContext
public void setXmlContext(XMLContext xmlContext)
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
setXmlContext
in interfaceSDOXMLHelper
-
getXmlContext
public XMLContext getXmlContext()
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
getXmlContext
in interfaceSDOXMLHelper
- Returns:
-
initializeDescriptor
public void initializeDescriptor(XMLDescriptor descriptor)
- Specified by:
initializeDescriptor
in interfaceSDOXMLHelper
-
addDescriptors
public void addDescriptors(List types)
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
addDescriptors
in interfaceSDOXMLHelper
-
setTopLinkProject
public void setTopLinkProject(Project toplinkProject)
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
setTopLinkProject
in interfaceSDOXMLHelper
-
getTopLinkProject
public Project getTopLinkProject()
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
getTopLinkProject
in interfaceSDOXMLHelper
- Returns:
-
setXmlMarshaller
public void setXmlMarshaller(XMLMarshaller xmlMarshaller)
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
setXmlMarshaller
in interfaceSDOXMLHelper
-
getXmlMarshaller
public XMLMarshaller getXmlMarshaller()
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
getXmlMarshaller
in interfaceSDOXMLHelper
- Returns:
-
setXmlUnmarshaller
public void setXmlUnmarshaller(XMLUnmarshaller xmlUnmarshaller)
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
setXmlUnmarshaller
in interfaceSDOXMLHelper
-
getXmlUnmarshaller
public XMLUnmarshaller getXmlUnmarshaller()
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
getXmlUnmarshaller
in interfaceSDOXMLHelper
- Returns:
-
reset
public void reset()
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
reset
in interfaceSDOXMLHelper
-
getHelperContext
public HelperContext getHelperContext()
Description copied from interface:SDOXMLHelper
INTERNAL: Return the helperContext that this instance is associated with.- Specified by:
getHelperContext
in interfaceSDOXMLHelper
- Returns:
-
setHelperContext
public void setHelperContext(HelperContext helperContext)
Description copied from interface:SDOXMLHelper
INTERNAL: Set the helperContext that this instance is associated with.- Specified by:
setHelperContext
in interfaceSDOXMLHelper
-
getXmlConversionManager
public org.eclipse.persistence.internal.oxm.XMLConversionManager getXmlConversionManager()
Description copied from interface:SDOXMLHelper
INTERNAL:- Specified by:
getXmlConversionManager
in interfaceSDOXMLHelper
-
-