Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)

B32476-02


oracle.toplink.ox
Class XMLMarshaller

java.lang.Object
  extended by oracle.toplink.ox.XMLMarshaller


public class XMLMarshaller
extends java.lang.Object

Class used to marshal object to XML.

Create an XMLMarshaller from an XMLContext.
Code Sample
XMLContext context = new XMLContext("mySessionName");
XMLMarshaller marshaller = context.createMarshaller();

Objects can be marshalled to the following outputs:

Objects that can be marshalled are those which are mapped in the TopLink project associated with the XMLContext, and which are mapped to an XMLDescriptor that has a default root element specified.

See Also:
XMLContext

Constructor Summary
XMLMarshaller(XMLContext xmlContext)
          Create a new XMLMarshaller based on the specified session

 

Method Summary
 XMLAttachmentMarshaller getAttachmentMarshaller()
           
 java.lang.String getEncoding()
          Get the encoding set on this XMLMarshaller If the encoding has not been set the default UTF-8 will be used
 XMLMarshalListener getMarshalListener()
           
 java.lang.String getNoNamespaceSchemaLocation()
          Get the no namespace schema location set on this XMLMarshaller
 java.util.Properties getProperties()
          Return a properties object for a given instance of the XMLMarshaller.
 java.lang.Object getProperty(java.lang.Object key)
          Return the property for a given key, if one exists.
 java.lang.String getSchemaLocation()
          Get the schema location set on this XMLMarshaller
 XMLContext getXMLContext()
          Return the instance of XMLContext that was used to create this instance of XMLMarshaller.
 boolean isFormattedOutput()
          Returns if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.
 boolean isFragment()
          Returns if this should marshal to a fragment.
 void marshal(java.lang.Object object, org.xml.sax.ContentHandler contentHandler)
          Convert the given object to XML and update the given contentHandler with that XML Document
 void marshal(java.lang.Object object, org.xml.sax.ContentHandler contentHandler, org.xml.sax.ext.LexicalHandler lexicalHandler)
          Convert the given object to XML and update the given contentHandler with that XML Document
 void marshal(java.lang.Object object, MarshalRecord marshalRecord)
          Convert the given object to XML and update the given marshal record with that XML Document.
 void marshal(java.lang.Object object, org.w3c.dom.Node node)
          Convert the given object to XML and update the given node with that XML Document
 void marshal(java.lang.Object object, java.io.OutputStream outputStream)
          Convert the given object to XML and update the given outputStream with that XML Document
 void marshal(java.lang.Object object, javax.xml.transform.Result result)
          Convert the given object to XML and update the given result with that XML Document
 void marshal(java.lang.Object object, java.io.Writer writer)
          Convert the given object to XML and update the given writer with that XML Document
 org.w3c.dom.Document objectToXML(java.lang.Object object)
          Convert the given object to an XML Document
 org.w3c.dom.Document objectToXML(java.lang.Object object, org.w3c.dom.Node parent)
          Deprecated.  
 void setAttachmentMarshaller(XMLAttachmentMarshaller atm)
           
 void setEncoding(java.lang.String newEncoding)
          Set the encoding on this XMLMarshaller If the encoding is not set the default UTF-8 will be used
 void setFormattedOutput(boolean shouldFormat)
          Set if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.
 void setFragment(boolean fragment)
          Set if this should marshal to a fragment.
 void setMarshalListener(XMLMarshalListener listener)
           
 void setNoNamespaceSchemaLocation(java.lang.String newNoNamespaceSchemaLocation)
          Set the no namespace schema location on this XMLMarshaller
 void setSchemaLocation(java.lang.String newSchemaLocation)
          Set the schema location on this XMLMarshaller
 void setXMLContext(XMLContext value)
          Set the XMLContext used by this instance of XMLMarshaller.
 void setXMLMarshalHandler(XMLMarshalListener marshalListener)
           

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

XMLMarshaller

public XMLMarshaller(XMLContext xmlContext)
Create a new XMLMarshaller based on the specified session
Parameters:
session - A single session

Method Detail

getXMLContext

public XMLContext getXMLContext()
Return the instance of XMLContext that was used to create this instance of XMLMarshaller.

setXMLContext

public void setXMLContext(XMLContext value)
Set the XMLContext used by this instance of XMLMarshaller.

isFormattedOutput

public boolean isFormattedOutput()
Returns if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.
Returns:
if this XMLMarshaller should format the XML

setFormattedOutput

public void setFormattedOutput(boolean shouldFormat)
Set if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.
Parameters:
shouldFormat - if this XMLMarshaller should format the XML

getEncoding

public java.lang.String getEncoding()
Get the encoding set on this XMLMarshaller If the encoding has not been set the default UTF-8 will be used
Returns:
the encoding set on this XMLMarshaller

setEncoding

public void setEncoding(java.lang.String newEncoding)
Set the encoding on this XMLMarshaller If the encoding is not set the default UTF-8 will be used
Parameters:
newEncoding - the encoding to set on this XMLMarshaller

getSchemaLocation

