org.eclipse.emf.ecore.xmi.impl
Class XMLSaveImpl

java.lang.Object
  extended byorg.eclipse.emf.ecore.xmi.impl.XMLSaveImpl
All Implemented Interfaces:
XMLSave
Direct Known Subclasses:
XMISaveImpl

public class XMLSaveImpl
extends Object
implements XMLSave

This implements the XML serializer, possibly using an XMLMap if one is provided as a save option.


Nested Class Summary
protected static class XMLSaveImpl.Escape
           
protected static class XMLSaveImpl.Lookup
           
protected  class XMLSaveImpl.XMLTypeInfoImpl
          Forces type information (xsi:type/xmi:type) to be serialized for references in cases where the object's type is different from the feature's type.
 
Nested classes inherited from class org.eclipse.emf.ecore.xmi.XMLSave
XMLSave.XMLTypeInfo
 
Field Summary
protected  EClass anySimpleType
           
protected  EClass anyType
           
protected static int ATTRIBUTE_FEATURE_MAP
           
protected static int CONTENT_ELEMENT
           
protected static int CROSS_DOC
           
protected  Node currentNode
           
protected static int DATATYPE_ATTRIBUTE_MANY
           
protected static int DATATYPE_CONTENT_SINGLE
           
protected static int DATATYPE_ELEMENT_SINGLE
           
protected static int DATATYPE_MANY
           
protected static int DATATYPE_SINGLE
           
protected static int DATATYPE_SINGLE_NILLABLE
           
protected  boolean declareSchemaLocation
           
protected  boolean declareSchemaLocationImplementation
           
protected  boolean declareXML
           
protected  boolean declareXSI
           
protected  XMLString doc
           
protected  Document document
           
protected static int ELEMENT_FEATURE_MAP
           
protected static int EMPTY_ELEMENT
           
protected  String encoding
           
protected  Map eObjectToExtensionMap
           
protected  XMLSaveImpl.Escape escape
           
protected  XMLSaveImpl.Escape escapeURI
           
protected  ExtendedMetaData extendedMetaData
           
protected  XMLSaveImpl.Lookup featureTable
           
protected  int flushThreshold
           
protected  DOMHandler handler
           
protected  XMLHelper helper
           
protected  String idAttributeName
           
protected  String idAttributeNS
           
protected static int INDEX_LOOKUP
           
protected  boolean keepDefaults
           
protected  XMLResource.XMLMap map
           
protected  NameInfo nameInfo
           
protected static int OBJECT_ATTRIBUTE_IDREF_MANY
           
protected static int OBJECT_ATTRIBUTE_IDREF_SINGLE
           
protected static int OBJECT_ATTRIBUTE_MANY
           
protected static int OBJECT_ATTRIBUTE_SINGLE
           
protected static int OBJECT_CONTAIN_MANY
           
protected static int OBJECT_CONTAIN_MANY_UNSETTABLE
           
protected static int OBJECT_CONTAIN_SINGLE
           
protected static int OBJECT_CONTAIN_SINGLE_UNSETTABLE
           
protected static int OBJECT_ELEMENT_IDREF_MANY
           
protected static int OBJECT_ELEMENT_IDREF_SINGLE
           
protected static int OBJECT_ELEMENT_IDREF_SINGLE_UNSETTABLE
           
protected static int OBJECT_ELEMENT_MANY
           
protected static int OBJECT_ELEMENT_SINGLE
           
protected static int OBJECT_ELEMENT_SINGLE_UNSETTABLE
           
protected static int OBJECT_HREF_MANY
           
protected static int OBJECT_HREF_MANY_UNSETTABLE
           
protected static int OBJECT_HREF_SINGLE
           
protected static int OBJECT_HREF_SINGLE_UNSETTABLE
           
protected  String processDanglingHREF
           
protected  EObject root
           
protected static int SAME_DOC
           
protected  boolean saveTypeInfo
           
