com.sodius.mdw.core.model
Interface MDWObject

All Superinterfaces:
Comparable<Object>
All Known Subinterfaces:
MDWEObject

public interface MDWObject
extends Comparable<Object>

MDWObject is the root of all modeled objects. Most of method names start with "e" to distinguish the MDWorkbench methods from the client methods.

It provides support to call scripts, and gives access to the related model and the metamodel.

This interface is not intended to be implemented by clients.


Method Summary
 int compareTo(Object o)
          Compares this object with the specified object for order using the toString() method.
 ExtendedClass eExtendedClass()
          Returns the type which gives reflective access to structural features.
 boolean eIsInstanceOf(String typeName)
          Determines wheter this object is an instance of the specified type.
 boolean eIsInstanceOf(String typeName, String profileName)
          Determines wheter this object is an instance of the specified type and if it matches the specified profile name.
 boolean eIsProfiled(String profileName, boolean includeSubTypes)
          Determines wheter this object matches the specified profile name.
 boolean eIsRemoved()
          Answers wheter this object is tagged as removed.
 Metamodel eMetamodel()
          Returns the metamodel to which this object is related.
 String eMetaTypeName()
          Returns the simple name of the meta-type ("Actor" or "Activity" for example).
 Model eModel()
          Returns the containing model, or null.
 void eRemove()
          Tag this object as removed.
 void eSetUniqueID(String uniqueID)
          Sets the unique ID of this object.
 String eUniqueID()
          Returns the ID which uniquely identifies the object, and which is constant in time.
 Object superScript(String scriptName)
          Invokes the specified script defined on the super-type.
 Object superScript(String scriptName, List<?> arguments)
          Invokes the specified script defined on the super-type.
 boolean toBoolean(String scriptName)
          Invokes the specified script and returns a boolean representation of the evaluation result.
 boolean toBoolean(String scriptName, List<?> arguments)
          Invokes the specified script and returns a boolean representation of the evaluation result.
 byte toByte(String scriptName)
          Invokes the specified script and returns a byte representation of the evaluation result.
 byte toByte(String scriptName, List<?> arguments)
          Invokes the specified script and returns a byte representation of the evaluation result.
 char toChar(String scriptName)
          Invokes the specified script and returns a char representation of the evaluation result.
 char toChar(String scriptName, List<?> arguments)
          Invokes the specified script and returns a char representation of the evaluation result.
 double toDouble(String scriptName)
          Invokes the specified script and returns a double representation of the evaluation result.
 double toDouble(String scriptName, List<?> arguments)
          Invokes the specified script and returns a double representation of the evaluation result.
 float toFloat(String scriptName)
          Invokes the specified script and returns a float representation of the evaluation result.
 float toFloat(String scriptName, List<?> arguments)
          Invokes the specified script and returns a float representation of the evaluation result.
 int toInt(String scriptName)
          Invokes the specified script and returns a int representation of the evaluation result.
 int toInt(String scriptName, List<?> arguments)
          Invokes the specified script and returns a int representation of the evaluation result.
<E> MDWList<E>
toList(Collection<E> values)
          Converts the specified collection to a new modifiable MDWList.
<E> MDWList<E>
toList(E[] values)
          Converts the specified array to a new modifiable MDWList.
<E> MDWList<E>
toList(Iterator<E> values)
          Converts the specified iterator to a new modifiable MDWList.
<T> MDWList<T>
toList(String scriptName)
          Invokes the specified script and returns a MDWList representation of the evaluation result.
<T> MDWList<T>
toList(String scriptName, List<?> arguments)
          Invokes the specified script and returns a MDWList representation of the evaluation result.
 long toLong(String scriptName)
          Invokes the specified script and returns a long representation of the evaluation result.
 long toLong(String scriptName, List<?> arguments)
          Invokes the specified script and returns a long representation of the evaluation result.
 Object toObject(String scriptName)
          Invokes the specified script.
 Object toObject(String scriptName, List<?> arguments)
          Invokes the specified script.
<T> MDWSet<T>
toSet(String scriptName)
          Invokes the specified script and returns a MDWSet representation of the evaluation result.
