org.eclipse.emf.ecore.xmi
Interface XMLHelper

All Known Subinterfaces:
EMOFHandler.Helper
All Known Implementing Classes:
EMOFHelperImpl, XMIHelperImpl, XMLHelperImpl

public interface XMLHelper

Configuration class for XML. It holds the EPackage to use when XML namespaces are not used in an XML file. It also holds the XMLMap to be used when serializing an XML file. The XML deserializer and serializer uses this class when an XML file is loaded and saved.


Nested Class Summary
static interface XMLHelper.ManyReference
           
 
Field Summary
static int DATATYPE_IS_MANY
           
static int DATATYPE_SINGLE
          These are the kinds of features that are important when loading XMI files.
static int IS_MANY_ADD
           
static int IS_MANY_MOVE
           
static int OTHER
           
 
Method Summary
 void addPrefix(java.lang.String prefix, java.lang.String uri)
          Records the prefix to URI mapping while loading an XML document.
 java.lang.String convertToString(EFactory factory, EDataType dataType, java.lang.Object data)
          Converts the given data value to a string while saving an XML document.
 EObject createObject(EFactory eFactory, EClassifier type)
          Create an object given an EFactory and a type
 EObject createObject(EFactory eFactory, java.lang.String name)
          Deprecated. since 2.2. Instead use #createObject(EFactory, EClassifier) and #getType(EFactory, String)
 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.
 java.lang.String getHREF(EObject eObject)
          Returns an HREF to this object from this resource
 java.lang.String getID(EObject eObject)
          Returns the xmi:id or null to supress
 java.lang.String getIDREF(EObject eObject)
          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 eNamedElement)
          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.
 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 eClass)
          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 eDataType)
          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(EStructuralFeature feature)
          By default, this method returns the name of the feature.
 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.
 java.lang.Object getValue(EObject eObject, EStructuralFeature eStructuralFeature)
          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.
 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 eClass)
          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)
           
 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 setValue(EObject eObject, EStructuralFeature eStructuralFeature, 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.
 

Field Detail

DATATYPE_SINGLE

static final int DATATYPE_SINGLE
These are the kinds of features that are important when loading XMI files.

See Also:
Constant Field Values

DATATYPE_IS_MANY

static final int DATATYPE_IS_MANY
See Also:
Constant Field Values

IS_MANY_ADD

static final int IS_MANY_ADD
See Also:
Constant Field Values

IS_MANY_MOVE

static final int IS_MANY_MOVE
See Also:
Constant Field Values

OTHER

static final int OTHER
See Also:
Constant Field Values
Method Detail

setOptions

void setOptions(java.util.Map<?,?> options)
Sets various resource options on the helper


setNoNamespacePackage

void setNoNamespacePackage(EPackage pkg)
Sets the package to use when there is no XML namespace in an XML file.


getNoNamespacePackage

EPackage getNoNamespacePackage()
Gets the package to use when there is no XML namespace in an XML file.


setAnySimpleType

void setAnySimpleType(EClass type)
Sets the any simple type class.

See Also:
XMLResource.OPTION_ANY_SIMPLE_TYPE

setXMLMap

void setXMLMap(XMLResource.XMLMap map)
Sets the XMLMap to use when serializing an XML file.


getXMLMap

XMLResource.XMLMap getXMLMap()
Gets the XMLMap to use when serializing an XML file.


setExtendedMetaData

void setExtendedMetaData(ExtendedMetaData extendedMetaData)
Sets the ExtendedMetaData to use when serializing an XML file.


getExtendedMetaData

ExtendedMetaData getExtendedMetaData()
Gets the ExtendedMetaData to use when serializing an XML file.


getResource

XMLResource getResource()
Returns the resource


getValue

java.lang.Object getValue(EObject eObject,
                          EStructuralFeature eStructuralFeature)
Returns the XMI value of the EObject's feature


getName

java.lang.String getName(ENamedElement eNamedElement)
Returns the XML name of the ENamedElement


getQName

java.lang.String getQName(EClass eClass)
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. If the map has a target namespace specified, that target namespace is used rather than the namespace from the EPackage.


populateNameInfo

void populateNameInfo(NameInfo nameInfo,
                      EClass eClass)
This method populates the given NameInfo with name information, resetting all the current values in the nameInfo

Parameters:
nameInfo - the name information to populate
eClass - the EClass for which name has to be computed
Since:
2.1.0
See Also:
getQName(EClass)

getQName

java.lang.String getQName(EDataType eDataType)
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. If the map has a target namespace specified, that target namespace is used rather than the namespace from the EPackage.


populateNameInfo

void populateNameInfo(NameInfo nameInfo,
                      EDataType eDataType)
This method populates the given NameInfo with name information, resetting all the current values in the nameInfo

Parameters:
nameInfo - the name information to fill in
eDataType - the EDataType for which name has to be computed
Since:
2.1.0
See Also:
getQName(EDataType)

getQName

java.lang.String getQName(EStructuralFeature feature)
By default, this method returns the name of the feature. However, if there is an XMLMap, and the map specifies a target namespace, the nsPrefix:name is returned.


populateNameInfo

void populateNameInfo(NameInfo nameInfo,
                      EStructuralFeature feature)
This method populates the given NameInfo with name information, resetting all the current values in the nameInfo

Parameters:
nameInfo - the name information to fill in
feature - the EStructuralFeature for which name has to be computed
Since:
2.1.0
See Also:
getQName(EStructuralFeature)

getPrefix

java.lang.String getPrefix(java.lang.String namespaceURI)

getPrefix

java.lang.String getPrefix(EPackage ePackage)
Return the prefix used for this package.


getNamespaceURI

java.lang.String getNamespaceURI(java.lang.String prefix)
Returns the namespaceURI in scope for the prefix.


getPrefixes

java.util.List<java.lang.String> getPrefixes(EPackage ePackage)
Return all the prefixes used for this package.


getID

java.lang.String getID(EObject eObject)
Returns the xmi:id or null to supress


getIDREF

java.lang.String getIDREF(EObject eObject)
Returns an IDREF to this object


getHREF

java.lang.String getHREF(EObject eObject)
Returns an HREF to this object from this resource


deresolve

URI deresolve(URI uri)
Returns a relative URI if necessary and if possible.


packages

EPackage[] packages()
Returns the packages in getQName()


createObject

@Deprecated
EObject createObject(EFactory eFactory,
                                java.lang.String name)
Deprecated. since 2.2. Instead use #createObject(EFactory, EClassifier) and #getType(EFactory, String)

Create an object given an EFactory and a type name.


createObject

EObject createObject(EFactory eFactory,
                     EClassifier type)
Create an object given an EFactory and a type

Parameters:
eFactory -
type -
Returns:
the created object.
Since:
2.2
See Also:
createObject(EFactory, String)

getType

EClassifier getType(EFactory eFactory,
                    java.lang.String typeName)
Given an EFactory and a type name, find and return the type

Parameters:
eFactory -
typeName -
Since:
2.2
See Also:
createObject(EFactory, String)

setValue

void setValue(EObject eObject,
              EStructuralFeature eStructuralFeature,
              java.lang.Object value,
              int position)
Set the value of the feature for the object.


getFeature

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.


getFeature

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.


getFeatureKind

int getFeatureKind(EStructuralFeature feature)
Return the kind of feature.


getXMLEncoding

java.lang.String getXMLEncoding(java.lang.String javaEncoding)
Return an XML encoding corresponding to the given Java encoding. By default, the Java encoding is returned.


getJavaEncoding

java.lang.String getJavaEncoding(java.lang.String xmlEncoding)
Return a Java encoding corresponding to the given XML encoding. By default, the XML encoding is returned.


setManyReference

java.util.List<XMIException> setManyReference(XMLHelper.ManyReference reference,
                                              java.lang.String location)

setCheckForDuplicates

void setCheckForDuplicates(boolean checkForDuplicates)

setProcessDanglingHREF

void setProcessDanglingHREF(java.lang.String value)

getDanglingHREFException

DanglingHREFException getDanglingHREFException()

resolve

URI resolve(URI relative,
            URI base)

addPrefix

void addPrefix(java.lang.String prefix,
               java.lang.String uri)
Records the prefix to URI mapping while loading an XML document.


getAnyContentPrefixToURIMapping

java.util.Map<java.lang.String,java.lang.String> getAnyContentPrefixToURIMapping()
Returns a map of prefixes to URI mapping for elements with any content


recordPrefixToURIMapping

void recordPrefixToURIMapping()
Must be called during endDocument to record all the prefix to URI mappings that have been seen in the document during loading


getURI

java.lang.String getURI(java.lang.String prefix)
Returns the namespace prefix that's in effect while loading an XML document.


pushContext

void pushContext()
Starts a new namespace context while loading an XML document.

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.


popContext

void popContext()
Reverts to the previous namespace context while loading XML document.

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

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.

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.


convertToString

java.lang.String convertToString(EFactory factory,
                                 EDataType dataType,
                                 java.lang.Object data)
Converts the given data value to a string while saving an XML document.


getPrefixToNamespaceMap

EMap<java.lang.String,java.lang.String> getPrefixToNamespaceMap()

setPrefixToNamespaceMap

void setPrefixToNamespaceMap(EMap<java.lang.String,java.lang.String> prefixToNamespaceMap)

setMustHavePrefix

void setMustHavePrefix(boolean mustHavePrefix)
Specify if qualified names must have a prefix or could use default namespace (if possible)

Parameters:
mustHavePrefix -

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