protected static int SKIP
           
protected  boolean toDOM
           
protected static int TRANSIENT
           
protected  boolean useCache
           
protected  boolean useEncodedAttributeStyle
           
protected static String XML_VERSION
           
protected  XMLResource xmlResource
           
protected  EPackage xmlSchemaTypePackage
           
protected  XMLSave.XMLTypeInfo xmlTypeInfo
           
protected  String xmlVersion
           
protected static String XSI_NIL
           
protected static String XSI_NO_NAMESPACE_SCHEMA_LOCATION
           
protected static String XSI_SCHEMA_LOCATION
           
protected static String XSI_TYPE_NS
           
protected static String XSI_XMLNS
           
 
Constructor Summary
XMLSaveImpl(Map options, XMLHelper helper, String encoding)
          Constructor for XMLSave.
XMLSaveImpl(Map options, XMLHelper helper, String encoding, String xmlVersion)
           
XMLSaveImpl(XMLHelper helper)
           
 
Method Summary
protected  void addNamespaceDeclarations()
           
protected  void endSaveFeatures(EObject o, int elementType, String content)
           
protected  String getContent(EObject o, EStructuralFeature[] features)
           
protected  String getDataTypeElementSingleSimple(EObject o, EStructuralFeature f)
           
protected  String getDatatypeValue(Object value, EStructuralFeature f, boolean isAttribute)
           
protected  String getElementIDRefManySimple(EObject o, EStructuralFeature f)
           
protected  String getElementIDRefSingleSimple(EObject o, EStructuralFeature f)
           
protected  String getElementReferenceManySimple(EObject o, EStructuralFeature f)
           
protected  String getElementReferenceSingleSimple(EObject o, EStructuralFeature f)
           
protected  EObject getSchemaLocationRoot(EObject eObject)
           
protected  void init(XMLResource resource, Map options)
           
 boolean isDuplicateURI(String nsURI)
           
protected  boolean isEmpty(EObject o, EStructuralFeature f)
           
protected  boolean isNil(EObject o, EStructuralFeature f)
           
protected  void processAttributeExtensions(EObject object)
           
protected  boolean processElementExtensions(EObject object)
          Returns true if there were extensions for the specified object.
protected  int sameDocMany(EObject o, EStructuralFeature f)
           
protected  int sameDocSingle(EObject o, EStructuralFeature f)
           
 Document save(XMLResource resource, Document doc, Map options, DOMHandler handler)
           
 void save(XMLResource resource, OutputStream outputStream, Map options)
           
 void save(XMLResource resource, Writer writer, Map options)
          Saves the resource to the writer using the specified options.
protected  void saveAttributeFeatureMap(EObject o, EStructuralFeature f)
           
protected  void saveContainedMany(EObject o, EStructuralFeature f)
           
protected  void saveContainedSingle(EObject o, EStructuralFeature f)
           
protected  void saveDataTypeAttributeMany(EObject o, EStructuralFeature f)
           
protected  void saveDataTypeElementSingle(EObject o, EStructuralFeature f)
           
protected  void saveDataTypeMany(EObject o, EStructuralFeature f)
           
protected  void saveDataTypeSingle(EObject o, EStructuralFeature f)
           
protected  void saveElement(EObject o, EStructuralFeature f)
           
protected  void saveElement(InternalEObject o, EStructuralFeature f)
           
protected  boolean saveElementFeatureMap(EObject o, EStructuralFeature f)
           
protected  void saveElementID(EObject o)
           
protected  void saveElementIDRef(EObject o, EObject target, EStructuralFeature f)
           
protected  void saveElementIDRef(EObject target, EStructuralFeature f)
           
protected  void saveElementIDRefMany(EObject o, EStructuralFeature f)
           
protected  void saveElementIDRefSingle(EObject o, EStructuralFeature f)
           
protected  void saveElementReference(EObject remote, EStructuralFeature f)
           
