org.eclipse.emf.ecore.xmi.impl
Class XMLHelperImpl

java.lang.Object
  |
  +--org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl
All Implemented Interfaces:
XMLHelper
Direct Known Subclasses:
XMIHelperImpl

public class XMLHelperImpl
extends java.lang.Object
implements XMLHelper

This class handles the package to use when there is no XML namespace in an XML file.


Inner classes inherited from class org.eclipse.emf.ecore.xmi.XMLHelper
XMLHelper.ManyReference
 
Field Summary
protected  DanglingHREFException danglingHREFException
           
protected  java.util.Map featuresToKinds
           
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  EPackage noNamespacePackage
           
protected  java.util.Map packages
           
protected  java.util.Map prefixesToURIs
           
protected  java.lang.String processDanglingHREF
           
protected  XMLResource resource
           
protected  XMLResource.XMLMap xmlMap
           
 
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
 void addPrefix(java.lang.String prefix, java.lang.String uri)
           
protected  void computeFeatureKind(EStructuralFeature feature)
           
 EObject createObject(EFactory eFactory, java.lang.String classXMIName)
          Create an object given an EFactory and a type name.
 DanglingHREFException getDanglingHREFException()
           
 EStructuralFeature getFeature(EClass eClass, java.lang.String namespaceURI, java.lang.String name)
          Returns the structural feature for 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
 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
 EPackage getNoNamespacePackage()
          Gets the package to use when there is no XML namespace in an XML file.
 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(EStructuralFeature feature)
          By default, this method returns the name of the feature.
protected  java.lang.String getQName(java.lang.String uri, java.lang.String name)
           
 XMLResource getResource()
          Returns the resource
 java.lang.String getURI(java.lang.String prefix)
           
 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()
 URI resolve(URI relative, URI base)
           
static java.lang.String saveString(java.util.Map options, java.util.List contents, java.lang.String encoding)
           
 java.util.List setManyReference(XMLHelper.ManyReference reference, java.lang.String location)
           
 void setNoNamespacePackage(EPackage pkg)
          Sets the package to use when there is no XML namespace in an XML file.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTEGER_DATATYPE_IS_MANY

protected static final java.lang.Integer INTEGER_DATATYPE_IS_MANY

INTEGER_DATATYPE_SINGLE

protected static final java.lang.Integer INTEGER_DATATYPE_SINGLE

INTEGER_IS_MANY_ADD

protected static final java.lang.Integer INTEGER_IS_MANY_ADD

INTEGER_IS_MANY_MOVE

protected static final java.lang.Integer INTEGER_IS_MANY_MOVE

noNamespacePackage

protected EPackage noNamespacePackage

xmlMap

protected XMLResource.XMLMap xmlMap

resource

protected XMLResource resource

packages

protected java.util.Map packages

featuresToKinds

protected java.util.Map featuresToKinds

processDanglingHREF

protected java.lang.String processDanglingHREF

danglingHREFException

protected DanglingHREFException danglingHREFException

prefixesToURIs

protected java.util.Map prefixesToURIs
Constructor Detail

XMLHelperImpl

public XMLHelperImpl()

XMLHelperImpl

public XMLHelperImpl(XMLResource resource)
Method Detail

saveString

public static java.lang.String saveString(java.util.Map options,
                                          java.util.List contents,
                                          java.lang.String encoding)
                                   throws java.lang.Exception

setNoNamespacePackage

public void setNoNamespacePackage(EPackage pkg)
Description copied from interface: XMLHelper
Sets the package to use when there is no XML namespace in an XML file.
Specified by:
setNoNamespacePackage in interface XMLHelper

getNoNamespacePackage

public EPackage getNoNamespacePackage()
Description copied from interface: XMLHelper
Gets the package to use when there is no XML namespace in an XML file.
Specified by:
getNoNamespacePackage in interface XMLHelper

setXMLMap

public void setXMLMap(XMLResource.XMLMap map)
Description copied from interface: XMLHelper
Sets the XMLMap to use when serializing an XML file.
Specified by:
setXMLMap in interface XMLHelper

getXMLMap

public XMLResource.XMLMap getXMLMap()
Description copied from interface: XMLHelper
Gets the XMLMap to use when serializing an XML file.
Specified by:
getXMLMap in interface XMLHelper

getResource