<T> MDWSet<T>
toSet(String scriptName, List<?> arguments)
          Invokes the specified script and returns a MDWSet representation of the evaluation result.
 short toShort(String scriptName)
          Invokes the specified script and returns a short representation of the evaluation result.
 short toShort(String scriptName, List<?> arguments)
          Invokes the specified script and returns a short representation of the evaluation result.
 String toString(String scriptName)
          Invokes the specified script and returns a String representation of the evaluation result.
 String toString(String scriptName, List<?> arguments)
          Invokes the specified script and returns a String representation of the evaluation result.
 

Method Detail

eModel

Model eModel()
Returns the containing model, or null.

The returned model is the one used to create this object (Model.create()), or the one to which the object has been added (Model.add()).

Returns:
the containing model, or null (when the object is removed).
See Also:
Model.create(String), Model.add(MDWObject)

eMetamodel

Metamodel eMetamodel()
Returns the metamodel to which this object is related.

Returns:
the metamodel used by this object.
Throws:
InvalidCallException - if this object is not attached to a model.

eMetaTypeName

String eMetaTypeName()
Returns the simple name of the meta-type ("Actor" or "Activity" for example).

Returns:
the simple name of the meta-type.

eUniqueID

String eUniqueID()
Returns the ID which uniquely identifies the object, and which is constant in time.

This ID is not generated by the framework, a MDWObject may not have a unique ID. The returned ID is the one that has been set using eSetUniqueID().

This ID must be unique during the lifetime of this object, and must be constant between multiple sessions. Reloading a model must assign the same unique ID for each element.

Returns:
the unique ID of this object, null if no ID has been set.

eSetUniqueID

void eSetUniqueID(String uniqueID)
Sets the unique ID of this object.

This ID must be unique during the lifetime of this object, and must be constant between multiple sessions. Reloading a model must assign the same unique ID for each element.

Parameters:
uniqueID - the unique ID of this object.

compareTo

int compareTo(Object o)
Compares this object with the specified object for order using the toString() method.

Caution: while this implementation may be statisfying for a natural ordering based on toString(), it may have no sense to compare model elements this way. It is always a good practice to sort model elements by defining your own Comparator which may handle specific features.

Specified by:
compareTo in interface Comparable<Object>
See Also:
Comparable, Comparator, Collections.sort(java.util.List, java.util.Comparator)

eIsInstanceOf

boolean eIsInstanceOf(String typeName)
Determines wheter this object is an instance of the specified type.

The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Classifier" for example), or a simple name ("Classifier"), if this name is unique in the metamodel.

Parameters:
typeName - the type name to compare with.
Returns:
true if this object's type matches the specified type or one of its subtype, false otherwise.
Throws:
InvalidCallException - if this object is not attached to a model.
NoSuchTypeException - if the specified type does not exists

eIsInstanceOf

boolean eIsInstanceOf(String typeName,
                      String profileName)
Determines wheter this object is an instance of the specified type and if it matches the specified profile name.

The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Classifier" for example), or a simple name ("Classifier"), if this name is unique in the metamodel.

Parameters:
typeName - the type name to compare with.
profileName - the name of the profile type this instance must match.
Returns:
true if this object's type matches the specified type or one of its subtype, false otherwise.
Throws:
InvalidCallException - if this object is not attached to a model or if this API is not called during an MDWorkbench evaluation.
NoSuchTypeException - if the specified type does not exists

eIsProfiled

boolean eIsProfiled(String profileName,
                    boolean includeSubTypes)
Determines wheter this object matches the specified profile name.

Parameters:
profileName - the name of the profile type this instance must match.
includeSubTypes - determines wheter to check for sub profile types.
Returns:
true if this object's type matches the specified profile type or one of its subtype, false otherwise.
Throws:
InvalidCallException - if this object is not attached to a model or if this API is not called during an MDWorkbench evaluation.
NoSuchTypeException - if the specified type does not exists

eIsRemoved

boolean eIsRemoved()
Answers wheter this object is tagged as removed.

When removed, an object is no longer attached to a model and you can't anymore call scripts on it.