protected  void saveElementReferenceMany(EObject o, EStructuralFeature f)
           
protected  void saveElementReferenceSingle(EObject o, EStructuralFeature f)
           
protected  void saveEObjectMany(EObject o, EStructuralFeature f)
           
protected  void saveEObjectSingle(EObject o, EStructuralFeature f)
           
protected  void saveFeatureMapElementReference(EObject o, EReference f)
           
protected  boolean saveFeatures(EObject o)
           
protected  void saveHref(EObject remote, EStructuralFeature f)
           
protected  void saveHRefMany(EObject o, EStructuralFeature f)
           
protected  void saveHRefSingle(EObject o, EStructuralFeature f)
           
protected  void saveIDRefMany(EObject o, EStructuralFeature f)
           
protected  void saveIDRefSingle(EObject o, EStructuralFeature f)
           
protected  void saveManyEmpty(EObject o, EStructuralFeature f)
           
protected  void saveManyEmpty(EStructuralFeature f)
           
protected  void saveNil(EObject o, EStructuralFeature f)
           
protected  void saveNil(EStructuralFeature f)
           
protected  void saveTypeAttribute(EClass eClass)
           
protected  void saveTypeAttribute(EDataType eDataType)
           
 char[] toChar()
           
 void traverse(List contents)
           
 void write(OutputStreamWriter os)
          Deprecated. since 2.2 - instead use #write(Writer)
 void write(Writer os)
           
 void writeAscii(OutputStream os)
           
protected  void writeTopAttributes(EObject top)
           
protected  boolean writeTopElements(EObject top)
           
protected  Object writeTopObject(EObject top)
           
protected  Object writeTopObjects(List contents)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDEX_LOOKUP

protected static final int INDEX_LOOKUP
See Also:
Constant Field Values

helper

protected XMLHelper helper

doc

protected XMLString doc

declareXSI

protected boolean declareXSI

useEncodedAttributeStyle

protected boolean useEncodedAttributeStyle

declareXML

protected boolean declareXML

saveTypeInfo

protected boolean saveTypeInfo

xmlTypeInfo

protected XMLSave.XMLTypeInfo xmlTypeInfo

keepDefaults

protected boolean keepDefaults

escape

protected XMLSaveImpl.Escape escape

escapeURI

protected XMLSaveImpl.Escape escapeURI

featureTable

protected XMLSaveImpl.Lookup featureTable

encoding

protected String encoding

xmlVersion

protected String xmlVersion

idAttributeName

protected String idAttributeName

idAttributeNS

protected String idAttributeNS

processDanglingHREF

protected String processDanglingHREF

declareSchemaLocation

protected boolean declareSchemaLocation

declareSchemaLocationImplementation

protected boolean declareSchemaLocationImplementation

map

protected XMLResource.XMLMap map

extendedMetaData

protected ExtendedMetaData extendedMetaData

anySimpleType

protected EClass anySimpleType

anyType

protected EClass anyType

eObjectToExtensionMap

protected Map eObjectToExtensionMap

xmlSchemaTypePackage

protected EPackage xmlSchemaTypePackage

flushThreshold

protected int flushThreshold

toDOM

protected boolean toDOM

handler

protected DOMHandler handler

document

protected Document document

currentNode

protected Node currentNode

nameInfo

protected NameInfo nameInfo

useCache

protected boolean useCache

root

protected EObject root

xmlResource

protected XMLResource xmlResource

SKIP

protected static final int SKIP
See Also:
Constant Field Values

SAME_DOC

protected static final int SAME_DOC
See Also:
Constant Field Values

CROSS_DOC

protected static final int CROSS_DOC
See Also:
Constant Field Values

TRANSIENT

protected static final int TRANSIENT
See Also:
Constant Field Values

DATATYPE_SINGLE

protected static final int DATATYPE_SINGLE
See Also:
Constant Field Values

