public class XMLHelperImpl extends java.lang.Object implements XMLHelper
| Modifier and Type | Class and Description |
|---|---|
protected static class |
XMLHelperImpl.NamespaceSupport
A helper to encode namespace prefix mappings.
|
XMLHelper.ManyReference| Modifier and Type | Field and Description |
|---|---|
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 <any> |
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 |
DATATYPE_IS_MANY, DATATYPE_SINGLE, IS_MANY_ADD, IS_MANY_MOVE, OTHER| Constructor and Description |
|---|
XMLHelperImpl() |
XMLHelperImpl(XMLResource resource) |
| Modifier and Type | Method and Description |
|---|---|
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 name.
|
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) |
protected java.lang.String |
getPrefix(EPackage ePackage,
boolean mustHavePrefix) |
java.util.List<java.lang.String> |
getPrefixes(EPackage ePackage)
Return all the prefixes used for this package.
|
<any> |
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)
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(NameInfo nameInfo,
EPackage ePackage,
java.lang.String name) |
protected java.lang.String |
getQName(NameInfo nameInfo,
EPackage ePackage,
java.lang.String name,
boolean mustHavePrefix) |
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(<any> 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) |
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 <any> 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
public XMLHelperImpl()
public XMLHelperImpl(XMLResource resource)
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.Exceptionpublic void setOptions(java.util.Map<?,?> options)
XMLHelpersetOptions in interface XMLHelperpublic void setNoNamespacePackage(EPackage pkg)
XMLHelpersetNoNamespacePackage in interface XMLHelperpublic EPackage getNoNamespacePackage()
XMLHelpergetNoNamespacePackage in interface XMLHelperpublic void setXMLMap(XMLResource.XMLMap map)
XMLHelperpublic XMLResource.XMLMap getXMLMap()
XMLHelperpublic void setExtendedMetaData(ExtendedMetaData extendedMetaData)
XMLHelpersetExtendedMetaData in interface XMLHelperpublic ExtendedMetaData getExtendedMetaData()
XMLHelpergetExtendedMetaData in interface XMLHelperpublic XMLResource getResource()
XMLHelpergetResource in interface XMLHelperpublic void setResource(XMLResource resource)
public java.lang.Object getValue(EObject obj,
EStructuralFeature f)
XMLHelperpublic java.lang.String getQName(EClass c)
XMLHelperpublic void populateNameInfo(NameInfo nameInfo, EClass c)
XMLHelperNameInfo with name information, resetting all the current
values in the nameInfopopulateNameInfo in interface XMLHelpernameInfo - the name information to populatec - the EClass for which name has to be computedXMLHelper.getQName(EClass)public java.lang.String getQName(EDataType c)
XMLHelperpublic void populateNameInfo(NameInfo nameInfo, EDataType eDataType)
XMLHelperNameInfo with name information, resetting all the current
values in the nameInfopopulateNameInfo in interface XMLHelpernameInfo - the name information to populateeDataType - the EClass for which name has to be computedXMLHelper.getQName(EClass)public java.lang.String getQName(EStructuralFeature feature)
XMLHelperpublic void populateNameInfo(NameInfo nameInfo, EStructuralFeature feature)
XMLHelperNameInfo with name information, resetting all the current
values in the nameInfopopulateNameInfo in interface XMLHelpernameInfo - the name information to populatefeature - the EClass for which name has to be computedXMLHelper.getQName(EClass)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)
public java.lang.String getNamespaceURI(java.lang.String prefix)
XMLHelpergetNamespaceURI in interface XMLHelperprotected java.lang.String getPrefix(EPackage ePackage,
boolean mustHavePrefix)
public java.util.List<java.lang.String> getPrefixes(EPackage ePackage)
XMLHelpergetPrefixes in interface XMLHelperpublic java.lang.String getName(ENamedElement obj)
XMLHelperpublic java.lang.String getID(EObject obj)
XMLHelperprotected java.lang.String getURIFragmentQuery(Resource containingResource,
EObject object)
protected java.lang.String getURIFragment(Resource containingResource,
EObject object)
public java.lang.String getIDREF(EObject obj)
XMLHelperprotected URI handleDanglingHREF(EObject object)
public java.lang.String getHREF(EObject obj)
XMLHelperprotected URI getHREF(Resource otherResource,
EObject obj)
public URI deresolve(URI uri)
XMLHelperpublic int getFeatureKind(EStructuralFeature feature)
XMLHelpergetFeatureKind in interface XMLHelperpublic EObject createObject(EFactory eFactory,
EClassifier type)
XMLHelpercreateObject in interface XMLHelperpublic EClassifier getType(EFactory eFactory,
java.lang.String typeName)
XMLHelpergetType in interface XMLHelperXMLHelper.createObject(EFactory, String)@Deprecated
public EObject createObject(EFactory eFactory,
java.lang.String classXMIName)
XMLHelpercreateObject in interface XMLHelperpublic EStructuralFeature getFeature(EClass eClass,
java.lang.String namespaceURI,
java.lang.String name)
XMLHelpergetFeature in interface XMLHelperpublic EStructuralFeature getFeature(EClass eClass,
java.lang.String namespaceURI,
java.lang.String name,
boolean isElement)
XMLHelpergetFeature in interface XMLHelperprotected EStructuralFeature getFeatureWithoutMap(EClass eClass,
java.lang.String name)
protected void computeFeatureKind(EStructuralFeature feature)
public java.lang.String getJavaEncoding(java.lang.String xmlEncoding)
XMLHelpergetJavaEncoding in interface XMLHelperpublic java.lang.String getXMLEncoding(java.lang.String javaEncoding)
XMLHelpergetXMLEncoding in interface XMLHelperpublic EPackage[] packages()
XMLHelperpublic void setValue(EObject object,
EStructuralFeature feature,
java.lang.Object value,
int position)
XMLHelperpublic java.util.List<XMIException> setManyReference(XMLHelper.ManyReference reference, java.lang.String location)
setManyReference in interface XMLHelperpublic void setCheckForDuplicates(boolean checkForDuplicates)
setCheckForDuplicates in interface XMLHelperpublic void setProcessDanglingHREF(java.lang.String value)
setProcessDanglingHREF in interface XMLHelperpublic DanglingHREFException getDanglingHREFException()
getDanglingHREFException in interface XMLHelperpublic void pushContext()
XMLHelperA 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 XMLHelperpublic void popContext()
XMLHelperThe 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 XMLHelperpublic void popContext(java.util.Map<java.lang.String,EFactory> prefixesToFactories)
XMLHelperThe 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 XMLHelperpublic void addPrefix(java.lang.String prefix,
java.lang.String uri)
XMLHelperpublic java.util.Map<java.lang.String,java.lang.String> getAnyContentPrefixToURIMapping()
XMLHelpergetAnyContentPrefixToURIMapping in interface XMLHelperpublic java.lang.String getURI(java.lang.String prefix)
XMLHelperpublic <any> getPrefixToNamespaceMap()
getPrefixToNamespaceMap in interface XMLHelperpublic void recordPrefixToURIMapping()
XMLHelperrecordPrefixToURIMapping in interface XMLHelperpublic void setPrefixToNamespaceMap(<any> prefixToNamespaceMap)
setPrefixToNamespaceMap in interface XMLHelperpublic void setAnySimpleType(EClass type)
XMLHelpersetAnySimpleType in interface XMLHelperXMLResource.OPTION_ANY_SIMPLE_TYPEpublic java.lang.String convertToString(EFactory factory,
EDataType dataType,
java.lang.Object value)
XMLHelperconvertToString in interface XMLHelperprotected 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 valuesprotected void addNSDeclaration(java.lang.String prefix,
java.lang.String uri)
public void setMustHavePrefix(boolean mustHavePrefix)
XMLHelpersetMustHavePrefix in interface XMLHelperCopyright © 2018. Licensed under the Eclipse Public License v1.0. All rights reserved.
Submit a bug or feature