public XMLResource getResource()
Description copied from interface: XMLHelper
Returns the resource
Specified by:
getResource in interface XMLHelper

setResource

public void setResource(XMLResource resource)

getValue

public java.lang.Object getValue(EObject obj,
                                 EStructuralFeature f)
Description copied from interface: XMLHelper
Returns the XMI value of the EObject's feature
Specified by:
getValue in interface XMLHelper

getQName

public java.lang.String getQName(EClass c)
Description copied from interface: XMLHelper
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.
Specified by:
getQName in interface XMLHelper

getQName

protected java.lang.String getQName(java.lang.String uri,
                                    java.lang.String name)

getName

public java.lang.String getName(ENamedElement obj)
Description copied from interface: XMLHelper
Returns the XML name of the ENamedElement
Specified by:
getName in interface XMLHelper

getQName

public java.lang.String getQName(EStructuralFeature feature)
Description copied from interface: XMLHelper
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.
Specified by:
getQName in interface XMLHelper

getID

public java.lang.String getID(EObject obj)
Description copied from interface: XMLHelper
Returns the xmi:id or null to supress
Specified by:
getID in interface XMLHelper

getIDREF

public java.lang.String getIDREF(EObject obj)
Description copied from interface: XMLHelper
Returns an IDREF to this object
Specified by:
getIDREF in interface XMLHelper

handleDanglingHREF

protected URI handleDanglingHREF(EObject object)

getHREF

public java.lang.String getHREF(EObject obj)
Description copied from interface: XMLHelper
Returns an HREF to this object from this resource
Specified by:
getHREF in interface XMLHelper

getFeatureKind

public int getFeatureKind(EStructuralFeature feature)
Description copied from interface: XMLHelper
Return the kind of feature.
Specified by:
getFeatureKind in interface XMLHelper

createObject

public EObject createObject(EFactory eFactory,
                            java.lang.String classXMIName)
Description copied from interface: XMLHelper
Create an object given an EFactory and a type name.
Specified by:
createObject in interface XMLHelper

getFeature

public EStructuralFeature getFeature(EClass eClass,
                                     java.lang.String namespaceURI,
                                     java.lang.String name)
Description copied from interface: XMLHelper
Returns the structural feature for the given namespaceURI and name.
Specified by:
getFeature in interface XMLHelper

getFeatureWithoutMap

protected EStructuralFeature getFeatureWithoutMap(EClass eClass,
                                                  java.lang.String name)

computeFeatureKind

protected void computeFeatureKind(EStructuralFeature feature)

getJavaEncoding

public java.lang.String getJavaEncoding(java.lang.String xmlEncoding)
Description copied from interface: XMLHelper
Return a Java encoding corresponding to the given XML encoding. By default, the XML encoding is returned.
Specified by:
getJavaEncoding in interface XMLHelper

getXMLEncoding

public java.lang.String getXMLEncoding(java.lang.String javaEncoding)
Description copied from interface: XMLHelper
Return an XML encoding corresponding to the given Java encoding. By default, the Java encoding is returned.
Specified by:
getXMLEncoding in interface XMLHelper

packages

public EPackage[] packages()
Description copied from interface: XMLHelper
Returns the packages in getQName()
Specified by:
packages in interface XMLHelper

setValue

public void setValue(EObject object,
                     EStructuralFeature feature,
                     java.lang.Object value,
                     int position)
Description copied from interface: XMLHelper
Set the value of the feature for the object.
Specified by:
setValue in interface XMLHelper

setManyReference

public java.util.List setManyReference(XMLHelper.ManyReference reference,
                                       java.lang.String location)
Specified by:
setManyReference in interface XMLHelper

setProcessDanglingHREF

public void setProcessDanglingHREF(java.lang.String value)
Specified by:
setProcessDanglingHREF in interface XMLHelper

getDanglingHREFException

public DanglingHREFException getDanglingHREFException()
Specified by:
getDanglingHREFException in interface XMLHelper

resolve

public URI resolve(URI relative,
                   URI base)
Specified by:
resolve in interface XMLHelper

addPrefix

public void addPrefix(java.lang.String prefix,
                      java.lang.String uri)
Specified by:
addPrefix in interface XMLHelper

getURI

public java.lang.String getURI(java.lang.String prefix)
Specified by:
getURI in interface XMLHelper

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