Dresden OCL Toolkit

tudresden.ocl.lib
Class Ocl

java.lang.Object
  extended bytudresden.ocl.lib.Ocl

public final class Ocl
extends Object

This class constitutes the central interface to generating classes in the OCL class library. An application should call one of the getOclRepresentationFor class methods whenever it wants to use any object or value with the library. This method than consults the installed OclFactory to create the correct representative for this object or value. The getFor methods are nothing but a shorthand for getOclRepresentationFor, which is self-speaking but tedious to write.

If the OCL class library is to be used in a new context, especially with a new code generator, a new OclFactory might become necessary. It can be installed in the Ocl class using the setFactory method. Adaptation to name changes by code generators is possible through NameAdapter. A standard implementation of this interface is contained in the library with SimpleNameAdapter and ArgoNameAdapter, but that is not set by default.

Also, an implementation of OclStateAdapter might become necessary if the operation oclInState of OclAny is to be used. The implementation must be registered using setStateAdapter. In contrast to OclFactory, there is no standard implementation for OclStateAdapter. The same is true for the interface AllInstancesAdapter. Implemenentations might access a CASE platforms repository.

Additionally, the switch STRICT_VALUE_TYPES can be set in this class to determine the runtime behaviour of the class library.

Author:
Frank Finger
See Also:
OclFactory, DefaultOclFactory, NameAdapter, ArgoNameAdapter, SimpleNameAdapter, OclStateAdapter, AllInstancesAdapter, setFactory(OclFactory of), setNameAdapter(NameAdapter na), STRICT_VALUE_TYPES

Field Summary
protected static AllInstancesAdapter allInstancesAdapter
          setting this adapter makes the operation allInstances evaluatable
protected static OclFactory factory
          this objects contains factory methods to generate OCL representations for application objects and values
