|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.fc.emf.ModelParser
public class ModelParser
Utility class providing a set functions related to working with the Ecore model used by EMF XMLToSDO and SDOToXML Function Components.
Field Summary | |
---|---|
static String |
DOCROOT_CLASSNAME
The name of the classes used in the Ecore models for the document root classes. |
static String |
ROOT_NAME
The name of the XML root object. |
static String |
XMLNSPREFIX_FEATURE_NAME
The name of the feature used in the Ecore models for the namespaces maps. |
Constructor Summary | |
---|---|
ModelParser(ResourceHash resHash)
Initializing the class instances. |
Method Summary | |
---|---|
void |
checkPackagesForConformity(Collection packageCollection,
boolean isNamespaceAware)
Checks if the packages conform to the restrictions set by the EMF XMLToSDO and SDOToXML Function Components. |
static org.eclipse.emf.ecore.sdo.EDataObject |
createRootObject(org.eclipse.emf.ecore.EPackage epackage)
Creates a Data Object of type the root class of the epackage package. |
org.eclipse.emf.ecore.sdo.EDataObject |
createRootObject(String xsdFile)
Creates a root object according to the XML Schema specified by the xsdFile file. |
org.eclipse.emf.ecore.EStructuralFeature |
getFeature(org.eclipse.emf.ecore.EClass eclass,
String name,
Map prefixToURIMap)
Searches an EClass features for a feature which represents an XML element or attribute with specified name. |
static String |
getFeatureName(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns the name as specified in the XML Schema of an XML element or attribute represented by the feature object. |
static String |
getFeatureNamespace(org.eclipse.emf.ecore.EStructuralFeature feature)
Returns the namespace URI of the XML element or attribute represented by the feature object. |
Collection |
getPackageCollection(String xsdFile)
Reads an XML Schema file and creates an Ecore model corresponding to it. |
static org.eclipse.emf.ecore.EClass |
getRootClass(org.eclipse.emf.ecore.EPackage epackage)
Returns the root class of the specified package. |
static org.eclipse.emf.ecore.EPackage |
getRootPackage(Collection packageCollection)
Searches the package collection for a package that defines a root class. |
static int |
getSeparatorPosition(String path)
Searches for a separator in the feature path and returns the position of the first separator or -1 if there are no separators. |
static boolean |
isAttribute(org.eclipse.emf.ecore.EStructuralFeature feature)
Checks if the specified feature object represents an XML attribute. |
static boolean |
isElement(org.eclipse.emf.ecore.EStructuralFeature feature)
Checks if the specified feature object represents an XML element. |
static boolean |
isIgnored(String name)
Checks if the specified string is a ignored feature name. |
static boolean |
isSeparator(char c)
Checks if the specified character is a feature path separator. |
static String |
makeFeaturePath(org.eclipse.emf.ecore.EStructuralFeature feature,
String path,
Map uriToPrefixMap,
boolean alwaysPrefix)
Appends an XML element or attribute name to the current path. |
Map |
parseNamespaces(String namespaces,
boolean isPrefixToURIMap)
Parses a string that describes a mapping between prefixes and namespace URIs. |
static void |
updateFactoryInstances(Collection packageCollection)
Sets the factory instances of all EPackages in the collection to factory instances compliant to the EDataObject interface. |
static void |
updatePackageRegistry(Collection packageCollection,
org.eclipse.emf.ecore.EPackage.Registry packageRegistry)
Traverses a collection of EPackages and adds them to a package registry. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ROOT_NAME
public static final String XMLNSPREFIX_FEATURE_NAME
public static final String DOCROOT_CLASSNAME
Constructor Detail |
---|
public ModelParser(ResourceHash resHash)
Method Detail |
---|
public static boolean isIgnored(String name)
public static boolean isSeparator(char c)
public static String getFeatureName(org.eclipse.emf.ecore.EStructuralFeature feature)
feature
object.
public static String getFeatureNamespace(org.eclipse.emf.ecore.EStructuralFeature feature)
feature
object.
public static boolean isAttribute(org.eclipse.emf.ecore.EStructuralFeature feature)
feature
object represents an XML attribute.
public static boolean isElement(org.eclipse.emf.ecore.EStructuralFeature feature)
feature
object represents an XML element.
public static String makeFeaturePath(org.eclipse.emf.ecore.EStructuralFeature feature, String path, Map uriToPrefixMap, boolean alwaysPrefix)
uriToPrefixMap
parameter, or with a namespace URI if a prefix does not exist
and the alwaysPrefix
parameter is true
.
feature
- EStructuralFeature object that represents an XML element or attribute.path
- the path expression from the root till the current XML element or attribute.uriToPrefixMap
- namespace URI to prefix map.alwaysPrefix
- if true
and no prefix is defined for the namespace of the XML element or attribute, for
prefix is used the namespace URI.public static int getSeparatorPosition(String path)
public static org.eclipse.emf.ecore.EPackage getRootPackage(Collection packageCollection)
packageCollection
- collection of EPackage objects
public static org.eclipse.emf.ecore.sdo.EDataObject createRootObject(org.eclipse.emf.ecore.EPackage epackage)
epackage
package.
epackage
- specifies the package which root class is used in the object creation
epackage
package. If the package has no root
class null
is returned.public static void updatePackageRegistry(Collection packageCollection, org.eclipse.emf.ecore.EPackage.Registry packageRegistry)
packageCollection
- a collection of EPackagespackageRegistry
- a package registrypublic static void updateFactoryInstances(Collection packageCollection)
packageCollection
- collection of EPackage objectspublic static org.eclipse.emf.ecore.EClass getRootClass(org.eclipse.emf.ecore.EPackage epackage)
public void checkPackagesForConformity(Collection packageCollection, boolean isNamespaceAware) throws Exception
packageCollection
- the Ecore model package collection.isNamespaceAware
- if true
siblings with case-insensitive equality in names but from different namespaces
will be considered different.
Exception
- if there are siblings with case-insenstive equal names and the XML elements or attributes are in the
same namespace.
Exception
- if there are siblings with case-insensitive equal names and the XML elements or attributes are in
different namespaces but the isNamespaceAware
is false.public Map parseNamespaces(String namespaces, boolean isPrefixToURIMap) throws Exception
isPrefixToURIMap
parameter.
namespaces
- string object describing a mapping between prefixes and namespace URIs. Each mapping is delimited by
an end-of-line character. On each line the prefix is delimited from the namespace URI by an equal
sign.isPrefixToURIMap
- if true
the created map is prefix to URI map, otherwise it is a URI to prefix map.
namespaces
attribute.
Exception
- if the namespace mapping format (prefix=namespaceURI) is not obeyed.public Collection getPackageCollection(String xsdFile) throws Exception
Collection
containing all packages in the model.
xsdFile
- specifies the location of the XML Schema File.
Exception
- if the XML Schema file is not found or is not valid XML Schema.public org.eclipse.emf.ecore.sdo.EDataObject createRootObject(String xsdFile) throws Exception
xsdFile
file.
xsdFile
- specifies an XML Schema file.
Exception
- if the specified file does not exist or contains an invalid XML Schema.
Exception
- if the XML Schema does not define a root elementpublic org.eclipse.emf.ecore.EStructuralFeature getFeature(org.eclipse.emf.ecore.EClass eclass, String name, Map prefixToURIMap) throws Exception
eclass
- the EClass object which features are searched.name
- the name of the XML element or attribute, probably with namespace prefix.prefixToURIMap
- prefix to namespace URI map.
name
parameter.
Exception
- if no feature matches the specified name.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |