org.biomage.tools.generate_classes
Class XMIParseHelpers

java.lang.Object
  extended by org.biomage.tools.generate_classes.XMIParseHelpers

public final class XMIParseHelpers
extends java.lang.Object


Nested Class Summary
static class XMIParseHelpers.IDREFException
          Description: Thrown when a lookup fails and the top element has an IDREF attribute.
 
Field Summary
static int AGGREGATE
          Is Co-owned by one or more objects
static int COMPOSITE
          Is solely owned by a containing object
static int NOT_AGGR
          Is Independent
static java.lang.String tobeIdentifiable
           
 
Constructor Summary
XMIParseHelpers()
           
 
Method Summary
static org.w3c.dom.Element getAssociationEndClassifier(org.w3c.dom.Element associationEndElement)
          Description: Returns the classifier of the association end element.
static int getAssociationEndMultiplicityRangeLower(org.w3c.dom.Element associationEndElement)
          Description: Returns the multiplicity range lower of the association end element.
static int getAssociationEndMultiplicityRangeUpper(org.w3c.dom.Element associationEndElement)
          Description: Returns the multiplicity range upper of the association end element.
static org.w3c.dom.Element getAttributeClassifier(org.w3c.dom.Element attributeElement)
          Description: Returns the classifier of the association end element.
static int getAttributeMultiplicityRangeLower(org.w3c.dom.Element attributeElement)
          Description: Returns the multiplicity range lower of the association end element.
static org.w3c.dom.NodeList getConstrainedElements(org.w3c.dom.Element constraintElement)
          Description: Returns a NodeList of constrained elements.
static java.lang.String getConstraintString(org.w3c.dom.Element constraintElement)
          Description: Returns the string representing the constraint.
static java.lang.String getElementID(org.w3c.dom.Element element)
          Description: Returns the ID of the element.
static java.lang.String getElementIDRef(org.w3c.dom.Element element)
          Description: Returns the IDRef of the element.
static java.lang.String getElementName(org.w3c.dom.Element element)
          Description: Returns the name of the element.
static java.lang.String getElementText(org.w3c.dom.Element element)
          Description: Returns the text of the element.
static java.lang.String getElementValue(org.w3c.dom.Element element)
          Description: Returns the value of the element.
static org.w3c.dom.Element getFirstElementByTagName(org.w3c.dom.Element element, java.lang.String sName)
          Description: Returns the first descendant Element with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.
static org.w3c.dom.Element getFirstElementByTagNameArray(org.w3c.dom.Element element, java.lang.String[] asName)
          Description: Returns the first descendant Element with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.
static java.lang.String getInitialValue(org.w3c.dom.Element attributeElement)
          Description: Returns the classifier of the association end element.
static org.w3c.dom.NodeList getOperationElements(org.w3c.dom.Element classElement)
          Description: Returns a NodeList of operation elements.
static java.lang.String getOperationSpecification(org.w3c.dom.Element operationElement)
          Description: Returns the specification(semantics) of an operation.
static org.w3c.dom.NodeList getParameterElements(org.w3c.dom.Element operationElement)
          Description: Returns a NodeList of parameter elements.
static java.lang.String getParameterKind(org.w3c.dom.Element parameterElement)
          Description: Returns the kind of the parameter ("return", "inout", etc.).
static java.lang.String getParameterTypeID(org.w3c.dom.Element parameterElement)
          Description: Returns the id of the parameter element's data type.
static java.lang.String getTokenValue(org.w3c.dom.Document doc, java.lang.String token)
          Description: Returns the text of the element with name of token.
static boolean isAssociationEndNavigable(org.w3c.dom.Element associationEndElement)
          Description: Returns whether the association end is navigable.
static boolean isAssociationEndOrdered(org.w3c.dom.Element associationEndElement)
          Description: Returns whether the association end is ordered.
static boolean isIdentifiable(org.w3c.dom.Element myclass)
          Description: Returns whether or not a given class is Identifiable -- useful in the C++ generation code.
static void setIdentifiable(org.w3c.dom.Element myclass, boolean value)
          Description: Sets up a class as identifiable or not.
static void setIdentifiable(org.w3c.dom.Element myclass, java.lang.String value)
          Description: Sets up a class as identifiable or not.
static int typeAssociationEndAggregate(org.w3c.dom.Element associationEndElement)
          Description: Returns whether the association end is aggregate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_AGGR

public static final int NOT_AGGR
Is Independent

See Also:
Constant Field Values

AGGREGATE

public static final int AGGREGATE
Is Co-owned by one or more objects

See Also:
Constant Field Values

COMPOSITE

public static final int COMPOSITE
Is solely owned by a containing object

See Also:
Constant Field Values

tobeIdentifiable

public static final java.lang.String tobeIdentifiable
See Also:
Constant Field Values
Constructor Detail

XMIParseHelpers

public XMIParseHelpers()
Method Detail

getAssociationEndClassifier

public static org.w3c.dom.Element getAssociationEndClassifier(org.w3c.dom.Element associationEndElement)
                                                       throws java.lang.Exception
Description: Returns the classifier of the association end element.

Parameters:
associationEndElement: - the association end element tree.

Returns:
The classifier of the association end element.

Throws:
java.lang.Exception

getAttributeClassifier

public static org.w3c.dom.Element getAttributeClassifier(org.w3c.dom.Element attributeElement)
                                                  throws java.lang.Exception
Description: Returns the classifier of the association end element.

Parameters:
associationEndElement: - the association end element tree.

Returns:
The classifier of the association end element.

Throws:
java.lang.Exception

getInitialValue

public static java.lang.String getInitialValue(org.w3c.dom.Element attributeElement)
                                        throws java.lang.Exception
Description: Returns the classifier of the association end element.

Parameters:
attributeElement: - the attribute element tree.

Returns:
The initial value for the attribute or the empty string.

Throws:
java.lang.Exception

getConstraintString

public static java.lang.String getConstraintString(org.w3c.dom.Element constraintElement)
                                            throws java.lang.Exception
Description: Returns the string representing the constraint.

Parameters:
constraintElement: - the constraint element tree.

Returns:
the String representing the constraint.

Throws:
java.lang.Exception

getConstrainedElements

public static org.w3c.dom.NodeList getConstrainedElements(org.w3c.dom.Element constraintElement)
                                                   throws java.lang.Exception
Description: Returns a NodeList of constrained elements.

Parameters:
constraintElement: - the constraint element tree.

Returns:
a NodeList of constrained elements.

Throws:
java.lang.Exception

getOperationElements

public static org.w3c.dom.NodeList getOperationElements(org.w3c.dom.Element classElement)
                                                 throws java.lang.Exception
Description: Returns a NodeList of operation elements.

Parameters:
classElement: - the class element tree.

Returns:
a NodeList of operation elements.

Throws:
java.lang.Exception

getParameterElements

public static org.w3c.dom.NodeList getParameterElements(org.w3c.dom.Element operationElement)
                                                 throws java.lang.Exception
Description: Returns a NodeList of parameter elements.

Parameters:
oeprationElement: - the operation element tree.

Returns:
a NodeList of parameter elements.

Throws:
java.lang.Exception

getParameterTypeID

public static java.lang.String getParameterTypeID(org.w3c.dom.Element parameterElement)
                                           throws java.lang.Exception
Description: Returns the id of the parameter element's data type.

Parameters:
paramElement: - the parameter element tree.

Returns:
The parameterID as a string. Can be null.

Throws:
java.lang.Exception

getParameterKind

public static java.lang.String getParameterKind(org.w3c.dom.Element parameterElement)
                                         throws java.lang.Exception
Description: Returns the kind of the parameter ("return", "inout", etc.).

Parameters:
paramElement: - the parameter element tree.

Returns:
The kind of parameter.

Throws:
java.lang.Exception

getOperationSpecification

public static java.lang.String getOperationSpecification(org.w3c.dom.Element operationElement)
                                                  throws java.lang.Exception
Description: Returns the specification(semantics) of an operation.

Parameters:
operationElement: - the operation element tree.

Returns:
The specification as a String. Can be null.

Throws:
java.lang.Exception

getAssociationEndMultiplicityRangeLower

public static int getAssociationEndMultiplicityRangeLower(org.w3c.dom.Element associationEndElement)
                                                   throws java.lang.Exception
Description: Returns the multiplicity range lower of the association end element.

Parameters:
associationEndElement: - the association end element tree.

Returns:
The multiplicity range lower of the association end element (-1 if no lower).

Throws:
java.lang.Exception

getAssociationEndMultiplicityRangeUpper

public static int getAssociationEndMultiplicityRangeUpper(org.w3c.dom.Element associationEndElement)
                                                   throws java.lang.Exception
Description: Returns the multiplicity range upper of the association end element.

Parameters:
associationEndElement: - the association end element tree.

Returns:
The multiplicity range upper of the association end element (-1 if no upper).

Throws:
java.lang.Exception

getAttributeMultiplicityRangeLower

public static int getAttributeMultiplicityRangeLower(org.w3c.dom.Element attributeElement)
                                              throws java.lang.Exception
Description: Returns the multiplicity range lower of the association end element.

Parameters:
associationEndElement: - the association end element tree.

Returns:
The multiplicity range lower of the association end element (-1 if no lower).

Throws:
java.lang.Exception

getElementID

