org.apache.tuscany.sdo.helper
Class XMLDocumentImpl

java.lang.Object
  extended by org.apache.tuscany.sdo.helper.XMLDocumentImpl
All Implemented Interfaces:
XMLDocument

public class XMLDocumentImpl
extends Object
implements XMLDocument

Represents an XML Document containing a tree of DataObjects. An example XMLDocument fragment is: created from this XML Schema fragment: Upon loading this XMLDocument: DataObject is an instance of Type PurchaseOrderType. RootElementURI is null because the XSD has no targetNamespace URI. RootElementName is purchaseOrder. Encoding is null because the document did not specify an encoding. XMLDeclaration is true because the document contained an XML declaration. XMLVersion is 1.0 SchemaLocation and noNamespaceSchemaLocation are null because they are not specified in the document. When saving the root element, if the type of the root dataObject is not the type of global element specified by rootElementURI and rootElementName, or if a global element does not exist for rootElementURI and rootElementName, then an xsi:type declaration is written to record the root DataObject's Type. When loading the root element and an xsi:type declaration is found it is used as the type of the root DataObject. In this case, if validation is not being performed, it is not an error if the rootElementName is not a global element.


Field Summary
protected  org.eclipse.emf.ecore.EObject documentRoot
           
protected  org.eclipse.emf.ecore.util.ExtendedMetaData extendedMetaData
           
protected  org.eclipse.emf.ecore.xmi.XMLResource resource
           
protected  org.eclipse.emf.ecore.EStructuralFeature rootElement
           
protected  org.eclipse.emf.ecore.EObject rootObject
           
protected static String WHITESPACE_REGEX
           
 
Constructor Summary
protected XMLDocumentImpl(org.eclipse.emf.ecore.util.ExtendedMetaData extendedMetaData)
           
protected XMLDocumentImpl(org.eclipse.emf.ecore.util.ExtendedMetaData extendedMetaData, DataObject dataObject, String rootElementURI, String rootElementName)
           
protected XMLDocumentImpl(org.eclipse.emf.ecore.util.ExtendedMetaData extendedMetaData, Object options)
           
 
Method Summary
protected  String deresolve(String value)
           
 String getEncoding()
          Return the XML encoding of the document, or null if not specified.
 String getNoNamespaceSchemaLocation()
          Return the value of the noNamespaceSchemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if not present.
 String getRootElementName()
          Return the name of the root element.
 String getRootElementURI()
          Return the targetNamespace URI for the root element.
 DataObject getRootObject()
          Return the root DataObject for the XMLDocument.
 String getSchemaLocation()
          Return the value of the schemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if not present.
protected  org.eclipse.emf.common.util.EMap getSchemaLocationMap()
           
 Map getUnknownProperties()
           
 String getXMLVersion()
          Return the XML version of the document, or null if not specified.
 boolean isXMLDeclaration()
          Return the XML declaration of the document.
protected  void load(InputSource inputSource, String locationURI, Object options)
           
protected  void load(InputStream inputStream, String locationURI, Object options)
           
protected  void load(Node node, Object options)
           
protected  void load(Reader inputReader, String locationURI, Object options)
           
protected  void load(javax.xml.stream.XMLStreamReader reader, Map options)
           
protected  String resolve(String value)
           
protected  void save(Node node, Object options)
           
protected  void save(OutputStream outputStream, Document document, Object options)
           
protected  void save(OutputStream outputStream, Object options)
           
protected  void save(Writer outputWriter, Object options)
           
 void setEncoding(String encoding)
          Set the XML encoding of the document, or null if not specified.
 void setNoNamespaceSchemaLocation(String schemaLocation)
          Sets the value of the noNamespaceSchemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if it should not be present.
 void setSchemaLocation(String schemaLocation)
          Sets the value of the schemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if it should not be present.
 void setXMLDeclaration(boolean xmlDeclaration)
          Set the XML declaration version of the document.
 void setXMLVersion(String xmlVersion)
          Set the XML version of the document, or null if not specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extendedMetaData

protected org.eclipse.emf.ecore.util.ExtendedMetaData extendedMetaData

rootObject

protected org.eclipse.emf.ecore.EObject rootObject

resource

protected org.eclipse.emf.ecore.xmi.XMLResource resource

rootElement

protected org.eclipse.emf.ecore.EStructuralFeature rootElement

documentRoot

protected org.eclipse.emf.ecore.EObject documentRoot

WHITESPACE_REGEX

protected static final String WHITESPACE_REGEX
See Also:
Constant Field Values
Constructor Detail

XMLDocumentImpl

protected XMLDocumentImpl(org.eclipse.emf.ecore.util.ExtendedMetaData extendedMetaData,
                          Object options)

XMLDocumentImpl

protected XMLDocumentImpl(org.eclipse.emf.ecore.util.ExtendedMetaData extendedMetaData)

XMLDocumentImpl

protected XMLDocumentImpl(org.eclipse.emf.ecore.util.ExtendedMetaData extendedMetaData,
                          DataObject dataObject,
                          String rootElementURI,
                          String rootElementName)
Method Detail

save

protected void save(OutputStream outputStream,
                    Object options)
             throws IOException
Throws:
IOException

save

protected void save(Writer outputWriter,
                    Object options)
             throws IOException
Throws:
IOException

save