static boolean JAVA_CLASS_NAMES
          This class attribute determines wether OclType.name() will return fully-qualified or simple class names (i.e.
protected static NameAdapter nameAdapter
          This object transforms diagram names to possible implementation names.
protected static OclStateAdapter stateAdapter
          a reference to the object that will be consulted if oclInState is called; by default it is null
static boolean STRICT_FLATTENING
          If this class attribute is set to true, a new OclCollection is automatically flattened upon creation.
static boolean STRICT_VALUE_TYPES
          Some methods can be implemented more runtime efficient if their value type nature is ignored.
static boolean TAKE_VECTORS_AS_SET
          Determines, whether attributes of type java.util.Vector are treated as Sequences or Sets.
static boolean TOLERATE_NONEXISTENT_FIELDS
          If this attribute is set to true, an access to a non-existent attribute or method is evaluated as an undefined value; otherwise, an exception is thrown.
 
Constructor Summary
Ocl()
           
 
Method Summary
static OclSet getAllInstances(OclType t)
           
static OclBoolean getFor(boolean b)
           
static OclRoot getFor(byte b)
           
static OclRoot getFor(char c)
           
static OclRoot getFor(double d)
           
static OclRoot getFor(float f)
           
static OclRoot getFor(int i)
           
static OclRoot getFor(long l)
           
static OclRoot getFor(Object o)
           
static OclRoot getFor(short s)
           
static String[] getNames(String n)
          Use the NameAdapter to find possible implementation names.
static OclBoolean getOclRepresentationFor(boolean b)
          the representation of boolean is restricted to be OclBoolean
static OclRoot getOclRepresentationFor(byte b)
           
static OclRoot getOclRepresentationFor(char c)
           
static OclRoot getOclRepresentationFor(double d)
           
static OclRoot getOclRepresentationFor(float f)
           
static OclRoot getOclRepresentationFor(int i)
           
static OclRoot getOclRepresentationFor(long l)
           
static OclRoot getOclRepresentationFor(Object o)
           
static OclRoot getOclRepresentationFor(short s)
           
static OclRoot getOclRepresentationForNull(Class c)
           
static OclSequence getOclSequenceFor(Object o)
          This method uses the factory to create an OclSequence representation for the given Object.
static OclState getOclStateFor(String s)
           
static String[] getPossibleAssociationNames(String n)
          Use the NameAdapter to find association names that might have been converted into the given implementation name.
static OclBoolean objectInState(Object o, OclState state)
           
static Object reconvert(Class type, OclRoot oclObject)
          calls the factory to retransform the OCL library representation of an object into the application representation denoted by the parameter type
static void setAllInstancesAdapter(AllInstancesAdapter aia)
           
static void setFactory(OclFactory of)
           
static void setNameAdapter(NameAdapter na)
          makes the methods getName and getPossibleAssociationNames use the given name adapter The ocl library will not work until a NameAdapter is provided.
static void setStateAdapter(OclStateAdapter adapter)
           
static OclAddable toOclAddable(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclAddable; if casting fails, this method will return an appropriate undefined value.
static OclAny toOclAny(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclAny; if casting fails, this method will return an appropriate undefined value.
static OclAnyImpl toOclAnyImpl(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclAnyImpl; if casting fails, this method will return an appropriate undefined value.
static OclBag toOclBag(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclBag; if casting fails, this method will return an appropriate undefined value.
static OclBoolean toOclBoolean(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclBoolean; if casting fails, this method will return an appropriate undefined value.
static OclCollection toOclCollection(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclCollection; if casting fails, this method will return an appropriate undefined value.
static OclComparable toOclComparable(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclComparable; if casting fails, this method will return an appropriate undefined value.
static OclInteger toOclInteger(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclInteger; if casting fails, this method will return an appropriate undefined value.
static OclMultiplyable toOclMultiplyable(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclMultiplyable; if casting fails, this method will return an appropriate undefined value.
static OclReal toOclReal(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclReal; if casting fails, this method will return an appropriate undefined value.
static OclSequence toOclSequence(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclSequence; if casting fails, this method will return an appropriate undefined value.
static OclSet toOclSet(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclSet; if casting fails, this method will return an appropriate undefined value.
static OclSizable toOclSizable(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclSizable; if casting fails, this method will return an appropriate undefined value.
static OclString toOclString(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclString; if casting fails, this method will return an appropriate undefined value.
static OclSubtractable toOclSubtractable(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclSubtractable; if casting fails, this method will return an appropriate undefined value.
static OclUnsortedCollection toOclUnsortedCollection(OclRoot or)
          use this method instead of a Java cast to downcast objects of type OclRoot to OclUnsortedCollection; if casting fails, this method will return an appropriate undefined value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOLERATE_NONEXISTENT_FIELDS

public static boolean TOLERATE_NONEXISTENT_FIELDS
If this attribute is set to true, an access to a non-existent attribute or method is evaluated as an undefined value; otherwise, an exception is thrown. Default is true.


STRICT_VALUE_TYPES

public static boolean STRICT_VALUE_TYPES
Some methods can be implemented more runtime efficient if their value type nature is ignored. An obvious example is the operation including defined on Collections. Its faster to just add the new Object to the existing collection and return this than to create a copy of the collection, add the new object to the copy and then return the copy.
Therefore, some operations are implemented in a specification-compliant and a fast way. If a class of this class library contains such an operation, it chooses the implementation by its instance attribute STRICT_VALUE_TYPES. The value of this attribute is copied in the concerning classes constructor from the class attribute Ocl.STRICT_VALUE_TYPES, which is set to true by default.


JAVA_CLASS_NAMES

public static boolean JAVA_CLASS_NAMES
This class attribute determines wether OclType.name() will return fully-qualified or simple class names (i.e. the part fully qualified name after the last "." character). By default, it is set to false


STRICT_FLATTENING

public static boolean STRICT_FLATTENING
If this class attribute is set to true, a new OclCollection is automatically flattened upon creation. This means that every element of the java.util.Collection given as constructor parameter is tested for being an OclCollection object itself and, if so, is flattened. Flattening means that the original collection is removed from the new collection and instead all its elements are stored in the new collection. By default, this is set to false for performance reasons. The collection constructors are not called illegally from within the library, so strict flattening is not necessary usually.


TAKE_VECTORS_AS_SET

public static boolean TAKE_VECTORS_AS_SET
Determines, whether attributes of type java.util.Vector are treated as Sequences or Sets. Default is Sequence (false). The other way is needed for older CASE-Tools and their code generators. This effects both the ocl library and the reflection facade.

See Also:
DefaultOclFactory.getOclRepresentationFor(Object), DefaultReflectionAdapter.getTypeForClass(java.lang.Class)

factory

protected static OclFactory factory
this objects contains factory methods to generate OCL representations for application objects and values

See Also:
setFactory(OclFactory of)

stateAdapter

protected static OclStateAdapter stateAdapter
a reference to the object that will be consulted if oclInState is called; by default it is null

See Also:
OclAny.oclInState(OclState stat)

allInstancesAdapter

protected static AllInstancesAdapter allInstancesAdapter
setting this adapter makes the operation allInstances evaluatable

See Also:
OclType.allInstances()

nameAdapter

protected static NameAdapter nameAdapter
This object transforms diagram names to possible implementation names. Default value is null, which causes the ocl library to throw NullPointerExceptions, unless a NameAdapter has been set.

See Also:
setNameAdapter(tudresden.ocl.lib.NameAdapter)
Constructor Detail

Ocl

public Ocl()
Method Detail

getFor

public static OclRoot getFor(Object o)

getOclRepresentationFor

public static OclRoot getOclRepresentationFor(Object o)

getOclRepresentationForNull

public static OclRoot getOclRepresentationForNull(Class c)

getFor

public static OclBoolean getFor(boolean b)

getOclRepresentationFor

public static OclBoolean getOclRepresentationFor(boolean b)
the representation of boolean is restricted to be OclBoolean


getFor

public static OclRoot getFor(byte b)

getOclRepresentationFor

public static OclRoot getOclRepresentationFor(byte b)

getFor

public static OclRoot getFor(short s)

getOclRepresentationFor

public static OclRoot getOclRepresentationFor(short s)

getFor

public static OclRoot getFor(int i)

getOclRepresentationFor

public static OclRoot getOclRepresentationFor(int i)

getFor

public static OclRoot getFor(long l)

getOclRepresentationFor

public static OclRoot getOclRepresentationFor(long l)

getFor

public static OclRoot getFor(float f)

getOclRepresentationFor

public static OclRoot getOclRepresentationFor(float f)

getFor

public static OclRoot getFor(double d)

getOclRepresentationFor

public static OclRoot getOclRepresentationFor(double d)

getFor

public static OclRoot getFor(char c)

getOclRepresentationFor

public static OclRoot getOclRepresentationFor(char c)

reconvert

public static Object reconvert(Class type,
                               OclRoot oclObject)
calls the factory to retransform the OCL library representation of an object into the application representation denoted by the parameter type

See Also:
OclFactory.reconvert(Class c, OclRoot or)

getOclSequenceFor

public static OclSequence getOclSequenceFor(Object o)
This method uses the factory to create an OclSequence representation for the given Object. It is called from OclAnyImpl.getFeatureAsSequence(String).

See Also:
OclFactory.getOclSequenceFor(Object o), OclAnyImpl.getFeatureAsSequence(String s)

setFactory

public static void setFactory(OclFactory of)

getOclStateFor

public static OclState getOclStateFor(String s)

setStateAdapter

public static void setStateAdapter(OclStateAdapter adapter)

objectInState

public static OclBoolean objectInState(Object o,
                                       OclState state)

setNameAdapter

public static void setNameAdapter(NameAdapter na)
makes the methods getName and getPossibleAssociationNames use the given name adapter The ocl library will not work until a NameAdapter is provided.

See Also:
getNames(String n), getPossibleAssociationNames(String n)

getNames

public static String[] getNames(String n)
Use the NameAdapter to find possible implementation names. Throws NullPointerException, if no NameAdapter is set.

See Also:
setNameAdapter(tudresden.ocl.lib.NameAdapter)

getPossibleAssociationNames

public static String[] getPossibleAssociationNames(String n)
Use the NameAdapter to find association names that might have been converted into the given implementation name. Throws NullPointerException, if no NameAdapter is set.

See Also:
setNameAdapter(tudresden.ocl.lib.NameAdapter)

toOclSizable

public static OclSizable toOclSizable(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclSizable; if casting fails, this method will return an appropriate undefined value.


toOclCollection

public static OclCollection toOclCollection(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclCollection; if casting fails, this method will return an appropriate undefined value.


toOclSubtractable

public static OclSubtractable toOclSubtractable(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclSubtractable; if casting fails, this method will return an appropriate undefined value.


toOclUnsortedCollection

public static OclUnsortedCollection toOclUnsortedCollection(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclUnsortedCollection; if casting fails, this method will return an appropriate undefined value.


toOclSet

public static OclSet toOclSet(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclSet; if casting fails, this method will return an appropriate undefined value.


toOclBag

public static OclBag toOclBag(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclBag; if casting fails, this method will return an appropriate undefined value.


toOclSequence

public static OclSequence toOclSequence(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclSequence; if casting fails, this method will return an appropriate undefined value.


toOclString

public static OclString toOclString(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclString; if casting fails, this method will return an appropriate undefined value.


toOclBoolean

public static OclBoolean toOclBoolean(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclBoolean; if casting fails, this method will return an appropriate undefined value.


toOclComparable

public static OclComparable toOclComparable(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclComparable; if casting fails, this method will return an appropriate undefined value.


toOclAddable

public static OclAddable toOclAddable(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclAddable; if casting fails, this method will return an appropriate undefined value.


toOclMultiplyable

public static OclMultiplyable toOclMultiplyable(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclMultiplyable; if casting fails, this method will return an appropriate undefined value.


toOclReal

public static OclReal toOclReal(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclReal; if casting fails, this method will return an appropriate undefined value.


toOclInteger

public static OclInteger toOclInteger(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclInteger; if casting fails, this method will return an appropriate undefined value.


toOclAny

public static OclAny toOclAny(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclAny; if casting fails, this method will return an appropriate undefined value.


toOclAnyImpl

public static OclAnyImpl toOclAnyImpl(OclRoot or)
use this method instead of a Java cast to downcast objects of type OclRoot to OclAnyImpl; if casting fails, this method will return an appropriate undefined value.


setAllInstancesAdapter

public static void setAllInstancesAdapter(AllInstancesAdapter aia)

getAllInstances

public static OclSet getAllInstances(OclType t)
Throws:
OclException - no AllInstancesAdapter has been set

Dresden OCL Toolkit

Submit a bug
Developed at the Dresden University of Technology.
This software is published under the GNU Lesser General Public License.