DATATYPE_ELEMENT_SINGLE

protected static final int DATATYPE_ELEMENT_SINGLE
See Also:
Constant Field Values

DATATYPE_CONTENT_SINGLE

protected static final int DATATYPE_CONTENT_SINGLE
See Also:
Constant Field Values

DATATYPE_SINGLE_NILLABLE

protected static final int DATATYPE_SINGLE_NILLABLE
See Also:
Constant Field Values

DATATYPE_MANY

protected static final int DATATYPE_MANY
See Also:
Constant Field Values

OBJECT_CONTAIN_SINGLE

protected static final int OBJECT_CONTAIN_SINGLE
See Also:
Constant Field Values

OBJECT_CONTAIN_MANY

protected static final int OBJECT_CONTAIN_MANY
See Also:
Constant Field Values

OBJECT_HREF_SINGLE

protected static final int OBJECT_HREF_SINGLE
See Also:
Constant Field Values

OBJECT_HREF_MANY

protected static final int OBJECT_HREF_MANY
See Also:
Constant Field Values

OBJECT_CONTAIN_SINGLE_UNSETTABLE

protected static final int OBJECT_CONTAIN_SINGLE_UNSETTABLE
See Also:
Constant Field Values

OBJECT_CONTAIN_MANY_UNSETTABLE

protected static final int OBJECT_CONTAIN_MANY_UNSETTABLE
See Also:
Constant Field Values

OBJECT_HREF_SINGLE_UNSETTABLE

protected static final int OBJECT_HREF_SINGLE_UNSETTABLE
See Also:
Constant Field Values

OBJECT_HREF_MANY_UNSETTABLE

protected static final int OBJECT_HREF_MANY_UNSETTABLE
See Also:
Constant Field Values

OBJECT_ELEMENT_SINGLE

protected static final int OBJECT_ELEMENT_SINGLE
See Also:
Constant Field Values

OBJECT_ELEMENT_SINGLE_UNSETTABLE

protected static final int OBJECT_ELEMENT_SINGLE_UNSETTABLE
See Also:
Constant Field Values

OBJECT_ELEMENT_MANY

protected static final int OBJECT_ELEMENT_MANY
See Also:
Constant Field Values

OBJECT_ELEMENT_IDREF_SINGLE

protected static final int OBJECT_ELEMENT_IDREF_SINGLE
See Also:
Constant Field Values

OBJECT_ELEMENT_IDREF_SINGLE_UNSETTABLE

protected static final int OBJECT_ELEMENT_IDREF_SINGLE_UNSETTABLE
See Also:
Constant Field Values

OBJECT_ELEMENT_IDREF_MANY

protected static final int OBJECT_ELEMENT_IDREF_MANY
See Also:
Constant Field Values

ATTRIBUTE_FEATURE_MAP

protected static final int ATTRIBUTE_FEATURE_MAP
See Also:
Constant Field Values

ELEMENT_FEATURE_MAP

protected static final int ELEMENT_FEATURE_MAP
See Also:
Constant Field Values

OBJECT_ATTRIBUTE_SINGLE

protected static final int OBJECT_ATTRIBUTE_SINGLE
See Also:
Constant Field Values

OBJECT_ATTRIBUTE_MANY

protected static final int OBJECT_ATTRIBUTE_MANY
See Also:
Constant Field Values

OBJECT_ATTRIBUTE_IDREF_SINGLE

protected static final int OBJECT_ATTRIBUTE_IDREF_SINGLE
See Also:
Constant Field Values

OBJECT_ATTRIBUTE_IDREF_MANY

protected static final int OBJECT_ATTRIBUTE_IDREF_MANY
See Also:
Constant Field Values

DATATYPE_ATTRIBUTE_MANY

protected static final int DATATYPE_ATTRIBUTE_MANY
See Also:
Constant Field Values

XML_VERSION

protected static final String XML_VERSION
See Also:
Constant Field Values

