|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.emf.ecore.xmi.impl.XMLHelperImpl
public class XMLHelperImpl
This class handles the package to use when there is no XML namespace in an XML file.
Nested Class Summary | |
---|---|
protected static class |
XMLHelperImpl.NamespaceSupport
A helper to encode namespace prefix mappings. |
Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.xmi.XMLHelper |
---|
XMLHelper.ManyReference |
Field Summary | |
---|---|
protected java.util.List<java.lang.String> |
allPrefixToURI
|
protected java.util.Map<java.lang.String,java.lang.String> |
anyPrefixesToURIs
|
protected EClass |
anySimpleType
|
protected boolean |
checkForDuplicates
|
protected DanglingHREFException |
danglingHREFException
|
protected boolean |
deresolve
|
protected ExtendedMetaData |
extendedMetaData
|
protected java.util.Map<EStructuralFeature,java.lang.Integer> |
featuresToKinds
|
protected java.lang.String[] |
fragmentPrefixes
|
protected static java.lang.Integer |
INTEGER_DATATYPE_IS_MANY
|
protected static java.lang.Integer |
INTEGER_DATATYPE_SINGLE
|
protected static java.lang.Integer |
INTEGER_IS_MANY_ADD
|
protected static java.lang.Integer |
INTEGER_IS_MANY_MOVE
|
protected static java.lang.Integer |
INTEGER_OTHER
|
protected boolean |
laxFeatureProcessing
|
protected boolean |
mustHavePrefix
|
protected XMLHelperImpl.NamespaceSupport |
namespaceSupport
|
protected EPackage |
noNamespacePackage
|
protected EPackage.Registry |
packageRegistry
|
protected java.util.Map<EPackage,java.lang.String> |
packages
|
protected EMap<java.lang.String,java.lang.String> |
prefixesToURIs
|
protected java.lang.String |
processDanglingHREF
|
protected XMLResource |
resource
|
protected URI |
resourceURI
|
protected java.util.List<? extends EObject> |
roots
|
protected boolean |
seenEmptyStringMapping
|
protected XMLResource.URIHandler |
uriHandler
|
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
urisToPrefixes
|
protected XMLResource.XMLMap |
xmlMap
|
protected EPackage |
xmlSchemaTypePackage
|
Fields inherited from interface org.eclipse.emf.ecore.xmi.XMLHelper |
---|
DATATYPE_IS_MANY, DATATYPE_SINGLE, IS_MANY_ADD, IS_MANY_MOVE, OTHER |
Constructor Summary | |
---|---|
XMLHelperImpl()
|
|
XMLHelperImpl(XMLResource resource)
|
Method Summary | |
---|---|
protected void |
addNSDeclaration(java.lang.String prefix,
java.lang.String uri)
|
void |
addPrefix(java.lang.String prefix,
java.lang.String uri)
Records the prefix to URI mapping while loading an XML document. |
protected void |
computeFeatureKind(EStructuralFeature feature)
|
java.lang.String |
convertToString(EFactory factory,
EDataType dataType,
java.lang.Object value)
Converts the given data value to a string while saving an XML document. |
protected java.lang.Object |
createFromString(EFactory eFactory,
EDataType eDataType,
java.lang.String value)
|
EObject |
createObject(EFactory eFactory,
EClassifier type)
Create an object given an EFactory and a type |
EObject |
createObject(EFactory eFactory,
java.lang.String classXMIName)
Deprecated. since 2.2 |
URI |
deresolve(URI uri)
Returns a relative URI if necessary and if possible. |
java.util.Map<java.lang.String,java.lang.String> |
getAnyContentPrefixToURIMapping()
Returns a map of prefixes to URI mapping for elements with any content |
DanglingHREFException |
getDanglingHREFException()
|
ExtendedMetaData |
getExtendedMetaData()
Gets the ExtendedMetaData to use when serializing an XML file. |
EStructuralFeature |
getFeature(EClass eClass,
java.lang.String namespaceURI,
java.lang.String name)
Returns the structural feature for the XML element/attribute with the given namespaceURI and name. |
EStructuralFeature |
getFeature(EClass eClass,
java.lang.String namespaceURI,
java.lang.String name,
boolean isElement)
Returns the structural feature for the XML element/attribute with the given namespaceURI and name. |
int |
getFeatureKind(EStructuralFeature feature)
Return the kind of feature. |
protected EStructuralFeature |
getFeatureWithoutMap(EClass eClass,
java.lang.String name)
|
java.lang.String |
getHREF(EObject obj)
Returns an HREF to this object from this resource |
protected URI |
getHREF(Resource otherResource,
EObject obj)
|
java.lang.String |
getID(EObject obj)
Returns the xmi:id or null to supress |
java.lang.String |
getIDREF(EObject obj)
Returns an IDREF to this object |
java.lang.String |
getJavaEncoding(java.lang.String xmlEncoding)
Return a Java encoding corresponding to the given XML encoding. |
java.lang.String |
getName(ENamedElement obj)
Returns the XML name of the ENamedElement |
java.lang.String |
getNamespaceURI(java.lang.String prefix)
Returns the namespaceURI in scope for the prefix. |
EPackage |
getNoNamespacePackage()
Gets the package to use when there is no XML namespace in an XML file. |
java.lang.String |
getPrefix(EPackage ePackage)
Return the prefix used for this package. |
protected java.lang.String |
getPrefix(EPackage ePackage,
boolean mustHavePrefix)
|
java.lang.String |
getPrefix(java.lang.String namespaceURI)
|
java.util.List<java.lang.String> |
getPrefixes(EPackage ePackage)
Return all the prefixes used for this package. |
EMap<java.lang.String,java.lang.String> |
getPrefixToNamespaceMap()
|
java.lang.String |
getQName(EClass c)
Returns the nsName:name c.ePackage().nsName() : c.eName() If there is an XMLMap, and the target namespace is null for this eClass, just the name is returned. |
java.lang.String |
getQName(EDataType c)
Returns the nsName:name c.ePackage().nsName() : c.eName() If there is an XMLMap, and the target namespace is null for this eClass, just the name is returned. |
protected java.lang.String |
getQName(EPackage ePackage,
java.lang.String name)
|
protected java.lang.String |
getQName(EPackage ePackage,
java.lang.String name,
boolean mustHavePrefix)
|
java.lang.String |
getQName(EStructuralFeature feature)
By default, this method returns the name of the feature. |
protected java.lang.String |
getQName(NameInfo nameInfo,
EPackage ePackage,
java.lang.String name)
|
protected java.lang.String |
getQName(NameInfo nameInfo,
EPackage ePackage,
java.lang.String name,
boolean mustHavePrefix)
|
protected java.lang.String |
getQName(java.lang.String uri,
java.lang.String name)
|
XMLResource |
getResource()
Returns the resource |
EClassifier |
getType(EFactory eFactory,
java.lang.String typeName)
Given an EFactory and a type name, find and return the type |
java.lang.String |
getURI(java.lang.String prefix)
Returns the namespace prefix that's in effect while loading an XML document. |
protected java.lang.String |
getURIFragment(Resource containingResource,
EObject object)
|
protected java.lang.String |
getURIFragmentQuery(Resource containingResource,
EObject object)
|
java.lang.Object |
getValue(EObject obj,
EStructuralFeature f)
Returns the XMI value of the EObject's feature |
java.lang.String |
getXMLEncoding(java.lang.String javaEncoding)
Return an XML encoding corresponding to the given Java encoding. |
XMLResource.XMLMap |
getXMLMap()
Gets the XMLMap to use when serializing an XML file. |
protected URI |
handleDanglingHREF(EObject object)
|
EPackage[] |
packages()
Returns the packages in getQName() |
void |
popContext()
Reverts to the previous namespace context while loading XML document. |
void |
popContext(java.util.Map<java.lang.String,EFactory> prefixesToFactories)
Reverts to the previous namespace context while loading XML document and removes from the map, prefixes that have gone out of scope. |
void |
populateNameInfo(NameInfo nameInfo,
EClass c)
This method populates the given NameInfo with name information, resetting all the current
values in the nameInfo |
void |
populateNameInfo(NameInfo nameInfo,
EDataType eDataType)
This method populates the given NameInfo with name information, resetting all the current
values in the nameInfo |
void |
populateNameInfo(NameInfo nameInfo,
EStructuralFeature feature)
This method populates the given NameInfo with name information, resetting all the current
values in the nameInfo |
void |
pushContext()
Starts a new namespace context while loading an XML document. |
void |
recordPrefixToURIMapping()
Must be called during endDocument to record all the prefix to URI mappings that have been seen in the document during loading |
URI |
resolve(URI relative,
URI base)
|
static java.lang.String |
saveString(java.util.Map<?,?> options,
java.util.List<? extends EObject> contents,
java.lang.String encoding,
XMLHelper helper)
|
void |
setAnySimpleType(EClass type)
Sets the any simple type class. |
void |
setCheckForDuplicates(boolean checkForDuplicates)
|
void |
setExtendedMetaData(ExtendedMetaData extendedMetaData)
Sets the ExtendedMetaData to use when serializing an XML file. |
java.util.List<XMIException> |
setManyReference(XMLHelper.ManyReference reference,
java.lang.String location)
|
void |
setMustHavePrefix(boolean mustHavePrefix)
Specify if qualified names must have a prefix or could use default namespace (if possible) |
void |
setNoNamespacePackage(EPackage pkg)
Sets the package to use when there is no XML namespace in an XML file. |
void |
setOptions(java.util.Map<?,?> options)
Sets various resource options on the helper |
void |
setPrefixToNamespaceMap(EMap<java.lang.String,java.lang.String> prefixToNamespaceMap)
|
void |
setProcessDanglingHREF(java.lang.String value)
|
void |
setResource(XMLResource resource)
|
void |
setValue(EObject object,
EStructuralFeature feature,
java.lang.Object value,
int position)
Set the value of the feature for the object. |
void |
setXMLMap(XMLResource.XMLMap map)
Sets the XMLMap to use when serializing an XML file. |
protected java.lang.String |
updateQNamePrefix(EFactory factory,
EDataType dataType,
java.lang.Object value,
boolean list)
|
protected java.lang.Object |
updateQNameURI(java.lang.Object value)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.Integer INTEGER_DATATYPE_IS_MANY
protected static final java.lang.Integer INTEGER_DATATYPE_SINGLE
protected static final java.lang.Integer INTEGER_IS_MANY_ADD
protected static final java.lang.Integer INTEGER_IS_MANY_MOVE
protected static final java.lang.Integer INTEGER_OTHER
protected EPackage noNamespacePackage
protected XMLResource.XMLMap xmlMap
protected ExtendedMetaData extendedMetaData
protected boolean laxFeatureProcessing
protected EPackage.Registry packageRegistry
protected XMLResource resource
protected URI resourceURI
protected boolean deresolve
protected java.util.Map<EPackage,java.lang.String> packages
protected java.util.Map<EStructuralFeature,java.lang.Integer> featuresToKinds
protected java.lang.String processDanglingHREF
protected DanglingHREFException danglingHREFException
protected EMap<java.lang.String,java.lang.String> prefixesToURIs
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> urisToPrefixes
protected java.util.Map<java.lang.String,java.lang.String> anyPrefixesToURIs
protected XMLHelperImpl.NamespaceSupport namespaceSupport
protected EClass anySimpleType
protected boolean seenEmptyStringMapping
protected EPackage xmlSchemaTypePackage
protected java.util.List<java.lang.String> allPrefixToURI
protected boolean checkForDuplicates
protected boolean mustHavePrefix
protected XMLResource.URIHandler uriHandler
protected java.util.List<? extends EObject> roots
protected java.lang.String[] fragmentPrefixes
Constructor Detail |
---|
public XMLHelperImpl()
public XMLHelperImpl(XMLResource resource)
Method Detail |
---|
public static java.lang.String saveString(java.util.Map<?,?> options, java.util.List<? extends EObject> contents, java.lang.String encoding, XMLHelper helper) throws java.lang.Exception
java.lang.Exception
public void setOptions(java.util.Map<?,?> options)
XMLHelper
setOptions
in interface XMLHelper
public void setNoNamespacePackage(EPackage pkg)
XMLHelper
setNoNamespacePackage
in interface XMLHelper
public EPackage getNoNamespacePackage()
XMLHelper
getNoNamespacePackage
in interface XMLHelper
public void setXMLMap(XMLResource.XMLMap map)
XMLHelper
setXMLMap
in interface XMLHelper
public XMLResource.XMLMap getXMLMap()
XMLHelper
getXMLMap
in interface XMLHelper
public void setExtendedMetaData(ExtendedMetaData extendedMetaData)
XMLHelper
setExtendedMetaData
in interface XMLHelper
public ExtendedMetaData getExtendedMetaData()
XMLHelper
getExtendedMetaData
in interface XMLHelper
public XMLResource getResource()
XMLHelper
getResource
in interface XMLHelper
public void setResource(XMLResource resource)
public java.lang.Object getValue(EObject obj, EStructuralFeature f)
XMLHelper
getValue
in interface XMLHelper
public java.lang.String getQName(EClass c)
XMLHelper
getQName
in interface XMLHelper
public void populateNameInfo(NameInfo nameInfo, EClass c)
XMLHelper
NameInfo
with name information, resetting all the current
values in the nameInfo
populateNameInfo
in interface XMLHelper
nameInfo
- the name information to populatec
- the EClass for which name has to be computedXMLHelper.getQName(EClass)
public java.lang.String getQName(EDataType c)
XMLHelper
getQName
in interface XMLHelper
public void populateNameInfo(NameInfo nameInfo, EDataType eDataType)
XMLHelper
NameInfo
with name information, resetting all the current
values in the nameInfo
populateNameInfo
in interface XMLHelper
nameInfo
- the name information to fill ineDataType
- the EDataType for which name has to be computedXMLHelper.getQName(EDataType)
public java.lang.String getQName(EStructuralFeature feature)
XMLHelper
getQName
in interface XMLHelper
public void populateNameInfo(NameInfo nameInfo, EStructuralFeature feature)
XMLHelper
NameInfo
with name information, resetting all the current
values in the nameInfo
populateNameInfo
in interface XMLHelper
nameInfo
- the name information to fill infeature
- the EStructuralFeature for which name has to be computedXMLHelper.getQName(EStructuralFeature)
protected java.lang.String getQName(NameInfo nameInfo, EPackage ePackage, java.lang.String name)
protected java.lang.String getQName(NameInfo nameInfo, EPackage ePackage, java.lang.String name, boolean mustHavePrefix)
protected java.lang.String getQName(EPackage ePackage, java.lang.String name)
protected java.lang.String getQName(EPackage ePackage, java.lang.String name, boolean mustHavePrefix)
public java.lang.String getPrefix(EPackage ePackage)
XMLHelper
getPrefix
in interface XMLHelper
public java.lang.String getNamespaceURI(java.lang.String prefix)
XMLHelper
getNamespaceURI
in interface XMLHelper
protected java.lang.String getPrefix(EPackage ePackage, boolean mustHavePrefix)
public java.util.List<java.lang.String> getPrefixes(EPackage ePackage)
XMLHelper
getPrefixes
in interface XMLHelper
protected java.lang.String getQName(java.lang.String uri, java.lang.String name)
public java.lang.String getName(ENamedElement obj)
XMLHelper
getName
in interface XMLHelper
public java.lang.String getID(EObject obj)
XMLHelper
getID
in interface XMLHelper
protected java.lang.String getURIFragmentQuery(Resource containingResource, EObject object)
protected java.lang.String getURIFragment(Resource containingResource, EObject object)
public java.lang.String getIDREF(EObject obj)
XMLHelper
getIDREF
in interface XMLHelper
protected URI handleDanglingHREF(EObject object)
public java.lang.String getHREF(EObject obj)
XMLHelper
getHREF
in interface XMLHelper
protected URI getHREF(Resource otherResource, EObject obj)
public URI deresolve(URI uri)
XMLHelper
deresolve
in interface XMLHelper
public int getFeatureKind(EStructuralFeature feature)
XMLHelper
getFeatureKind
in interface XMLHelper
public EObject createObject(EFactory eFactory, EClassifier type)
XMLHelper
createObject
in interface XMLHelper
XMLHelper.createObject(EFactory, String)
public EClassifier getType(EFactory eFactory, java.lang.String typeName)
XMLHelper
getType
in interface XMLHelper
XMLHelper.createObject(EFactory, String)
@Deprecated public EObject createObject(EFactory eFactory, java.lang.String classXMIName)
XMLHelper
createObject
in interface XMLHelper
public EStructuralFeature getFeature(EClass eClass, java.lang.String namespaceURI, java.lang.String name)
XMLHelper
getFeature
in interface XMLHelper
public EStructuralFeature getFeature(EClass eClass, java.lang.String namespaceURI, java.lang.String name, boolean isElement)
XMLHelper
getFeature
in interface XMLHelper
protected EStructuralFeature getFeatureWithoutMap(EClass eClass, java.lang.String name)
protected void computeFeatureKind(EStructuralFeature feature)
public java.lang.String getJavaEncoding(java.lang.String xmlEncoding)
XMLHelper
getJavaEncoding
in interface XMLHelper
public java.lang.String getXMLEncoding(java.lang.String javaEncoding)
XMLHelper
getXMLEncoding
in interface XMLHelper
public EPackage[] packages()
XMLHelper
packages
in interface XMLHelper
public void setValue(EObject object, EStructuralFeature feature, java.lang.Object value, int position)
XMLHelper
setValue
in interface XMLHelper
public java.util.List<XMIException> setManyReference(XMLHelper.ManyReference reference, java.lang.String location)
setManyReference
in interface XMLHelper
public void setCheckForDuplicates(boolean checkForDuplicates)
setCheckForDuplicates
in interface XMLHelper
public void setProcessDanglingHREF(java.lang.String value)
setProcessDanglingHREF
in interface XMLHelper
public DanglingHREFException getDanglingHREFException()
getDanglingHREFException
in interface XMLHelper
public URI resolve(URI relative, URI base)
resolve
in interface XMLHelper
public void pushContext()
XMLHelper
A new context should be pushed at the beginning of each XML element. The new context will automatically inherit the declarations of its parent context, but it will also keep track of which declarations were made within this context.
pushContext
in interface XMLHelper
public void popContext()
XMLHelper
The context should be popped at the end of each XML element. After popping the context, all namespace prefix mappings that were previously in scope are restored.
popContext
in interface XMLHelper
public void popContext(java.util.Map<java.lang.String,EFactory> prefixesToFactories)
XMLHelper
The context should be popped at the end of each XML element. After popping the context, all namespace prefix mappings that were previously in scope are restored.
popContext
in interface XMLHelper
public void addPrefix(java.lang.String prefix, java.lang.String uri)
XMLHelper
addPrefix
in interface XMLHelper
public java.lang.String getPrefix(java.lang.String namespaceURI)
getPrefix
in interface XMLHelper
public java.util.Map<java.lang.String,java.lang.String> getAnyContentPrefixToURIMapping()
XMLHelper
getAnyContentPrefixToURIMapping
in interface XMLHelper
public java.lang.String getURI(java.lang.String prefix)
XMLHelper
getURI
in interface XMLHelper
public EMap<java.lang.String,java.lang.String> getPrefixToNamespaceMap()
getPrefixToNamespaceMap
in interface XMLHelper
public void recordPrefixToURIMapping()
XMLHelper
recordPrefixToURIMapping
in interface XMLHelper
public void setPrefixToNamespaceMap(EMap<java.lang.String,java.lang.String> prefixToNamespaceMap)
setPrefixToNamespaceMap
in interface XMLHelper
public void setAnySimpleType(EClass type)
XMLHelper
setAnySimpleType
in interface XMLHelper
XMLResource.OPTION_ANY_SIMPLE_TYPE
public java.lang.String convertToString(EFactory factory, EDataType dataType, java.lang.Object value)
XMLHelper
convertToString
in interface XMLHelper
protected java.lang.Object createFromString(EFactory eFactory, EDataType eDataType, java.lang.String value)
protected java.lang.Object updateQNameURI(java.lang.Object value)
protected java.lang.String updateQNamePrefix(EFactory factory, EDataType dataType, java.lang.Object value, boolean list)
factory
- dataType
- value
- a data value to be converted to stringlist
- if the value is part of the list of values
protected void addNSDeclaration(java.lang.String prefix, java.lang.String uri)
public void setMustHavePrefix(boolean mustHavePrefix)
XMLHelper
setMustHavePrefix
in interface XMLHelper
|
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 |