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

E13403-03

oracle.ide.marshal.xml
Class Object2Dom

java.lang.Object
  extended by oracle.ide.marshal.xml.XMLObjectStore
      extended by oracle.ide.marshal.xml.Object2Dom
All Implemented Interfaces:
ObjectStore

public final class Object2Dom
extends XMLObjectStore

This class mediates the conversion of an object to and from an XML representation. An extension API is available for registring custom conversions. A migration API is available for registring XSLT files that should be applied to an XML document before unmarshalling it; multiple XSLT files can be applied in sequence.


Field Summary
static java.lang.String ID_ATTR
           
static java.lang.String IDREF_ATTR
           
static java.lang.String ITEM_TAG
           
static java.util.HashSet<java.lang.String> obsoleteClassNames
           
static int REPORT_DATA_CONSTRAINT_ERRORS
           
static int REPORT_NO_ERRORS
           
static int REPORT_VALIDATION_ERRORS
           
static int REPORT_WELL_FORMED_ERRORS
           
static java.lang.String XMLNS_ATTR
           
static java.lang.String XMLNS_URI
           
 
Fields inherited from class oracle.ide.marshal.xml.XMLObjectStore
CLASS_ATTR, NSELEM_ATTR
 
Method Summary
static void exemptTypeFromIdref(java.lang.Class type)
           
static org.w3c.dom.NodeList getChildrenByTagName(org.w3c.dom.Element element, java.lang.String tag)
           
 java.net.URL getDocumentURL()
          Returns the URL of the current document that is being marshalled or unmarshalled.
 java.lang.String getEncoding()
           
 boolean isIncludeNulls()
          Return whether null values should be included as empty elements or if they should be omitted from the document.
 boolean isNamedArrayElems()
          Return whether array elements should be named or just be generic.
 boolean isNullIfEmpty()
          Return whether empty values should be converted to null.
 java.lang.Object load(java.net.URL url)
          Creates a new instance of an object based on its peristent state saved at the specified URL.
 void marshalAttributes(org.w3c.dom.Element element, java.lang.Object object)
          Sets the attributes on the specified Element to correspond to the attribute properties from the specified object.
static Object2Dom newInstance()
          Factory method for creating a new instance of Object2Dom that is configured with the (strongly) recommended options.
static Object2Dom newInstanceForSchemaCompiledBeans()
          Factory method for creating a new instance of Object2Dom that is configured to marshal JavaBeans that are designed to conform to a DTD.
 boolean open(java.net.URL url, java.lang.Object object)
          Initializes the specified object based on its persistent state that is saved at the specified URL.
static void registerConverter(ToDomConverter converter)
           
static void registerDoctype(java.lang.Class objectClass, java.lang.String rootName, java.lang.String publicID, java.lang.String systemID)
           
static void registerNamespaceElem(java.lang.Class objectClass, java.lang.String namespaceURI, java.lang.String localElemName)
          This method associates the specified namespace URI and local element name with the objectClass.
 boolean save(java.net.URL url, java.lang.Object object)
          Marshals the persistent properties of the specified object and saves the persistent form at the specified URL.
 void setDoctypeID(java.lang.String publicID, java.lang.String systemID)
           
 void setDocumentURL(java.net.URL documentURL)
          Sets the base document URL that all URLs should be resolved against.
 void setDTD(oracle.xml.parser.v2.DTD dtd)
          WARNING: This method is still in the prototype stage.
 void setEncoding(java.lang.String encoding)
           
 void setLogger(int reportLevel, Object2DomLogger logger)
          WARNING: This method is still in the prototype stage.
 void setNamespaceURI(java.lang.String namespaceURI)
           
 oracle.xml.parser.v2.XMLDocument toDocument(java.lang.Object object, java.lang.String rootTag)
           
 oracle.xml.parser.v2.XMLDocument toDocument(java.lang.Object object, java.lang.String rootTag, java.lang.Class defaultClass)
           
 oracle.xml.parser.v2.XMLDocument toDocument(java.lang.Object object, java.lang.String rootTag, java.lang.Class defaultClass, java.net.URL outURL)
           
 oracle.xml.parser.v2.XMLDocument toDocument(java.lang.Object object, java.lang.String rootTag, java.net.URL outURL)
           
 org.w3c.dom.Element toElement(java.lang.Object object, java.lang.String tag, java.lang.Class defaultClass)
          Deprecated. Need to use toElement( Object, String, Class, String ) instead.
 org.w3c.dom.Element toElement(java.lang.Object object, java.lang.String tag, java.lang.Class defaultClass, java.lang.String namespaceURI)
          Recursive method that converts the given Object into a DOM Element with the given tag.
 java.lang.Object toObject(org.w3c.dom.Element element, java.lang.Class defaultClass)
          Recursive method that converts the given Element into an object.
 java.lang.Object toObject(java.io.InputStream inputStream, java.lang.Class defaultClass)
           
 java.lang.Object toObject(java.io.Reader reader, java.lang.Class defaultClass)
           
 java.lang.Object toObject(java.net.URL url)
           
 java.lang.Object toObject(java.net.URL url, java.lang.Class defaultClass)
           
 java.lang.Object toObject(oracle.xml.parser.v2.XMLDocument document)
           
 java.lang.Object toObject(oracle.xml.parser.v2.XMLDocument document, java.lang.Class defaultClass)
           
 void unmarshalAttributes(org.w3c.dom.Element element, java.lang.Object object)
          Sets the properties on the specified object based on the attributes that are in the specified Element.
 