XSI_NIL

protected static final String XSI_NIL
See Also:
Constant Field Values

XSI_TYPE_NS

protected static final String XSI_TYPE_NS
See Also:
Constant Field Values

XSI_XMLNS

protected static final String XSI_XMLNS
See Also:
Constant Field Values

XSI_SCHEMA_LOCATION

protected static final String XSI_SCHEMA_LOCATION
See Also:
Constant Field Values

XSI_NO_NAMESPACE_SCHEMA_LOCATION

protected static final String XSI_NO_NAMESPACE_SCHEMA_LOCATION
See Also:
Constant Field Values

EMPTY_ELEMENT

protected static final int EMPTY_ELEMENT
See Also:
Constant Field Values

CONTENT_ELEMENT

protected static final int CONTENT_ELEMENT
See Also:
Constant Field Values
Constructor Detail

XMLSaveImpl

public XMLSaveImpl(XMLHelper helper)

XMLSaveImpl

public XMLSaveImpl(Map options,
                   XMLHelper helper,
                   String encoding)
Constructor for XMLSave.

Parameters:
options -
helper -
encoding -

XMLSaveImpl

public XMLSaveImpl(Map options,
                   XMLHelper helper,
                   String encoding,
                   String xmlVersion)
Method Detail

save

public Document save(XMLResource resource,
                     Document doc,
                     Map options,
                     DOMHandler handler)
Specified by:
save in interface XMLSave
Parameters:
resource - a resource
doc - a Document (must not be null)
options - options
handler - a DOMHandler (must not be null)
Returns:
the document

save

public void save(XMLResource resource,
                 Writer writer,
                 Map options)
          throws IOException
Description copied from interface: XMLSave
Saves the resource to the writer using the specified options.

Specified by:
save in interface XMLSave
Parameters:
resource -
writer -
options -
Throws:
IOException

save

public void save(XMLResource resource,
                 OutputStream outputStream,
                 Map options)
          throws IOException
Specified by:
save in interface XMLSave
Throws:
IOException

init

protected void init(XMLResource resource,
                    Map options)

traverse

public void traverse(List contents)

writeTopAttributes

protected void writeTopAttributes(EObject top)

writeTopElements

protected boolean writeTopElements(EObject top)

writeTopObject

protected Object writeTopObject(EObject top)

writeTopObjects

protected Object writeTopObjects(List contents)

addNamespaceDeclarations

protected void addNamespaceDeclarations()

getSchemaLocationRoot

protected EObject getSchemaLocationRoot(EObject eObject)

isDuplicateURI

public boolean isDuplicateURI(String nsURI)

write

public void write(OutputStreamWriter os)
           throws IOException
Deprecated. since 2.2 - instead use #write(Writer)

Parameters:
os -
Throws:
IOException

write

public void write(Writer os)
           throws IOException
Throws:
IOException

writeAscii

public void writeAscii(OutputStream os)
                throws IOException
Throws:
IOException

toChar

public char[] toChar()

saveElement

protected void saveElement(InternalEObject o,
                           EStructuralFeature f)

saveElement

protected void saveElement(EObject o,
                           EStructuralFeature f)

saveTypeAttribute

protected void saveTypeAttribute(EClass eClass)

saveTypeAttribute

protected void saveTypeAttribute(EDataType eDataType)

saveFeatures

protected boolean saveFeatures(EObject o)

endSaveFeatures

protected void endSaveFeatures(EObject o,
                               int elementType,
                               String content)

processElementExtensions

protected boolean processElementExtensions(EObject object)
Returns true if there were extensions for the specified object.


processAttributeExtensions

protected void processAttributeExtensions(EObject object)

saveDataTypeSingle

protected void saveDataTypeSingle(EObject o,
                                  EStructuralFeature f)

isNil

protected boolean isNil(EObject o,
                        EStructuralFeature f)

isEmpty

