|
|||||||||||
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
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 inherited from class org.eclipse.emf.ecore.xmi.XMLHelper |
XMLHelper.ManyReference |
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(String prefix,
String uri)
|
void |
addPrefix(String prefix,
String uri)
Records the prefix to URI mapping while loading an XML document. |
protected void |
computeFeatureKind(EStructuralFeature feature)
|
String |
convertToString(EFactory factory,
EDataType dataType,
Object value)
Converts the given valuevalue to string while saving an XML document. |
protected Object |
createFromString(EFactory eFactory,
EDataType eDataType,
String value)
|
EObject |
createObject(EFactory eFactory,
EClassifier type)
Create an object given an EFactory and a type |
EObject |
createObject(EFactory eFactory,
String classXMIName)
Create an object given an EFactory and a type name. |
URI |
deresolve(URI uri)
Returns a relative URI if necessary and if possible. |
Map |
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,
String namespaceURI,
String name)
Returns the structural feature for the XML element/attribute with the given namespaceURI and name. |
EStructuralFeature |
getFeature(EClass eClass,
String namespaceURI,
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,
String name)
|
String |
getHREF(EObject obj)
Returns an HREF to this object from this resource |
protected URI |
getHREF(Resource otherResource,
EObject obj)
|
String |
getID(EObject obj)
Returns the xmi:id or null to supress |
String |
getIDREF(EObject obj)
Returns an IDREF to this object |
String |
getJavaEncoding(String xmlEncoding)
Return a Java encoding corresponding to the given XML encoding. |
String |
getName(ENamedElement obj)
Returns the XML name of the ENamedElement |
String |
getNamespaceURI(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. |
String |
getPrefix(EPackage ePackage)
Return the prefix used for this package. |
protected String |
getPrefix(EPackage ePackage,
boolean mustHavePrefix)
|
String |
getPrefix(String namespaceURI)
|
List |
getPrefixes(EPackage ePackage)
Return all the prefixes used for this package. |
EMap |
getPrefixToNamespaceMap()
|
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. |
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 String |
getQName(EPackage ePackage,
String name)
|
protected String |
getQName(EPackage ePackage,
String name,
boolean mustHavePrefix)
|
String |
getQName(EStructuralFeature feature)
By default, this method returns the name of the feature. |
protected String |
getQName(NameInfo nameInfo,
EPackage ePackage,
String name)
|
protected String |
getQName(NameInfo nameInfo,
EPackage ePackage,
String name,
boolean mustHavePrefix)
|
protected String |
getQName(String uri,
String name)
|
XMLResource |
getResource()
Returns the resource |
EClassifier |
getType(EFactory eFactory,
String typeName)
Given an EFactory and a type name, find and return the type |
String |
getURI(String prefix)
Returns the namespace prefix that's in effect while loading an XML document. |
protected String |
getURIFragment(Resource containingResource,
EObject object)
|
protected String |
getURIFragmentQuery(Resource containingResource,
EObject object)
|
Object |
getValue(EObject obj,
EStructuralFeature f)
Returns the XMI value of the EObject's feature |
String |
getXMLEncoding(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(Map 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 String |
saveString(Map options,
List contents,
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. |
List |
setManyReference(XMLHelper.ManyReference reference,
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(Map options)
Sets various resource options on the helper |
void |
setPrefixToNamespaceMap(EMap prefixToNamespaceMap)
|
void |
setProcessDanglingHREF(String value)
|
void |
setResource(XMLResource resource)
|
void |
setValue(EObject object,
EStructuralFeature feature,
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 String |
updateQNamePrefix(EFactory factory,
EDataType dataType,
Object value,
boolean list)
|
protected void |
updateQNameURI(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 Integer INTEGER_DATATYPE_IS_MANY
protected static final Integer INTEGER_DATATYPE_SINGLE
protected static final Integer INTEGER_IS_MANY_ADD
protected static final Integer INTEGER_IS_MANY_MOVE
protected static final 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 Map packages
protected Map featuresToKinds
protected String processDanglingHREF
protected DanglingHREFException danglingHREFException
protected EMap prefixesToURIs
protected Map urisToPrefixes
protected Map anyPrefixesToURIs
protected XMLHelperImpl.NamespaceSupport namespaceSupport
protected EClass anySimpleType
protected boolean seenEmptyStringMapping
protected EPackage xmlSchemaTypePackage
protected List allPrefixToURI
protected boolean checkForDuplicates
protected boolean mustHavePrefix
Constructor Detail |
public XMLHelperImpl()
public XMLHelperImpl(XMLResource resource)
Method Detail |
public static String saveString(Map options, List contents, String encoding, XMLHelper helper) throws Exception
Exception
public void setOptions(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 Object getValue(EObject obj, EStructuralFeature f)
XMLHelper
getValue
in interface XMLHelper
public 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 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 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 String getQName(NameInfo nameInfo, EPackage ePackage, String name)
protected String getQName(NameInfo nameInfo, EPackage ePackage, String name, boolean mustHavePrefix)
protected String getQName(EPackage ePackage, String name)
protected String getQName(EPackage ePackage, String name, boolean mustHavePrefix)
public String getPrefix(EPackage ePackage)
XMLHelper
getPrefix
in interface XMLHelper
public String getNamespaceURI(String prefix)
XMLHelper
getNamespaceURI
in interface XMLHelper
protected String getPrefix(EPackage ePackage, boolean mustHavePrefix)
public List getPrefixes(EPackage ePackage)
XMLHelper
getPrefixes
in interface XMLHelper
protected String getQName(String uri, String name)
public String getName(ENamedElement obj)
XMLHelper
getName
in interface XMLHelper
public String getID(EObject obj)
XMLHelper
getID
in interface XMLHelper
protected String getURIFragmentQuery(Resource containingResource, EObject object)
protected String getURIFragment(Resource containingResource, EObject object)
public String getIDREF(EObject obj)
XMLHelper
getIDREF
in interface XMLHelper
protected URI handleDanglingHREF(EObject object)
public 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
eFactory
- type
-
XMLHelper.createObject(EFactory, String)
public EClassifier getType(EFactory eFactory, String typeName)
XMLHelper
getType
in interface XMLHelper
eFactory
- typeName
- XMLHelper.createObject(EFactory, String)
public EObject createObject(EFactory eFactory, String classXMIName)
XMLHelper
createObject
in interface XMLHelper
public EStructuralFeature getFeature(EClass eClass, String namespaceURI, String name)
XMLHelper
getFeature
in interface XMLHelper
public EStructuralFeature getFeature(EClass eClass, String namespaceURI, String name, boolean isElement)
XMLHelper
getFeature
in interface XMLHelper
protected EStructuralFeature getFeatureWithoutMap(EClass eClass, String name)
protected void computeFeatureKind(EStructuralFeature feature)
public String getJavaEncoding(String xmlEncoding)
XMLHelper
getJavaEncoding
in interface XMLHelper
public String getXMLEncoding(String javaEncoding)
XMLHelper
getXMLEncoding
in interface XMLHelper
public EPackage[] packages()
XMLHelper
packages
in interface XMLHelper
public void setValue(EObject object, EStructuralFeature feature, Object value, int position)
XMLHelper
setValue
in interface XMLHelper
public List setManyReference(XMLHelper.ManyReference reference, String location)
setManyReference
in interface XMLHelper
public void setCheckForDuplicates(boolean checkForDuplicates)
setCheckForDuplicates
in interface XMLHelper
public void setProcessDanglingHREF(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(Map 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(String prefix, String uri)
XMLHelper
addPrefix
in interface XMLHelper
public String getPrefix(String namespaceURI)
getPrefix
in interface XMLHelper
public Map getAnyContentPrefixToURIMapping()
XMLHelper
getAnyContentPrefixToURIMapping
in interface XMLHelper
public String getURI(String prefix)
XMLHelper
getURI
in interface XMLHelper
public EMap getPrefixToNamespaceMap()
getPrefixToNamespaceMap
in interface XMLHelper
public void recordPrefixToURIMapping()
XMLHelper
recordPrefixToURIMapping
in interface XMLHelper
public void setPrefixToNamespaceMap(EMap prefixToNamespaceMap)
setPrefixToNamespaceMap
in interface XMLHelper
public void setAnySimpleType(EClass type)
XMLHelper
setAnySimpleType
in interface XMLHelper
XMLResource.OPTION_ANY_SIMPLE_TYPE
public String convertToString(EFactory factory, EDataType dataType, Object value)
XMLHelper
convertToString
in interface XMLHelper
protected Object createFromString(EFactory eFactory, EDataType eDataType, String value)
protected void updateQNameURI(Object value)
protected String updateQNamePrefix(EFactory factory, EDataType dataType, 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(String prefix, String uri)
public void setMustHavePrefix(boolean mustHavePrefix)
XMLHelper
setMustHavePrefix
in interface XMLHelper
mustHavePrefix
-
|
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 |