Methods inherited from class oracle.ide.marshal.xml.XMLObjectStore
registerTransform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPORT_NO_ERRORS

public static final int REPORT_NO_ERRORS
See Also:
Constant Field Values

REPORT_WELL_FORMED_ERRORS

public static final int REPORT_WELL_FORMED_ERRORS
See Also:
Constant Field Values

REPORT_VALIDATION_ERRORS

public static final int REPORT_VALIDATION_ERRORS
See Also:
Constant Field Values

REPORT_DATA_CONSTRAINT_ERRORS

public static final int REPORT_DATA_CONSTRAINT_ERRORS
See Also:
Constant Field Values

ID_ATTR

public static final java.lang.String ID_ATTR
See Also:
Constant Field Values

IDREF_ATTR

public static final java.lang.String IDREF_ATTR
See Also:
Constant Field Values

XMLNS_ATTR

public static final java.lang.String XMLNS_ATTR
See Also:
Constant Field Values

XMLNS_URI

public static final java.lang.String XMLNS_URI
See Also:
Constant Field Values

ITEM_TAG

public static final java.lang.String ITEM_TAG
See Also:
Constant Field Values

obsoleteClassNames

public static final java.util.HashSet<java.lang.String> obsoleteClassNames
Method Detail

newInstance

public static Object2Dom newInstance()
Factory method for creating a new instance of Object2Dom that is configured with the (strongly) recommended options.


newInstanceForSchemaCompiledBeans

public static Object2Dom newInstanceForSchemaCompiledBeans()
Factory method for creating a new instance of Object2Dom that is configured to marshal JavaBeans that are designed to conform to a DTD. The Object2Dom instance is configured to omit annotations (such as ID and class attributes) and substructures (such as "Item" elements) so that these do not interfere with DTD compliance.

Use newInstance() instead, whenever possible.


toDocument

public oracle.xml.parser.v2.XMLDocument toDocument(java.lang.Object object,
                                                   java.lang.String rootTag,
                                                   java.net.URL outURL)
                                            throws java.io.IOException
Throws:
java.io.IOException

toDocument

public oracle.xml.parser.v2.XMLDocument toDocument(java.lang.Object object,
                                                   java.lang.String rootTag,
                                                   java.lang.Class defaultClass,
                                                   java.net.URL outURL)
                                            throws java.io.IOException
Throws:
java.io.IOException

toDocument

public oracle.xml.parser.v2.XMLDocument toDocument(java.lang.Object object,
                                                   java.lang.String rootTag)

toDocument

public oracle.xml.parser.v2.XMLDocument toDocument(java.lang.Object object,
                                                   java.lang.String rootTag,
                                                   java.lang.Class defaultClass)

toObject

public java.lang.Object toObject(java.io.InputStream inputStream,
                                 java.lang.Class defaultClass)
                          throws java.io.IOException
Throws:
java.io.IOException

toObject

public java.lang.Object toObject(java.io.Reader reader,
                                 java.lang.Class defaultClass)
                          throws java.io.IOException
Throws:
java.io.IOException

toObject

public java.lang.Object toObject(java.net.URL url)
                          throws java.io.IOException
Throws:
java.io.IOException

toObject

public java.lang.Object toObject(java.net.URL url,
                                 java.lang.Class defaultClass)
                          throws java.io.IOException
Throws:
java.io.IOException

toObject

public java.lang.Object toObject(oracle.xml.parser.v2.XMLDocument document)

toObject

public java.lang.Object toObject(oracle.xml.parser.v2.XMLDocument document,
                                 java.lang.Class defaultClass)

getEncoding

public java.lang.String getEncoding()

setEncoding

public void setEncoding(java.lang.String encoding)

setDoctypeID

public void setDoctypeID(java.lang.String publicID,
                         java.lang.String systemID)

