net.sourceforge.nrl.parser.model
Class ModelUtils

java.lang.Object
  extended by net.sourceforge.nrl.parser.model.ModelUtils

public class ModelUtils
extends Object

Utility methods for working with model objects.


Constructor Summary
ModelUtils()
           
 
Method Summary
static IAttribute getAttributeByOriginalName(IClassifier container, String originalName, boolean includeInherited)
          Finds an attribute within the given IClassifier whose originalName matches that specified.
static String getLocation(IPackage pkg)
          Return the file location (a URL as a String) that a package was loaded from.
static String getXMLNamespaceURI(IAttribute attr)
          Return the namespace an attribute is in.
static String getXMLNamespaceURI(IModelElement element)
          Return the namespace an model element (i.e.
static String getXSDPath(IAttribute attr)
          Return an XPath to an attribute inside a schema.
static boolean isAttributeAnXMLAttribute(IAttribute attr)
          Return true if an attribute represents an XML attribute (as opposed to an XML element).
static boolean isAttributeAnXMLElement(IAttribute attr)
          Return true if an attribute represents an XML element (rather than an XML attribute).
static boolean isRenamedXSDAttribute(IAttribute attr)
          Returnt true if an attribute is an XML attribute or element that had to be renamed by the model loader due to a naming conflict.
static boolean isXSDModelElement(IModelElement modelElement)
          Detects if an IModelElement originates from an XSD model i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelUtils

public ModelUtils()
Method Detail

getAttributeByOriginalName

public static IAttribute getAttributeByOriginalName(IClassifier container,
                                                    String originalName,
                                                    boolean includeInherited)
Finds an attribute within the given IClassifier whose originalName matches that specified.

Parameters:
container - The IClassifier to search for attributes.
originalName - The name of the attribute as specified in the original e.g. XSD
includeInherited -
Returns:
the attribute or null if none found

getLocation

public static String getLocation(IPackage pkg)
Return the file location (a URL as a String) that a package was loaded from.

Parameters:
pkg - the package
Returns:
the location, may be null for internal packages

getXMLNamespaceURI

public static String getXMLNamespaceURI(IAttribute attr)
Return the namespace an attribute is in. This only works on attributes retrieved from XML schema, and will return null unless the attribute is in a target namespace.

Parameters:
attr - the attribute
Returns:
a namespace URI or null

getXMLNamespaceURI

public static String getXMLNamespaceURI(IModelElement element)
Return the namespace an model element (i.e. type) is in. This only works on attributes retrieved from XML schema, and will return null unless the element is in a target namespace.

Parameters:
element - the model element
Returns:
a namespace URI or null

getXSDPath

public static String getXSDPath(IAttribute attr)
Return an XPath to an attribute inside a schema. This is attached if isRenamedXSDAttribute(IAttribute) returns true and can be used by applications that require JAXB bindings.

Parameters:
attr - the attribute
Returns:
the path

isAttributeAnXMLElement

public static boolean isAttributeAnXMLElement(IAttribute attr)
Return true if an attribute represents an XML element (rather than an XML attribute). If this returns false this does not mean that the attribute is an XML attribute (it may be a UML attribute, for example). Use isAttributeAnXMLAttribute(IAttribute) instead.

Parameters:
attr - the attribute
Returns:
true if the attribute is an XML element

isAttributeAnXMLAttribute

public static boolean isAttributeAnXMLAttribute(IAttribute attr)
Return true if an attribute represents an XML attribute (as opposed to an XML element). Use isAttributeAnXMLElement(IAttribute) to find out if it's an XML element.

Parameters:
attr - the attribute
Returns:
true if the attribute is an XML attribute

isRenamedXSDAttribute

public static boolean isRenamedXSDAttribute(IAttribute attr)
Returnt true if an attribute is an XML attribute or element that had to be renamed by the model loader due to a naming conflict.

Parameters:
attr - the attribute
Returns:
true if the attribute was renamed

isXSDModelElement

public static boolean isXSDModelElement(IModelElement modelElement)
Detects if an IModelElement originates from an XSD model i.e. is it an XSDPackage, XSDClassifier or XSDDataType.

Parameters:
modelElement - the IModelElement to inspect
Returns:
true if the supplied modelElement originates from an XSD model, false otherwise.


Copyright © 2006-2013. All Rights Reserved.