|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.emf.common.notify.impl.BasicNotifierImpl org.eclipse.emf.common.notify.impl.NotifierImpl org.eclipse.emf.ecore.resource.impl.ResourceImpl org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl
public class XMLResourceImpl
This class implements the XMLResource interface. It overloads the doLoad method to invoke the XML deserializer rather than using the default XMI loader.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.eclipse.emf.ecore.resource.impl.ResourceImpl |
---|
ResourceImpl.ContentsEList<E extends java.lang.Object & EObject>, ResourceImpl.ModificationTrackingAdapter |
Nested classes/interfaces inherited from class org.eclipse.emf.common.notify.impl.BasicNotifierImpl |
---|
BasicNotifierImpl.EAdapterList<E extends java.lang.Object & Adapter> |
Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.xmi.XMLResource |
---|
XMLResource.ElementHandler, XMLResource.ResourceEntityHandler, XMLResource.ResourceHandler, XMLResource.URIHandler, XMLResource.XMLInfo, XMLResource.XMLMap |
Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.resource.Resource |
---|
Resource.Diagnostic, Resource.Factory, Resource.Internal, Resource.IOWrappedException |
Field Summary | |
---|---|
protected static java.util.Map<EObject,java.lang.String> |
DETACHED_EOBJECT_TO_ID_MAP
The map from EObject to ID . |
protected DOMHandler |
domHandler
|
protected java.lang.String |
encoding
|
protected java.util.Map<EObject,AnyType> |
eObjectToExtensionMap
|
protected java.util.Map<EObject,java.lang.String> |
eObjectToIDMap
The map from EObject to ID . |
protected java.util.Map<java.lang.String,EObject> |
idToEObjectMap
The map from ID to EObject . |
protected java.lang.String |
publicId
|
protected java.lang.String |
systemId
|
protected boolean |
useZip
|
protected java.lang.String |
xmlVersion
|
Fields inherited from class org.eclipse.emf.ecore.resource.impl.ResourceImpl |
---|
contents, defaultDeleteOptions, defaultLoadOptions, defaultSaveOptions, errors, intrinsicIDToEObjectMap, isLoaded, isLoading, isModified, modificationTrackingAdapter, resourceSet, timeStamp, unloadingContents, uri, warnings |
Fields inherited from class org.eclipse.emf.common.notify.impl.NotifierImpl |
---|
eAdapters, EDELIVER, eFlags, ELAST_NOTIFIER_FLAG |
Fields inherited from interface org.eclipse.emf.ecore.resource.Resource |
---|
OPTION_CIPHER, OPTION_SAVE_ONLY_IF_CHANGED, OPTION_SAVE_ONLY_IF_CHANGED_FILE_BUFFER, OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER, OPTION_ZIP, RESOURCE__CONTENTS, RESOURCE__ERRORS, RESOURCE__IS_LOADED, RESOURCE__IS_MODIFIED, RESOURCE__IS_TRACKING_MODIFICATION, RESOURCE__RESOURCE_SET, RESOURCE__TIME_STAMP, RESOURCE__URI, RESOURCE__WARNINGS |
Constructor Summary | |
---|---|
XMLResourceImpl()
Constructor for XMLResourceImpl. |
|
XMLResourceImpl(URI uri)
Constructor for XMLResourceImpl. |
Method Summary | |
---|---|
protected boolean |
assignIDsWhileLoading()
|
protected void |
attachedHelper(EObject eObject)
|
protected XMLHelper |
createXMLHelper()
|
protected XMLLoad |
createXMLLoad()
|
protected XMLSave |
createXMLSave()
|
protected void |
detachedHelper(EObject eObject)
|
void |
doLoad(org.xml.sax.InputSource inputSource,
java.util.Map<?,?> options)
|
void |
doLoad(java.io.InputStream inputStream,
java.util.Map<?,?> options)
Called to load the resource. |
void |
doLoad(org.w3c.dom.Node node,
java.util.Map<?,?> options)
|
void |
doSave(java.io.OutputStream outputStream,
java.util.Map<?,?> options)
Called to save the resource. |
void |
doSave(java.io.Writer writer,
java.util.Map<?,?> options)
|
protected void |
doUnload()
Does all the work of unloading the resource. |
java.util.Map<java.lang.Object,java.lang.Object> |
getDefaultLoadOptions()
Returns the map of options that, in addition to the overriding options specified during load, are used to to control load behavior. |
java.util.Map<java.lang.Object,java.lang.Object> |
getDefaultSaveOptions()
Returns the map of options that, in addition to the overriding options specified during save, are used to to control save behavior. |
DOMHelper |
getDOMHelper()
Returns the DOMHelper |
java.lang.String |
getEncoding()
Get the XML encoding for this resource. |
protected EObject |
getEObjectByID(java.lang.String id)
Returns the object based on the fragment as an ID. |
java.util.Map<EObject,AnyType> |
getEObjectToExtensionMap()
Returns the map with EObject as keys and corresponding AnyType s as the values. |
java.util.Map<EObject,java.lang.String> |
getEObjectToIDMap()
Returns the Map of EObjects as keys and IDs as values. |
java.lang.String |
getID(EObject eObject)
Returns the ID that was assigned with XMLResource.setID(EObject, String) ; if there is
no ID, it returns null. |
java.util.Map<java.lang.String,EObject> |
getIDToEObjectMap()
Returns the Map with IDs as keys and EObjects as values. |
java.lang.String |
getPublicId()
Returns public identifier specified on the doctype. |
java.lang.String |
getSystemId()
Returns system identifier specified on the doctype. |
java.lang.String |
getURIFragment(EObject eObject)
Returns the URI fragment that,
when passed to getEObject will return the given object. |
java.lang.String |
getXMLVersion()
Returns the XML version for this resource. |
protected void |
init()
|
protected boolean |
isAttachedDetachedHelperRequired()
|
protected boolean |
isPath(java.lang.String uriFragment)
|
void |
load(org.xml.sax.InputSource inputSource,
java.util.Map<?,?> options)
|
void |
load(org.w3c.dom.Node node,
java.util.Map<?,?> options)
Loads the resource from the DOM node, either an Element or Document, using the specified options. |
org.w3c.dom.Document |
save(org.w3c.dom.Document doc,
java.util.Map<?,?> options,
DOMHandler handler)
Create a DOM tree representing contents of this resource. |
void |
save(java.io.Writer writer,
java.util.Map<?,?> options)
Saves the resource to the writer using the specified options. |
void |
setDoctypeInfo(java.lang.String publicId,
java.lang.String systemId)
Sets the values of system and public identifiers on this resource. |
void |
setEncoding(java.lang.String encoding)
Set the XML encoding for this resource. |
void |
setID(EObject eObject,
java.lang.String id)
Sets the ID of the object. |
void |
setUseZip(boolean useZip)
Set whether the contents will be zipped. |
void |
setXMLVersion(java.lang.String version)
Set the XML version for this resource |
java.lang.String |
toKeyString()
Returns a string representation of the ID map. |
protected boolean |
useIDAttributes()
|
protected boolean |
useIDs()
|
protected boolean |
useUUIDs()
|
boolean |
useZip()
Returns whether contents will be compressed. |
Methods inherited from class org.eclipse.emf.common.notify.impl.NotifierImpl |
---|
eAdapters, eBasicAdapters, eDeliver, eSetDeliver |
Methods inherited from class org.eclipse.emf.common.notify.impl.BasicNotifierImpl |
---|
eNotificationRequired, eNotify |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.emf.ecore.resource.Resource |
---|
delete, getAllContents, getContents, getEObject, getErrors, getResourceSet, getTimeStamp, getURI, getWarnings, isLoaded, isModified, isTrackingModification, load, load, save, save, setModified, setTimeStamp, setTrackingModification, setURI, unload |
Methods inherited from interface org.eclipse.emf.common.notify.Notifier |
---|
eAdapters, eDeliver, eNotify, eSetDeliver |
Field Detail |
---|
protected java.util.Map<java.lang.String,EObject> idToEObjectMap
ID
to EObject
.
It is used to store IDs during a load or if the user
sets the ID of an object.
protected java.util.Map<EObject,java.lang.String> eObjectToIDMap
EObject
to ID
.
It is used to store IDs during a load or if the user
sets the ID of an object.
protected java.util.Map<EObject,AnyType> eObjectToExtensionMap
protected java.lang.String encoding
protected java.lang.String xmlVersion
protected boolean useZip
protected java.lang.String publicId
protected java.lang.String systemId
protected DOMHandler domHandler
protected static final java.util.Map<EObject,java.lang.String> DETACHED_EOBJECT_TO_ID_MAP
EObject
to ID
. It is used to store
IDs for objects that have been detached.
Constructor Detail |
---|
public XMLResourceImpl()
public XMLResourceImpl(URI uri)
uri
- Method Detail |
---|
protected void init()
protected boolean useIDs()
protected boolean useIDAttributes()
protected boolean useUUIDs()
protected boolean assignIDsWhileLoading()
public java.util.Map<java.lang.Object,java.lang.Object> getDefaultSaveOptions()
XMLResource
getDefaultSaveOptions
in interface XMLResource
public java.util.Map<java.lang.Object,java.lang.Object> getDefaultLoadOptions()
XMLResource
getDefaultLoadOptions
in interface XMLResource
protected XMLHelper createXMLHelper()
protected XMLLoad createXMLLoad()
protected XMLSave createXMLSave()
public void doLoad(java.io.InputStream inputStream, java.util.Map<?,?> options) throws java.io.IOException
ResourceImpl
doLoad
in class ResourceImpl
inputStream
- the streamoptions
- the load options.
java.io.IOException
public void doSave(java.io.OutputStream outputStream, java.util.Map<?,?> options) throws java.io.IOException
ResourceImpl
doSave
in class ResourceImpl
outputStream
- the streamoptions
- the save options.
java.io.IOException
public final void save(java.io.Writer writer, java.util.Map<?,?> options) throws java.io.IOException
This implementation is final
;
clients should override doSave
.
save
in interface XMLResource
writer
- the writeroptions
- the save options.
java.io.IOException
doSave(Writer, Map)
public void doSave(java.io.Writer writer, java.util.Map<?,?> options) throws java.io.IOException
java.io.IOException
public org.w3c.dom.Document save(org.w3c.dom.Document doc, java.util.Map<?,?> options, DOMHandler handler)
XMLResource
save
in interface XMLResource
doc
- an empty Document
to use or null. If no document is specified, the
new Document
will be created using JAXP API.options
- the "save" optionshandler
- the DOMHandler
to record mappings or null.
If no DOMHandler is passed, the default DOMHandler will be created.
Document
. In the case the document is specified as a parameter,
the returned document is the same as the one specified, otherwise the newly created document is returned.public DOMHelper getDOMHelper()
XMLResource
DOMHelper
getDOMHelper
in interface XMLResource
public boolean useZip()
ResourceImpl
false
.
When this returns true
,
ResourceImpl.save(OutputStream, Map)
and ResourceImpl.load(InputStream, Map)
will zip compress and decompress contents.
useZip
in interface XMLResource
useZip
in class ResourceImpl
ResourceImpl.newContentZipEntry()
,
ResourceImpl.isContentZipEntry(ZipEntry)
public void setUseZip(boolean useZip)
XMLResource
setUseZip
in interface XMLResource
public java.lang.String getPublicId()
XMLResource
getPublicId
in interface XMLResource
public java.lang.String getSystemId()
XMLResource
getSystemId
in interface XMLResource
public void setDoctypeInfo(java.lang.String publicId, java.lang.String systemId)
XMLResource
setDoctypeInfo
in interface XMLResource
public java.lang.String getEncoding()
XMLResource
getEncoding
in interface XMLResource
public void setEncoding(java.lang.String encoding)
XMLResource
setEncoding
in interface XMLResource
public java.lang.String getXMLVersion()
XMLResource
getXMLVersion
in interface XMLResource
public void setXMLVersion(java.lang.String version)
XMLResource
setXMLVersion
in interface XMLResource
public java.util.Map<java.lang.String,EObject> getIDToEObjectMap()
XMLResource
getIDToEObjectMap
in interface XMLResource
public java.util.Map<EObject,java.lang.String> getEObjectToIDMap()
XMLResource
getEObjectToIDMap
in interface XMLResource
public java.util.Map<EObject,AnyType> getEObjectToExtensionMap()
XMLResource
EObject
as keys and corresponding AnyType
s as the values.
It's used to record unrecognized elements and attributes.
getEObjectToExtensionMap
in interface XMLResource
public java.lang.String getID(EObject eObject)
XMLResource
XMLResource.setID(EObject, String)
; if there is
no ID, it returns null.
getID
in interface XMLResource
public void setID(EObject eObject, java.lang.String id)
eObjectToIDMap
.
Clients may override it to set the ID as an actual attribute object the object.
setID
in interface XMLResource
eObject
- the object.id
- the object's ID.public java.lang.String getURIFragment(EObject eObject)
Resource
fragment
that,
when passed to getEObject
will return the given object.
In other words,
the following is true
for any object contained by a resource:
Resource resource = eObject.eResource(); eObject == resource.getEObject(resource.getURIFragment(eObject))An implementation may choose to use IDs or to use structured URI fragments, as supported by
eURIFragmentSegment
.
getURIFragment
in interface Resource
getURIFragment
in class ResourceImpl
eObject
- the object to identify.
fragment
for the object.Resource.getEObject(String)
,
InternalEObject.eURIFragmentSegment(org.eclipse.emf.ecore.EStructuralFeature, EObject)
protected EObject getEObjectByID(java.lang.String id)
ResourceImpl
getEObjectByID
in class ResourceImpl
protected boolean isPath(java.lang.String uriFragment)
protected boolean isAttachedDetachedHelperRequired()
isAttachedDetachedHelperRequired
in class ResourceImpl
protected void attachedHelper(EObject eObject)
attachedHelper
in class ResourceImpl
protected void detachedHelper(EObject eObject)
detachedHelper
in class ResourceImpl
protected void doUnload()
idToEObjectMap
and eObjectToIDMap
as necessary.
doUnload
in class ResourceImpl
public java.lang.String toKeyString()
ID
map.
toKeyString
in class ResourceImpl
public final void load(org.w3c.dom.Node node, java.util.Map<?,?> options) throws java.io.IOException
XMLResource
This method assumes that no namespace fixup needs to be done. To process comments and CDATA section nodes, please set XMLResource.OPTION_USE_LEXICAL_HANDLER option to Boolean.TRUE.
load
in interface XMLResource
node
- DOM Element or Document node.options
- the load options.
java.io.IOException
XMLResource.save(Document, Map, DOMHandler)
public void doLoad(org.w3c.dom.Node node, java.util.Map<?,?> options) throws java.io.IOException
java.io.IOException
public final void load(org.xml.sax.InputSource inputSource, java.util.Map<?,?> options) throws java.io.IOException
load
in interface XMLResource
java.io.IOException
public void doLoad(org.xml.sax.InputSource inputSource, java.util.Map<?,?> options) throws java.io.IOException
java.io.IOException
|
Copyright 2001-2006 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |