public interface MDWObject extends Comparable<Object>, EModelElement
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.
Modifier and Type | Method and Description |
---|---|
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 whether this object is an instance of the specified type.
|
boolean |
eIsInstanceOf(String typeName,
String profileName)
Determines whether this object is an instance of the specified type and if it matches the specified profile name.
|
boolean |
eIsProfiled(String profileName,
boolean includeSubTypes)
Determines whether this object matches the specified profile name.
|
boolean |
eIsRemoved()
Answers whether 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. |
getEAnnotation, getEAnnotations
eAllContents, eClass, eContainer, eContainingFeature, eContainmentFeature, eContents, eCrossReferences, eGet, eGet, eInvoke, eIsProxy, eIsSet, eResource, eSet, eUnset
eAdapters, eDeliver, eNotify, eSetDeliver
Model eModel()
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()
).
null
(when the object is removed).Model.create(String)
,
Model.add(MDWObject)
Metamodel eMetamodel()
InvalidCallException
- if this object is not attached to a model.String eMetaTypeName()
"Actor"
or "Activity"
for example).String eUniqueID()
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.
null
if no ID has been set.void eSetUniqueID(String uniqueID)
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.
uniqueID
- the unique ID of this object.int compareTo(Object o)
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.
compareTo
in interface Comparable<Object>
Comparable
,
Comparator
,
Collections.sort(java.util.List, java.util.Comparator)
boolean eIsInstanceOf(String typeName)
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.
typeName
- the type name to compare with.true
if this object's type matches the specified type or one of its subtype, false
otherwise.InvalidCallException
- if this object is not attached to a model.NoSuchTypeException
- if the specified type does not existsboolean eIsInstanceOf(String typeName, String profileName)
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.
typeName
- the type name to compare with.profileName
- the name of the profile type this instance must match.true
if this object's type matches the specified type or one of its subtype, false
otherwise.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 existsboolean eIsProfiled(String profileName, boolean includeSubTypes)
profileName
- the name of the profile type this instance must match.includeSubTypes
- determines whether to check for sub profile types.true
if this object's type matches the specified profile type or one of its subtype, false
otherwise.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 existsboolean eIsRemoved()
When removed, an object is no longer attached to a model and you can't anymore call scripts on it.
true
if the object is removed, false
otherwise.void eRemove()
This method will:
EObject
).Once the object is tagged as removed, it should not be accessible from other objects and from its model.
Object toObject(String scriptName)
The specified name can reference a structural feature (EAttribute
or EReference
) defined in the related metamodel.
scriptName
- the name of the script to evaluate (which must not expect any parameter).null
if the scripts returns nothing.InvalidCallException
- if the script does not exist or is not visible.EvaluationException
- if the evaluation of the script failed.Object toObject(String scriptName, List<?> arguments)
The number and type of arguments must match the parameters of the script.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.null
if the scripts returns nothing.InvalidCallException
- if the script does not exist or is not visible.EvaluationException
- if the evaluation of the script failed.String toString(String scriptName)
String
representation of the evaluation result.
The specified name can reference a structural feature (EAttribute
or EReference
) defined in the related metamodel.
scriptName
- the name of the script to evaluate (which must not expect any parameter).String
representation of the script result, an empty String
if the result is null
.InvalidCallException
- if the script does not exist or is not visible.EvaluationException
- if the evaluation of the script failed.String.valueOf(java.lang.Object)
String toString(String scriptName, List<?> arguments)
String
representation of the evaluation result.
The number and type of arguments must match the parameters of the script.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.String
representation of the script result, an empty String
if the result is null
.InvalidCallException
- if the script does not exist or is not visible.EvaluationException
- if the evaluation of the script failed.String.valueOf(java.lang.Object)
boolean toBoolean(String scriptName)
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:
null
: false
is returned.java.lang.Boolean
, its boolean
value is returned.
java.lang.String
, Boolean.valueOf(String)
is used to convert the String
to a boolean
.
scriptName
- the name of the script to evaluate (which must not expect any parameter).boolean
representation of the script result.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
.Boolean.valueOf(java.lang.String)
boolean toBoolean(String scriptName, List<?> arguments)
boolean
representation of the evaluation result.
If the script result is:
null
: false
is returned.java.lang.Boolean
, its boolean
value is returned.
java.lang.String
, Boolean.valueOf(String)
is used to convert the String
to a boolean
.
The number and type of arguments must match the parameters of the script.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.boolean
representation of the script result.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
.Boolean.valueOf(java.lang.String)
int toInt(String scriptName)
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:
null
: 0
is returned.java.lang.Number
, its int
value is returned.
java.lang.String
, Integer.parseInt(String)
is used to convert the String
to a int
.
scriptName
- the name of the script to evaluate (which must not expect any parameter).int
representation of the script result.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
.Integer.parseInt(java.lang.String)
int toInt(String scriptName, List<?> arguments)
int
representation of the evaluation result.
If the script result is:
null
: 0
is returned.java.lang.Number
, its int
value is returned.
java.lang.String
, Integer.parseInt(String)
is used to convert the String
to a int
.
The number and type of arguments must match the parameters of the script.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.int
representation of the script result.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
.Integer.parseInt(java.lang.String)
long toLong(String scriptName)
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:
null
: 0
is returned.java.lang.Number
, its long
value is returned.
java.lang.String
, Long.parseLong(String)
is used to convert the String
to a long
.
scriptName
- the name of the script to evaluate (which must not expect any parameter).long
representation of the script result.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
.Long.parseLong(java.lang.String)
long toLong(String scriptName, List<?> arguments)
long
representation of the evaluation result.
If the script result is:
null
: 0
is returned.java.lang.Number
, its long
value is returned.
java.lang.String
, Long.parseLong(String)
is used to convert the String
to a long
.
The number and type of arguments must match the parameters of the script.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.long
representation of the script result.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
.Long.parseLong(java.lang.String)
short toShort(String scriptName)
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:
null
: 0
is returned.java.lang.Number
, its short
value is returned.
java.lang.String
, Short.parseShort(String)
is used to convert the String
to a short
.
scriptName
- the name of the script to evaluate (which must not expect any parameter).short
representation of the script result.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
.Short.parseShort(java.lang.String)
short toShort(String scriptName, List<?> arguments)
short
representation of the evaluation result.
If the script result is:
null
: 0
is returned.java.lang.Number
, its short
value is returned.
java.lang.String
, Short.parseShort(String)
is used to convert the String
to a short
.
The number and type of arguments must match the parameters of the script.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.short
representation of the script result.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
.Short.parseShort(java.lang.String)
float toFloat(String scriptName)
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:
null
: 0
is returned.java.lang.Number
, its float
value is returned.
java.lang.String
, Float.parseFloat(String)
is used to convert the String
to a float
.
scriptName
- the name of the script to evaluate (which must not expect any parameter).float
representation of the script result.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
.Float.parseFloat(java.lang.String)
float toFloat(String scriptName, List<?> arguments)
float
representation of the evaluation result.
If the script result is:
null
: 0
is returned.java.lang.Number
, its float
value is returned.
java.lang.String
, Float.parseFloat(String)
is used to convert the String
to a float
.
The number and type of arguments must match the parameters of the script.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.float
representation of the script result.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
.Float.parseFloat(java.lang.String)
double toDouble(String scriptName)
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:
null
: 0
is returned.java.lang.Number
, its double
value is returned.
java.lang.String
, Double.parseDouble(String)
is used to convert the String
to a
double
.
scriptName
- the name of the script to evaluate (which must not expect any parameter).double
representation of the script result.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
.Double.parseDouble(java.lang.String)
double toDouble(String scriptName, List<?> arguments)
double
representation of the evaluation result.
If the script result is:
null
: 0
is returned.java.lang.Number
, its double
value is returned.
java.lang.String
, Double.parseDouble(String)
is used to convert the String
to a
double
.
The number and type of arguments must match the parameters of the script.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.double
representation of the script result.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
.Double.parseDouble(java.lang.String)
byte toByte(String scriptName)
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:
null
: 0
is returned.java.lang.Number
, its byte
value is returned.
java.lang.String
, Byte.parseByte(String)
is used to convert the String
to a byte
.
scriptName
- the name of the script to evaluate (which must not expect any parameter).byte
representation of the script result.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
.Byte.parseByte(java.lang.String)
byte toByte(String scriptName, List<?> arguments)
byte
representation of the evaluation result.
If the script result is:
null
: 0
is returned.java.lang.Number
, its byte
value is returned.
java.lang.String
, Byte.parseByte(String)
is used to convert the String
to a byte
.
The number and type of arguments must match the parameters of the script.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.byte
representation of the script result.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
.Byte.parseByte(java.lang.String)
char toChar(String scriptName)
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:
java.lang.Character
, its char
value is returned.
java.lang.String
of one character, its unique character is returned.
scriptName
- the name of the script to evaluate (which must not expect any parameter).byte
representation of the script result.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
.char toChar(String scriptName, List<?> arguments)
char
representation of the evaluation result.
If the script result is:
java.lang.Character
, its char
value is returned.
java.lang.String
of one character, its unique character is returned.
The number and type of arguments must match the parameters of the script.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.byte
representation of the script result.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
.<T> MDWSet<T> toSet(String scriptName)
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:
null
, an empty MDWSet
is returned.
Collection
, Map
, Iterator
or array
), a MDWSet
is
created and wraps these elements.MDWSet
is created containing just this element.T
- the type of elements in the returned collection.scriptName
- the name of the script to evaluate (which must not expect any parameter).MDWSet
representation of the script result.InvalidCallException
- if the script does not exist or is not visible.EvaluationException
- if the evaluation of the script failed.<T> MDWSet<T> toSet(String scriptName, List<?> arguments)
MDWSet
representation of the evaluation result. MDWSet
provides facilities
to invoke scripts on each MDWObject
element of the Set.
If the script result is:
null
, an empty MDWSet
is returned.
Collection
, Map
, Iterator
or array
), a MDWSet
is
created and wraps these elements.MDWSet
is created containing just this element.The number and type of arguments must match the parameters of the script.
T
- the type of elements in the returned collection.scriptName
- the name of the script to evaluate.arguments
- the script arguments.MDWSet
representation of the script result.InvalidCallException
- if the script does not exist or is not visible.EvaluationException
- if the evaluation of the script failed.<T> MDWList<T> toList(String scriptName)
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:
null
, an empty MDWList
is returned.
Collection
, Map
, Iterator
or array
), a MDWList
is
created and wraps these elements.MDWList
is created containing just this element.T
- the type of elements in the returned collection.scriptName
- the name of the script to evaluate (which must not expect any parameter).MDWList
representation of the script result.InvalidCallException
- if the script does not exist or is not visible.EvaluationException
- if the evaluation of the script failed.<T> MDWList<T> toList(String scriptName, List<?> arguments)
MDWList
representation of the evaluation result. MDWList
provides
facilities to invoke scripts on each MDWObject
element of the list.
If the script result is:
null
, an empty MDWList
is returned.
Collection
, Map
, Iterator
or array
), a MDWList
is
created and wraps these elements.MDWList
is created containing just this element.The number and type of arguments must match the parameters of the script.
T
- the type of elements in the returned collection.scriptName
- the name of the script to evaluate.arguments
- the script arguments.MDWList
representation of the script result.InvalidCallException
- if the script does not exist or is not visible.EvaluationException
- if the evaluation of the script failed.<E> MDWList<E> toList(Collection<E> values)
MDWList
. MDWList
provides facilities to invoke scripts on each
MDWObject
element of the list.E
- the type of elements in the returned collection.values
- the collection to wrap into a list.MDWList
containing each element of the specified collection.<E> MDWList<E> toList(Iterator<E> values)
MDWList
. MDWList
provides facilities to invoke scripts on each
MDWObject
element of the list.E
- the type of elements in the returned collection.values
- the iterator to wrap into a list.MDWList
containing each element of the specified iterator.<E> MDWList<E> toList(E[] values)
MDWList
. MDWList
provides facilities to invoke scripts on each
MDWObject
element of the list.E
- the type of elements in the returned collection.values
- the array to wrap into a list.MDWList
containing each element of the specified array.Object superScript(String scriptName)
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")
.
scriptName
- the name of the script to evaluate (which must not expect any parameter).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 existsObject superScript(String scriptName, List<?> arguments)
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.
scriptName
- the name of the script to evaluate.arguments
- the script arguments.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 existsExtendedClass eExtendedClass()