org.eclipse.emf.ecore.xmi
Interface XMLHelper

All Known Subinterfaces:
EMOFHandler.Helper
All Known Implementing Classes:
EMOFHelperImpl, 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(String prefix, String uri)
          Records the prefix to URI mapping while loading an XML document.
 String convertToString(EFactory factory, EDataType dataType, Object data)
          Converts the given valuevalue to string while saving an XML document.
 EObject createObject(EFactory eFactory, String name)
          Create an object given an EFactory and a type name.
 URI deresolve(URI uri)
          Returns a relative URI if necessary and if possible.
 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.
 String getHREF(EObject eObject)
          Returns an HREF to this object from this resource
 String getID(EObject eObject)
          Returns the xmi:id or null to supress
 String getIDREF(EObject eObject)
          Returns an IDREF to this object
 String getJavaEncoding(String xmlEncoding)
          Return a Java encoding corresponding to the given XML encoding.
 String getName(ENamedElement eNamedElement)
          Returns the XML name of the ENamedElement
 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.
 List getPrefixes(EPackage ePackage)
          Return all the prefixes used for this package.
 EMap getPrefixToNamespaceMap()
           
 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.
 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.
 String getQName(EStructuralFeature feature)
          By default, this method returns the name of the feature.
 XMLResource getResource()
          Returns the resource
 String getURI(String prefix)
          Returns the namespace prefix that's in effect while loading an XML document.
 Object getValue(EObject eObject, EStructuralFeature eStructuralFeature)
          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.
 EPackage[] packages()
          Returns the packages in getQName()
 void popContext()
          Reverts to the previous namespace context while loading XML document.
 void pushContext()
          Starts a new namespace context while loading an XML document.
 URI resolve(URI relative, URI base)
           
 void setAnySimpleType(EClass type)
          Sets the any simple type class.
 void setExtendedMetaData(ExtendedMetaData extendedMetaData)
          Sets the ExtendedMetaData to use when serializing an XML file.
 List setManyReference(XMLHelper.ManyReference reference, String location)
           
 void setNoNamespacePackage(EPackage pkg)
          Sets the package to use when there is no XML namespace in an XML file.
 void setPrefixToNamespaceMap(EMap prefixToNamespaceMap)
           
 void setProcessDanglingHREF(String value)
           
 void setValue(EObject eObject, EStructuralFeature eStructuralFeature, 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

public 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

public static final int DATATYPE_IS_MANY
See Also:
Constant Field Values

IS_MANY_ADD

public static final int IS_MANY_ADD
See Also:
Constant Field Values

IS_MANY_MOVE

public static final int IS_MANY_MOVE
See Also:
Constant Field Values

OTHER

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

setNoNamespacePackage

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


getNoNamespacePackage

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


setAnySimpleType

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

See Also:
XMLResource.OPTION_ANY_SIMPLE_TYPE

setXMLMap

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


getXMLMap

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


setExtendedMetaData

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


getExtendedMetaData

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


getResource

public XMLResource getResource()
Returns the resource


getValue

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


getName

public String getName(ENamedElement eNamedElement)
Returns the XML name of the ENamedElement


getQName

public 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.


getQName

public 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.


getQName

public 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.


getPrefix

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


getPrefixes

public List getPrefixes(EPackage ePackage)
Return all the prefixes used for this package.


getID

public String getID(EObject eObject)
Returns the xmi:id or null to supress


getIDREF

public String getIDREF(EObject eObject)
Returns an IDREF to this object


getHREF

public String getHREF(EObject eObject)
Returns an HREF to this object from this resource


deresolve

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


packages

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


createObject

public EObject createObject(EFactory eFactory,
                            String name)
Create an object given an EFactory and a type name.


setValue

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


getFeature

public EStructuralFeature getFeature(EClass eClass,
                                     String namespaceURI,
                                     String name)
Returns the structural feature for the XML element/attribute with the given namespaceURI and name.


getFeature

public 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.


getFeatureKind

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


getXMLEncoding

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


getJavaEncoding

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


setManyReference

public List setManyReference(XMLHelper.ManyReference reference,
                             String location)

setProcessDanglingHREF

public void setProcessDanglingHREF(String value)

getDanglingHREFException

public DanglingHREFException getDanglingHREFException()

resolve

public URI resolve(URI relative,
                   URI base)

addPrefix

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


getURI

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


pushContext

public 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

public 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.


convertToString

public String convertToString(EFactory factory,
                              EDataType dataType,
                              Object data)
Converts the given valuevalue to string while saving an XML document.


getPrefixToNamespaceMap

public EMap getPrefixToNamespaceMap()

setPrefixToNamespaceMap

public void setPrefixToNamespaceMap(EMap prefixToNamespaceMap)

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