public java.lang.String getSchemaLocation()
Get the schema location set on this XMLMarshaller
Returns:
the schema location specified on this XMLMarshaller

setSchemaLocation

public void setSchemaLocation(java.lang.String newSchemaLocation)
Set the schema location on this XMLMarshaller
Parameters:
newSchemaLocation - the schema location to be seton this XMLMarshaller

getNoNamespaceSchemaLocation

public java.lang.String getNoNamespaceSchemaLocation()
Get the no namespace schema location set on this XMLMarshaller
Returns:
the no namespace schema location specified on this XMLMarshaller

getProperties

public java.util.Properties getProperties()
Return a properties object for a given instance of the XMLMarshaller.
Returns:

getProperty

public java.lang.Object getProperty(java.lang.Object key)
Return the property for a given key, if one exists.
Returns:

setNoNamespaceSchemaLocation

public void setNoNamespaceSchemaLocation(java.lang.String newNoNamespaceSchemaLocation)
Set the no namespace schema location on this XMLMarshaller
Parameters:
newNoNamespaceSchemaLocation - no namespace schema location to be seton this XMLMarshaller

setXMLMarshalHandler

public void setXMLMarshalHandler(XMLMarshalListener marshalListener)

getMarshalListener

public XMLMarshalListener getMarshalListener()

setMarshalListener

public void setMarshalListener(XMLMarshalListener listener)

marshal

public void marshal(java.lang.Object object,
                    javax.xml.transform.Result result)
             throws XMLMarshalException
Convert the given object to XML and update the given result with that XML Document
Parameters:
object - the object to marshal
result - the result to marshal the object to
Throws:
XMLMarshalException - if an error occurred during marshalling

marshal

public void marshal(java.lang.Object object,
                    java.io.OutputStream outputStream)
             throws XMLMarshalException
Convert the given object to XML and update the given outputStream with that XML Document
Parameters:
object - the object to marshal
outputStream - the outputStream to marshal the object to
Throws:
XMLMarshalException - if an error occurred during marshalling

marshal

public void marshal(java.lang.Object object,
                    java.io.Writer writer)
             throws XMLMarshalException
Convert the given object to XML and update the given writer with that XML Document
Parameters:
object - the object to marshal
writer - the writer to marshal the object to
Throws:
XMLMarshalException - if an error occurred during marshalling

marshal

public void marshal(java.lang.Object object,
                    org.xml.sax.ContentHandler contentHandler)
             throws XMLMarshalException
Convert the given object to XML and update the given contentHandler with that XML Document
Parameters:
object - the object to marshal
contentHandler - the contentHandler which the specified object should be marshalled to
Throws:
XMLMarshalException - if an error occurred during marshalling

marshal

public void marshal(java.lang.Object object,
                    org.xml.sax.ContentHandler contentHandler,
                    org.xml.sax.ext.LexicalHandler lexicalHandler)
             throws XMLMarshalException
Convert the given object to XML and update the given contentHandler with that XML Document
Parameters:
object - the object to marshal
contentHandler - the contentHandler which the specified object should be marshalled to
Throws:
XMLMarshalException - if an error occurred during marshalling

marshal

public void marshal(java.lang.Object object,
                    org.w3c.dom.Node node)
             throws XMLMarshalException
Convert the given object to XML and update the given node with that XML Document
Parameters:
object - the object to marshal
node - the node which the specified object should be marshalled to
Throws:
XMLMarshalException - if an error occurred during marshalling

marshal

public void marshal(java.lang.Object object,
                    MarshalRecord marshalRecord)
Convert the given object to XML and update the given marshal record with that XML Document.
Parameters:
object - the object to marshal
marshalRecord - the marshalRecord to marshal the object to

objectToXML

public org.w3c.dom.Document objectToXML(java.lang.Object object)
                                 throws XMLMarshalException
Convert the given object to an XML Document
Parameters:
object - the object to marshal
Returns:
the document which the specified object has been marshalled to
Throws:
XMLMarshalException - if an error occurred during marshalling

objectToXML

public org.w3c.dom.Document objectToXML(java.lang.Object object,
                                        org.w3c.dom.Node parent)
                                 throws XMLMarshalException
Deprecated. 
Convert the given object to descendants of the parent element
Parameters:
object - the object to marshal
parent - the node to marshal the object to
Returns:
the document which the specified object has been marshalled to
Throws:
XMLMarshalException - if an error occurred during marshalling

setFragment

public void setFragment(boolean fragment)
Set if this should marshal to a fragment. If true an XML header string is not written out.
Parameters:
fragment - if this should marshal to a fragment or not

isFragment

public boolean isFragment()
Returns if this should marshal to a fragment. If true an XML header string is not written out.
Returns:
if this should marshal to a fragment or not

setAttachmentMarshaller

public void setAttachmentMarshaller(XMLAttachmentMarshaller atm)

getAttachmentMarshaller

public XMLAttachmentMarshaller getAttachmentMarshaller()

Skip navigation links

Copyright © 1998, 2009, Oracle. All Rights Reserved.