de.tuberlin.cs.cis.ocl.eval.instance
Class ModelInstance

java.lang.Object
  |
  +--de.tuberlin.cs.cis.ocl.eval.instance.PredefinedInstance
        |
        +--de.tuberlin.cs.cis.ocl.eval.instance.OclAnyInstance
              |
              +--de.tuberlin.cs.cis.ocl.eval.instance.ModelInstance
All Implemented Interfaces:
Instance, OclAny

public class ModelInstance
extends OclAnyInstance

Represents instances of OCL model types.

Author:
fchabar

Constructor Summary
ModelInstance(CollectionInstance alternativeCollection)
          Constructs a model element navigated through a navigation with multiplity zero.
ModelInstance(ModelType modelType, InstanceDescriptor mid)
          Constructs a model instance.
ModelInstance(ModelType modelType, InstanceDescriptor mid, CollectionInstance alternativeCollection)
          Constructs a navigated model instance.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 CollectionInstance getAlternativeCollection()
          Returns the alternative single-membered collection of this instance that can occur if this instance is navigated over an association with multiplicity one or zero.
 InstanceDescriptor getDescriptor()
          Return the descriptor of this instance.
 Instance getValue(Property attribute)
          Returns the value of an attribut of this instance.
 Instance invoke(Property operation, Instance[] args)
          Invokes an operation on this instance.
 Instance navigate(Property assoc, Instance[] qs)
          Navigates an association of this instance.
 java.lang.String toString()
           
 
Methods inherited from class de.tuberlin.cs.cis.ocl.eval.instance.OclAnyInstance
eq, neq, oclAsType, oclInState, oclIsKindOf, oclIsNew, oclIsTypeOf
 
Methods inherited from class de.tuberlin.cs.cis.ocl.eval.instance.PredefinedInstance
getRepresentation, getRuntimeType, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModelInstance

public ModelInstance(ModelType modelType,
                     InstanceDescriptor mid)
Constructs a model instance.

Parameters:
modelType - the runtime type of this model instance
mid - descriptor describing the state and behavior of this instance

ModelInstance

public ModelInstance(ModelType modelType,
                     InstanceDescriptor mid,
                     CollectionInstance alternativeCollection)
Constructs a navigated model instance.

Parameters:
modelType - the runtime type of this model instance
mid - descriptor describing the state and behavior of this instance

ModelInstance

public ModelInstance(CollectionInstance alternativeCollection)
Constructs a model element navigated through a navigation with multiplity zero.

Parameters:
alternativeCollection -
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class PredefinedInstance

getValue

public Instance getValue(Property attribute)
Description copied from interface: Instance
Returns the value of an attribut of this instance.

Specified by:
getValue in interface Instance
Overrides:
getValue in class PredefinedInstance
Parameters:
attribute - the attribute to access
Returns:
the value of the accessed attribute

invoke

public Instance invoke(Property operation,
                       Instance[] args)
Description copied from interface: Instance
Invokes an operation on this instance.

Specified by:
invoke in interface Instance
Overrides:
invoke in class PredefinedInstance
Parameters:
operation - the operation to invoke
args - the arguments the operation is called with
Returns:
the return value of the invokation

navigate

public Instance navigate(Property assoc,
                         Instance[] qs)
Description copied from interface: Instance
Navigates an association of this instance.

Specified by:
navigate in interface Instance
Overrides:
navigate in class PredefinedInstance
Parameters:
assoc - the association to navigate
qs - the evaluated denotation the navigation is qualified with.
Returns:
the navigated instance

getAlternativeCollection

public CollectionInstance getAlternativeCollection()
Returns the alternative single-membered collection of this instance that can occur if this instance is navigated over an association with multiplicity one or zero.

Returns:
The alternative collection containing this instance or null if this instance has not been navigated.

getDescriptor

public InstanceDescriptor getDescriptor()
Return the descriptor of this instance.

Returns:
the descriptor of this instance

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class OclAnyInstance