protected void save(Node node,
                    Object options)
             throws IOException
Throws:
IOException

save

protected void save(OutputStream outputStream,
                    Document document,
                    Object options)
             throws IOException
Throws:
IOException

load

protected void load(InputStream inputStream,
                    String locationURI,
                    Object options)
             throws IOException
Throws:
IOException

load

protected void load(Reader inputReader,
                    String locationURI,
                    Object options)
             throws IOException
Throws:
IOException

load

protected final void load(Node node,
                          Object options)
                   throws IOException
Throws:
IOException

load

protected final void load(javax.xml.stream.XMLStreamReader reader,
                          Map options)
                   throws IOException
Throws:
IOException

load

protected void load(InputSource inputSource,
                    String locationURI,
                    Object options)
             throws IOException
Throws:
IOException

getUnknownProperties

public Map getUnknownProperties()
Returns:
a Map object with key-value pair where key is the DataObject and value contains the info about the unknown properties for the DataObject

getRootObject

public DataObject getRootObject()
Description copied from interface: XMLDocument
Return the root DataObject for the XMLDocument.

Specified by:
getRootObject in interface XMLDocument
Returns:
root DataObject for the XMLDocument.

getRootElementURI

public String getRootElementURI()
Description copied from interface: XMLDocument
Return the targetNamespace URI for the root element. If there is no targetNamespace URI, the value is null. The root element is a global element of the XML Schema with a type compatible to the DataObject.

Specified by:
getRootElementURI in interface XMLDocument
Returns:
the targetNamespace URI for the root element.

getRootElementName

public String getRootElementName()
Description copied from interface: XMLDocument
Return the name of the root element. The root element is a global element of the XML Schema with a type compatible to the DataObject.

Specified by:
getRootElementName in interface XMLDocument
Returns:
the name of the root element.

getEncoding

public String getEncoding()
Description copied from interface: XMLDocument
Return the XML encoding of the document, or null if not specified. The default value is "UTF-8". Specification of other values is implementation-dependent.

Specified by:
getEncoding in interface XMLDocument
Returns:
the XML encoding of the document, or null if not specified.

setEncoding

public void setEncoding(String encoding)
Description copied from interface: XMLDocument
Set the XML encoding of the document, or null if not specified.

Specified by:
setEncoding in interface XMLDocument

isXMLDeclaration

public boolean isXMLDeclaration()
Description copied from interface: XMLDocument
Return the XML declaration of the document. If true, XMLHelper save() will produce a declaration of the form: Encoding will be suppressed if getEncoding() is null. The default value is true.

Specified by:
isXMLDeclaration in interface XMLDocument
Returns:
the XML declaration of the document.

setXMLDeclaration

public void setXMLDeclaration(boolean xmlDeclaration)
Description copied from interface: XMLDocument
Set the XML declaration version of the document.

Specified by:
setXMLDeclaration in interface XMLDocument
Parameters:
xmlDeclaration - the XML declaration version of the document.

getXMLVersion

public String getXMLVersion()
Description copied from interface: XMLDocument
Return the XML version of the document, or null if not specified. The default value is "1.0". Specification of other values is implementation-dependent.

Specified by:
getXMLVersion in interface XMLDocument
Returns:
the XML version of the document, or null if not specified.

setXMLVersion

public void setXMLVersion(String xmlVersion)
Description copied from interface: XMLDocument
Set the XML version of the document, or null if not specified.

Specified by:
setXMLVersion in interface XMLDocument
Parameters:
xmlVersion - the XML version of the document, or null if not specified.

getSchemaLocationMap

protected org.eclipse.emf.common.util.EMap getSchemaLocationMap()
Returns:
an EMap containing the schema locations or null when no map

deresolve

protected String deresolve(String value)
Parameters:
value - from schema location map.
Returns:
string form of URI from provided value, deresolved if appropriate.

resolve

protected String resolve(String value)
Parameters:
value - for schema location from input parameter.
Returns:
string form of URI from provided value, resolved if appropriate.

getSchemaLocation

public String getSchemaLocation()
Description copied from interface: XMLDocument
Return the value of the schemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if not present.

Specified by:
getSchemaLocation in interface XMLDocument
Returns:
the value of the schemaLocation declaration, or null if not present.

setSchemaLocation

public void setSchemaLocation(String schemaLocation)
Description copied from interface: XMLDocument
Sets the value of the schemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if it should not be present.

Specified by:
setSchemaLocation in interface XMLDocument
Parameters:
schemaLocation - the value of the schemaLocation declaration, or null.

getNoNamespaceSchemaLocation

public String getNoNamespaceSchemaLocation()
Description copied from interface: XMLDocument
Return the value of the noNamespaceSchemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if not present.

Specified by:
getNoNamespaceSchemaLocation in interface XMLDocument
Returns:
the value of the noNamespaceSchemaLocation declaration, or null if not present.

setNoNamespaceSchemaLocation

public void setNoNamespaceSchemaLocation(String schemaLocation)
Description copied from interface: XMLDocument
Sets the value of the noNamespaceSchemaLocation declaration for the http://www.w3.org/2001/XMLSchema-instance namespace in the root element, or null if it should not be present.

Specified by:
setNoNamespaceSchemaLocation in interface XMLDocument
Parameters:
schemaLocation - the value of the noNamespaceSchemaLocation declaration, or null.


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.