public static java.lang.String getElementID(org.w3c.dom.Element element)
                                     throws java.lang.Exception
Description: Returns the ID of the element.

Parameters:
element: - the element tree.

Returns:
The ID of the element.

Throws:
java.lang.Exception

getElementIDRef

public static java.lang.String getElementIDRef(org.w3c.dom.Element element)
                                        throws java.lang.Exception
Description: Returns the IDRef of the element.

Parameters:
element: - the element tree.

Returns:
The IDRef of the element.

Throws:
java.lang.Exception

getElementValue

public static java.lang.String getElementValue(org.w3c.dom.Element element)
                                        throws java.lang.Exception
Description: Returns the value of the element.

Parameters:
element: - the element tree.

Returns:
The value of the element.

Throws:
java.lang.Exception

getElementName

public static java.lang.String getElementName(org.w3c.dom.Element element)
                                       throws java.lang.Exception
Description: Returns the name of the element.

Parameters:
element: - the element tree.

Returns:
The name of the element.

Throws:
java.lang.Exception

getElementText

public static java.lang.String getElementText(org.w3c.dom.Element element)
                                       throws java.lang.Exception
Description: Returns the text of the element.

Parameters:
element: - the element tree.

Returns:
The text of the element.

Throws:
java.lang.Exception

getTokenValue

public static java.lang.String getTokenValue(org.w3c.dom.Document doc,
                                             java.lang.String token)
                                      throws java.lang.Exception
Description: Returns the text of the element with name of token.

Parameters:
doc: - the document which may have an elemnt with a name corresponding to token
token: - name of element to get the text of.

Returns:
The text of the element.

Throws:
java.lang.Exception

getFirstElementByTagName

public static org.w3c.dom.Element getFirstElementByTagName(org.w3c.dom.Element element,
                                                           java.lang.String sName)
Description: Returns the first descendant Element with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.

Parameters:
element: - the element tree.
sName: - name of the tag to match on. The special value "*" matches all tags.

Returns:
The first matching Element, or null if there was no match.


getFirstElementByTagNameArray

public static org.w3c.dom.Element getFirstElementByTagNameArray(org.w3c.dom.Element element,
                                                                java.lang.String[] asName)
                                                         throws XMIParseHelpers.IDREFException,
                                                                java.lang.Exception
Description: Returns the first descendant Element with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.

Parameters:
element: - the element tree.
asName: - array of names of the tags to match on. The special value "*" matches all tags.

Returns:
The first matching Element, or null if there was no match.

Throws:
XMIParseHelpers.IDREFException - is thrown if the lookup fails to find the tag and the element parameter has an idref attribute.

java.lang.Exception

typeAssociationEndAggregate

public static int typeAssociationEndAggregate(org.w3c.dom.Element associationEndElement)
                                       throws java.lang.Exception
Description: Returns whether the association end is aggregate.

Parameters:
associationEndElement: - the association end element tree.

Returns:
True if the association end is aggregate; false otherwise.

Throws:
java.lang.Exception

isAssociationEndNavigable

public static boolean isAssociationEndNavigable(org.w3c.dom.Element associationEndElement)
                                         throws java.lang.Exception
Description: Returns whether the association end is navigable.

Parameters:
associationEndElement: - the association end element tree.

Returns:
True if the association end is navigable; false otherwise.

Throws:
java.lang.Exception

isAssociationEndOrdered

public static boolean isAssociationEndOrdered(org.w3c.dom.Element associationEndElement)
                                       throws java.lang.Exception
Description: Returns whether the association end is ordered.

Parameters:
associationEndElement: - the association end element tree.

Returns:
True if the association end is ordered; false otherwise.

Throws:
java.lang.Exception

isIdentifiable

public static boolean isIdentifiable(org.w3c.dom.Element myclass)
                              throws java.lang.Exception
Description: Returns whether or not a given class is Identifiable -- useful in the C++ generation code.

Parameters:
myclass: - the element which we wish to check.

Returns:
True if the Class is Identifiable; false otherwise.

Throws:
java.lang.Exception

setIdentifiable

public static void setIdentifiable(org.w3c.dom.Element myclass,
                                   boolean value)
                            throws java.lang.Exception
Description: Sets up a class as identifiable or not. Useful for classes that are indirect subclasses of identifiable

Parameters:
myclass: - the element which we wish to identify

value: - whether or not it is true or false.

Throws:
java.lang.Exception

setIdentifiable

public static void setIdentifiable(org.w3c.dom.Element myclass,
                                   java.lang.String value)
                            throws java.lang.Exception
Description: Sets up a class as identifiable or not. Useful for classes that are indirect subclasses of identifiable

Parameters:
myclass: - the element which we wish to identify

value: - whether or not it is true or false.

Throws:
java.lang.Exception