Returns:
true if the object is removed, false otherwise.

eRemove

void eRemove()
Tag this object as removed. Has no effect if the object is already tagged as removed.

This method will:

Once the object is tagged as removed, it should not be accessible from other objects and from its model.


toObject

Object toObject(String scriptName)
Invokes the specified script.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
the script result, or null if the scripts returns nothing.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed.

toObject

Object toObject(String scriptName,
                List<?> arguments)
Invokes the specified script.

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
the script result, or null if the scripts returns nothing.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed.

toString

String toString(String scriptName)
Invokes the specified script and returns a String representation of the evaluation result.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
a String representation of the script result, an empty String if the result is null .
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed.
See Also:
String.valueOf(java.lang.Object)

toString

String toString(String scriptName,
                List<?> arguments)
Invokes the specified script and returns a String representation of the evaluation result.

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
a String representation of the script result, an empty String if the result is null .
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed.
See Also:
String.valueOf(java.lang.Object)

toBoolean

boolean toBoolean(String scriptName)
Invokes the specified script and returns a boolean representation of the evaluation result.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

If the script result is:

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
a boolean representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a boolean.
See Also:
Boolean.valueOf(java.lang.String)

toBoolean

boolean toBoolean(String scriptName,
                  List<?> arguments)
Invokes the specified script and returns a boolean representation of the evaluation result.

If the script result is:

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
a boolean representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a boolean.
See Also:
Boolean.valueOf(java.lang.String)

toInt

int toInt(String scriptName)
Invokes the specified script and returns a int representation of the evaluation result.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

If the script result is:

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
an int representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a int.
See Also:
Integer.parseInt(java.lang.String)

toInt

int toInt(String scriptName,
          List<?> arguments)
Invokes the specified script and returns a int representation of the evaluation result.

If the script result is:

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
an int representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a int.
See Also:
Integer.parseInt(java.lang.String)

toLong

long toLong(String scriptName)
Invokes the specified script and returns a long representation of the evaluation result.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

If the script result is:

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
a long representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a long.
See Also:
Long.parseLong(java.lang.String)

toLong

long toLong(String scriptName,
            List<?> arguments)
Invokes the specified script and returns a long representation of the evaluation result.

If the script result is:

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
a long representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a long.
See Also:
Long.parseLong(java.lang.String)

toShort

short toShort(String scriptName)
Invokes the specified script and returns a short representation of the evaluation result.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

If the script result is:

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
a short representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a short.
See Also:
Short.parseShort(java.lang.String)

toShort

short toShort(String scriptName,
              List<?> arguments)
Invokes the specified script and returns a short representation of the evaluation result.

If the script result is:

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
a short representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a short.
See Also:
Short.parseShort(java.lang.String)

toFloat

float toFloat(String scriptName)
Invokes the specified script and returns a float representation of the evaluation result.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

If the script result is:

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
a float representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a float.
See Also:
Float.parseFloat(java.lang.String)

toFloat

float toFloat(String scriptName,
              List<?> arguments)
Invokes the specified script and returns a float representation of the evaluation result.

If the script result is:

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
a float representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a float.
See Also:
Float.parseFloat(java.lang.String)

toDouble

double toDouble(String scriptName)
Invokes the specified script and returns a double representation of the evaluation result.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

If the script result is:

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
a double representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a double.
See Also:
Double.parseDouble(java.lang.String)

toDouble

double toDouble(String scriptName,
                List<?> arguments)
Invokes the specified script and returns a double representation of the evaluation result.

If the script result is:

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
a double representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a double.
See Also:
Double.parseDouble(java.lang.String)

toByte

byte toByte(String scriptName)
Invokes the specified script and returns a byte representation of the evaluation result.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

If the script result is:

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
a byte representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a byte.
See Also:
Byte.parseByte(java.lang.String)

toByte

byte toByte(String scriptName,
            List<?> arguments)
Invokes the specified script and returns a byte representation of the evaluation result.

If the script result is:

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
a byte representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a byte.
See Also:
Byte.parseByte(java.lang.String)