protected boolean isEmpty(EObject o,
                          EStructuralFeature f)

saveNil

protected void saveNil(EObject o,
                       EStructuralFeature f)

saveNil

protected void saveNil(EStructuralFeature f)

saveManyEmpty

protected void saveManyEmpty(EObject o,
                             EStructuralFeature f)

saveManyEmpty

protected void saveManyEmpty(EStructuralFeature f)

saveDataTypeMany

protected void saveDataTypeMany(EObject o,
                                EStructuralFeature f)

saveDataTypeAttributeMany

protected void saveDataTypeAttributeMany(EObject o,
                                         EStructuralFeature f)

saveEObjectSingle

protected void saveEObjectSingle(EObject o,
                                 EStructuralFeature f)

saveEObjectMany

protected void saveEObjectMany(EObject o,
                               EStructuralFeature f)

saveIDRefSingle

protected void saveIDRefSingle(EObject o,
                               EStructuralFeature f)

saveIDRefMany

protected void saveIDRefMany(EObject o,
                             EStructuralFeature f)

saveElementReference

protected void saveElementReference(EObject remote,
                                    EStructuralFeature f)

saveElementReferenceSingle

protected void saveElementReferenceSingle(EObject o,
                                          EStructuralFeature f)

saveElementReferenceMany

protected void saveElementReferenceMany(EObject o,
                                        EStructuralFeature f)

getElementReferenceSingleSimple

protected String getElementReferenceSingleSimple(EObject o,
                                                 EStructuralFeature f)

getElementReferenceManySimple

protected String getElementReferenceManySimple(EObject o,
                                               EStructuralFeature f)

saveElementIDRef

protected void saveElementIDRef(EObject o,
                                EObject target,
                                EStructuralFeature f)

saveElementIDRef

protected void saveElementIDRef(EObject target,
                                EStructuralFeature f)

saveElementIDRefSingle

protected void saveElementIDRefSingle(EObject o,
                                      EStructuralFeature f)

saveElementIDRefMany

protected void saveElementIDRefMany(EObject o,
                                    EStructuralFeature f)

getElementIDRefSingleSimple

protected String getElementIDRefSingleSimple(EObject o,
                                             EStructuralFeature f)

getElementIDRefManySimple

protected String getElementIDRefManySimple(EObject o,
                                           EStructuralFeature f)

saveHref

protected void saveHref(EObject remote,
                        EStructuralFeature f)

saveHRefSingle

protected void saveHRefSingle(EObject o,
                              EStructuralFeature f)

saveHRefMany

protected void saveHRefMany(EObject o,
                            EStructuralFeature f)

saveContainedSingle

protected void saveContainedSingle(EObject o,
                                   EStructuralFeature f)

saveContainedMany

protected void saveContainedMany(EObject o,
                                 EStructuralFeature f)

saveFeatureMapElementReference

protected void saveFeatureMapElementReference(EObject o,
                                              EReference f)

saveElementFeatureMap

protected boolean saveElementFeatureMap(EObject o,
                                        EStructuralFeature f)

saveAttributeFeatureMap

protected void saveAttributeFeatureMap(EObject o,
                                       EStructuralFeature f)

sameDocSingle

protected int sameDocSingle(EObject o,
                            EStructuralFeature f)

sameDocMany

protected int sameDocMany(EObject o,
                          EStructuralFeature f)

getContent

protected String getContent(EObject o,
                            EStructuralFeature[] features)

saveDataTypeElementSingle

protected void saveDataTypeElementSingle(EObject o,
                                         EStructuralFeature f)

getDataTypeElementSingleSimple

protected String getDataTypeElementSingleSimple(EObject o,
                                                EStructuralFeature f)

saveElementID

protected void saveElementID(EObject o)

getDatatypeValue

protected String getDatatypeValue(Object value,
                                  EStructuralFeature f,
                                  boolean isAttribute)

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.