setDTD

public void setDTD(oracle.xml.parser.v2.DTD dtd)
WARNING: This method is still in the prototype stage.


setNamespaceURI

public void setNamespaceURI(java.lang.String namespaceURI)

setLogger

public void setLogger(int reportLevel,
                      Object2DomLogger logger)
WARNING: This method is still in the prototype stage.


registerConverter

public static void registerConverter(ToDomConverter converter)

registerDoctype

public static void registerDoctype(java.lang.Class objectClass,
                                   java.lang.String rootName,
                                   java.lang.String publicID,
                                   java.lang.String systemID)

registerNamespaceElem

public static void registerNamespaceElem(java.lang.Class objectClass,
                                         java.lang.String namespaceURI,
                                         java.lang.String localElemName)
This method associates the specified namespace URI and local element name with the objectClass. Whenever an object whose type exactly matches objectClass is marshalled (i.e. saved), it will be assigned the specified namespace URI and an "nselem" attribute containing the local element name.

This method is part of the version migration support implemented by Object2Dom.

Parameters:
objectClass -
namespaceURI -
localElemName - This is written into the "nselem" attribute. It's intended to be used by XSLT-based migration transformations.

exemptTypeFromIdref

public static void exemptTypeFromIdref(java.lang.Class type)

isNamedArrayElems

public boolean isNamedArrayElems()
Return whether array elements should be named or just be generic. See the comments for the _namedArrayElems field for details.


isNullIfEmpty

public boolean isNullIfEmpty()
Return whether empty values should be converted to null. See the comments for the _nullIfEmpty field for details.


isIncludeNulls

public boolean isIncludeNulls()
Return whether null values should be included as empty elements or if they should be omitted from the document. See the comments for the _includeNulls field for details.


toElement

public org.w3c.dom.Element toElement(java.lang.Object object,
                                     java.lang.String tag,
                                     java.lang.Class defaultClass)
Deprecated. Need to use toElement( Object, String, Class, String ) instead.


toElement

public org.w3c.dom.Element toElement(java.lang.Object object,
                                     java.lang.String tag,
                                     java.lang.Class defaultClass,
                                     java.lang.String namespaceURI)
Recursive method that converts the given Object into a DOM Element with the given tag. The class is expressed explicitly as an XML attribute if the object type does not match defaultClass.

NOTE: This method should not be called directly by application code. This is intended to be called by classes that implement ToDomConverter when they need to recurse.


toObject

public java.lang.Object toObject(org.w3c.dom.Element element,
                                 java.lang.Class defaultClass)
Recursive method that converts the given Element into an object. If the element does not provide a class type explicitly, the defaultType is used to instantiate the object.

NOTE: This method should not be called directly by application code. This is intended to be called by classes that implement ToDomConverter when they need to recurse.


getChildrenByTagName

public static org.w3c.dom.NodeList getChildrenByTagName(org.w3c.dom.Element element,
                                                        java.lang.String tag)

marshalAttributes

public void marshalAttributes(org.w3c.dom.Element element,
                              java.lang.Object object)
Sets the attributes on the specified Element to correspond to the attribute properties from the specified object.


unmarshalAttributes

public void unmarshalAttributes(org.w3c.dom.Element element,
                                java.lang.Object object)
Sets the properties on the specified object based on the attributes that are in the specified Element.


load

public java.lang.Object load(java.net.URL url)
                      throws java.io.IOException
Description copied from interface: ObjectStore
Creates a new instance of an object based on its peristent state saved at the specified URL.

Throws:
java.io.IOException

open

public boolean open(java.net.URL url,
                    java.lang.Object object)
             throws java.io.IOException
Description copied from interface: ObjectStore
Initializes the specified object based on its persistent state that is saved at the specified URL. This has the effect of reloading or reverting an object's in-memory state.

Throws:
java.io.IOException

save

public boolean save(java.net.URL url,
                    java.lang.Object object)
             throws java.io.IOException
Description copied from interface: ObjectStore
Marshals the persistent properties of the specified object and saves the persistent form at the specified URL.

Throws:
java.io.IOException

getDocumentURL

public java.net.URL getDocumentURL()
Returns the URL of the current document that is being marshalled or unmarshalled. If there is no current URL then null is returned. This URL is used for resolving and unresolving URL properties within objects so that they are stored using relative paths or using portions of paths that are based on macro definitions.


setDocumentURL

public void setDocumentURL(java.net.URL documentURL)
Sets the base document URL that all URLs should be resolved against. The base document URL does not need to have its filename trimmed off.


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

E13403-03

Copyright © 1997, 2009, Oracle. All rights reserved.