toChar

char toChar(String scriptName)
Invokes the specified script and returns a char representation of the evaluation result.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

If the script result is:

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
a byte representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a char.

toChar

char toChar(String scriptName,
            List<?> arguments)
Invokes the specified script and returns a char representation of the evaluation result.

If the script result is:

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
a byte representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed, or the script result can't be converted to a char.

toSet

<T> MDWSet<T> toSet(String scriptName)
Invokes the specified script and returns a MDWSet representation of the evaluation result. MDWSet provides facilities to invoke scripts on each MDWObject element of the Set.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

If the script result is:

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
a modifiable MDWSet representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed.
Since:
MDWorkbench 3.0.0

toSet

<T> MDWSet<T> toSet(String scriptName,
                    List<?> arguments)
Invokes the specified script and returns a MDWSet representation of the evaluation result. MDWSet provides facilities to invoke scripts on each MDWObject element of the Set.

If the script result is:

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
a modifiable MDWSet representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed.
Since:
MDWorkbench 3.0.0

toList

<T> MDWList<T> toList(String scriptName)
Invokes the specified script and returns a MDWList representation of the evaluation result. MDWList provides facilities to invoke scripts on each MDWObject element of the list.

The specified name can reference a structural feature (EAttribute or EReference) defined in the related metamodel.

If the script result is:

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
a modifiable MDWList representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed.

toList

<T> MDWList<T> toList(String scriptName,
                      List<?> arguments)
Invokes the specified script and returns a MDWList representation of the evaluation result. MDWList provides facilities to invoke scripts on each MDWObject element of the list.

If the script result is:

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
a modifiable MDWList representation of the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed.

toList

<E> MDWList<E> toList(Collection<E> values)
Converts the specified collection to a new modifiable MDWList. MDWList provides facilities to invoke scripts on each MDWObject element of the list.

Returns:
a modifiable MDWList containing each element of the specified collection.

toList

<E> MDWList<E> toList(Iterator<E> values)
Converts the specified iterator to a new modifiable MDWList. MDWList provides facilities to invoke scripts on each MDWObject element of the list.

Returns:
a modifiable MDWList containing each element of the specified iterator.

toList

<E> MDWList<E> toList(E[] values)
Converts the specified array to a new modifiable MDWList. MDWList provides facilities to invoke scripts on each MDWObject element of the list.

Returns:
a modifiable MDWList containing each element of the specified array.

superScript

Object superScript(String scriptName)
Invokes the specified script defined on the super-type.

This is useful when overriding a script: when you redefine a script on a subtype, you're still able to call the super-type script and refine its behavior.

If the related type has many super-types (for example in UML, Classifier inherits from GeneralizableElement and from Namespace), the specified script may be defined on more than one super-type, and the call can be ambiguous. To resolve this ambiguity, the expected script can be prefixed by its defining super-type name. For example, from a Classifier element, you can call self.superScript("Namespace.myScript").

Parameters:
scriptName - the name of the script to evaluate (which must not expect any parameter).
Returns:
the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed.
NoSuchTypeException - if the super-type (if specified) does not exists

superScript

Object superScript(String scriptName,
                   List<?> arguments)
Invokes the specified script defined on the super-type.

This is useful when overriding a script: when you redefine a script on a subtype, you're still able to call the super-type script and refine its behavior.

If the related type has many super-types (for example in UML, Classifier inherits from GeneralizableElement and from Namespace), the specified script may be defined on more than one super-type, and the call can be ambiguous. To resolve this ambiguity, the expected script can be prefixed by its defining super-type name. For example, from a Classifier element, you can call self.superScript("Namespace.myScript").

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate.
arguments - the script arguments.
Returns:
the script result.
Throws:
InvalidCallException - if the script does not exist or is not visible.
EvaluationException - if the evaluation of the script failed.
NoSuchTypeException - if the super-type (if specified) does not exists

eExtendedClass

ExtendedClass eExtendedClass()
Returns the type which gives reflective access to structural features.

Returns:
the type which gives reflective access to structural features.
Since:
MDWorkbench 3.0.0