www.sdmetrics.com

com.sdmetrics.model
Class ModelElement

java.lang.Object
  extended by com.sdmetrics.model.ModelElement

public class ModelElement
extends java.lang.Object

Represents a model element of a model. A model element stores the values of its attributes (which includes outgoing references to other model elements), and keeps track of incoming references from other model elements.


Constructor Summary
ModelElement(MetaModelElement type)
          Creates a new element.
 
Method Summary
static java.util.Comparator<ModelElement> getComparator()
          Returns a comparator to sort model elements by the order in which they are defined in the XMI file.
 java.lang.String getFullName()
          Gets the fully qualified name of this model element.
 boolean getLinksIgnored()
          Tests whether cross-references to this element should be ignored according to the element filter settings.
 java.lang.String getName()
          Gets the name of this model element.
 java.util.Collection<ModelElement> getOwnedElements()
          Gets the model elements owned by this element.
 ModelElement getOwner()
          Gets the owner of this model element.
 java.lang.String getPlainAttribute(java.lang.String attrName)
          Retrieves the value of a single-valued data attribute for this model element.
 ModelElement getRefAttribute(java.lang.String attrName)
          Retrieves the model element referenced by a single-valued cross-reference attribute.
 java.util.Collection<ModelElement> getRelations(java.lang.String relationName)
          Returns the set of model elements that point to this model element via a specified cross-reference attribute.
 java.util.Collection<?> getSetAttribute(java.lang.String attrName)
          Retrieves the set of values for a multi-valued attribute.
 MetaModelElement getType()
          Returns the metamodel element type of this model element.
 java.lang.String getXMIID()
          Gets the XMI ID of this model element.
 java.lang.String toString()
          Returns the XMI ID of the model element as its string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModelElement

public ModelElement(MetaModelElement type)
Creates a new element.

Parameters:
type - The element type of the model element.
Method Detail

getRelations

public java.util.Collection<ModelElement> getRelations(java.lang.String relationName)
Returns the set of model elements that point to this model element via a specified cross-reference attribute.

Parameters:
relationName - Name of the cross-reference attribute.
Returns:
The set of model elements that point to this model element with the specified cross-reference attribute. May be null if there are no such referencing model elements.

getPlainAttribute

public java.lang.String getPlainAttribute(java.lang.String attrName)
Retrieves the value of a single-valued data attribute for this model element.

Parameters:
attrName - Name of the attribute.
Returns:
Value of the attribute.

getRefAttribute

public ModelElement getRefAttribute(java.lang.String attrName)
Retrieves the model element referenced by a single-valued cross-reference attribute.

Parameters:
attrName - Name of the cross-reference attribute.
Returns:
the referenced model element, or null if the reference is empty or the reference should be ignored as per filter settings.

getSetAttribute

public java.util.Collection<?> getSetAttribute(java.lang.String attrName)
Retrieves the set of values for a multi-valued attribute. For cross-reference attributes, this is a collection of model elements. For data attributes, the collection contains strings.

Parameters:
attrName - Name of the multi-valued attribute.
Returns:
Collection of model elements or strings stored by the attribute.

getLinksIgnored

public boolean getLinksIgnored()
Tests whether cross-references to this element should be ignored according to the element filter settings.

Returns:
true if the cross-references to this element should be ignored

getType

public MetaModelElement getType()
Returns the metamodel element type of this model element.

Returns:
The type of this element

getFullName

public java.lang.String getFullName()
Gets the fully qualified name of this model element. This is the path to the model in the containment hierarchy, with the names of the owner elements separated by dots.

Returns:
Fully qualified name of this model element

getOwner

public ModelElement getOwner()
Gets the owner of this model element.

Returns:
Owner of the model element, null for root model elements.

getOwnedElements

public java.util.Collection<ModelElement> getOwnedElements()
Gets the model elements owned by this element.

Returns:
A collection of all that this model element owns.

getXMIID

public java.lang.String getXMIID()
Gets the XMI ID of this model element.

Returns:
XMI ID of the model element.

getName

public java.lang.String getName()
Gets the name of this model element.

Returns:
The unqualified name of the model element

toString

public java.lang.String toString()
Returns the XMI ID of the model element as its string representation.

Overrides:
toString in class java.lang.Object

getComparator

public static java.util.Comparator<ModelElement> getComparator()
Returns a comparator to sort model elements by the order in which they are defined in the XMI file.

Returns:
Model element comparator

www.sdmetrics.com