Dresden OCL Toolkit

tudresden.ocl.lib
Class OclType

java.lang.Object
  extended bytudresden.ocl.lib.OclAny
      extended bytudresden.ocl.lib.OclType
All Implemented Interfaces:
Cloneable, OclRoot

public class OclType
extends OclAny

This class represents the predefined OCL class OclType and gives access to the meta level of OCL. Is is implemented as an adapter class around a java.lang.Class object.

Author:
Frank Finger
See Also:
Class

Field Summary
private  Class myClass
          the encapsulated Class object of this instance of OclType; for basic OCL types this is a class of this library, e.g.
private  String myName
          the name of this OclType object, e.g.
private static Map predefinedTypes
          a Set containing all names of predefined OCL types
static OclType typeAny
           
static OclType typeBoolean
           
static OclType typeInteger
          singletons for the predefined types; can also be accessed through getOclTypeFor(String), which calls getPredefinedTypeFor(String)
static OclType typeReal
           
static OclType typeString
           
static OclType typeType
           
 
Fields inherited from class tudresden.ocl.lib.OclAny
 
Constructor Summary
protected OclType(Class c)
          package-visible constructor for defined OclType objects
  OclType(int dummy, String reason)
          constructor for the undefined OclType object
 
Method Summary
 OclSet allInstances()
          In general, it is not possible to get all instances of a class or type in Java.
 OclSet allSupertypes()
           
 OclSet associationEnds()
           
 OclSet attributes()
           
 boolean equals(Object o)
           
 OclRoot getFeature(String name)
          This method returns an undefined value.
static OclType getOclTypeFor(Object context, String name)
          factory method for OclTypes that creates OclType objects from its name; if the name does not contains a '.' character, package information is extracted from the object given as context (should usually be called with this as context parameter); if no class with the given name is found, this method returns the undefined OclType object.
static OclType getOclTypeFor(String name)
          factory method for OclTypes that creates OclType objects from its fully qualified name; if no class with the given name is found, this method returns the undefined OclType object,
protected static OclType getPredefinedTypeFor(String name)
           
 int hashCode()
           
 OclBoolean isEqualTo(Object o)
          Returns true if this object is equal to the object given as parameter.
 OclString name()
           
 OclBoolean oclIsKindOf(OclType type)
          This method returns true if the OclType given as parameter is a type of the object whose method is called or a supertype of such a type.
 OclBoolean oclIsTypeOf(OclType type)
          This method returns true if the OclType given as parameter is a "type" of this object.
 OclSet operations()
           
 OclSet supertypes()
           
 String toString()
           
 
Methods inherited from class tudresden.ocl.lib.OclAny
getFeatureAsCollection, getUndefinedReason, isNotEqualTo, isUndefined, oclAsType, oclInState, oclType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

myClass

private Class myClass
the encapsulated Class object of this instance of OclType; for basic OCL types this is a class of this library, e.g. OclInteger


myName

private String myName
the name of this OclType object, e.g. "Integer" or "Person"


typeInteger

public static final OclType typeInteger
singletons for the predefined types; can also be accessed through getOclTypeFor(String), which calls getPredefinedTypeFor(String)


typeReal

public static final OclType typeReal

typeString

public static final OclType typeString

typeBoolean

public static final OclType typeBoolean

typeAny

public static final OclType typeAny

typeType

public static final OclType typeType

predefinedTypes

private static final Map predefinedTypes
a Set containing all names of predefined OCL types

Constructor Detail

OclType

protected OclType(Class c)
package-visible constructor for defined OclType objects

Throws:
OclException - if parameter c is null

OclType

public OclType(int dummy,
               String reason)
constructor for the undefined OclType object

Method Detail

getOclTypeFor

public static OclType getOclTypeFor(String name)
factory method for OclTypes that creates OclType objects from its fully qualified name; if no class with the given name is found, this method returns the undefined OclType object,

Parameters:
name - the name of the class that will be encapsulated by this instance of OclType; the name needs to be fully qualified for application types or be one of the names of the predefined OCL types, e.g. "String" or "Integer"

getOclTypeFor

public static OclType getOclTypeFor(Object context,
                                    String name)
factory method for OclTypes that creates OclType objects from its name; if the name does not contains a '.' character, package information is extracted from the object given as context (should usually be called with this as context parameter); if no class with the given name is found, this method returns the undefined OclType object.

Parameters:
name - the name of the class that will be encapsulated by this instance of OclType; the name needs to be fully qualified for application types or be one of the names of the predefined OCL types, e.g. "String" or "Integer"
context - package information is extracted from this object (the class with the requested name will be assumed to be in the same package as the context object)

getPredefinedTypeFor

protected static OclType getPredefinedTypeFor(String name)

isEqualTo

public OclBoolean isEqualTo(Object o)
Description copied from interface: OclRoot
Returns true if this object is equal to the object given as parameter. For definitions of equality for the different types, see the implementing methods. Generally, all basic and collection objects are considered equal if they contain the same value(s), application objects are considered equal if they are identical (==, not equal).

Specified by:
isEqualTo in interface OclRoot
Specified by:
isEqualTo in class OclAny

equals

public boolean equals(Object o)

hashCode

public int hashCode()

toString

public String toString()

getFeature

public OclRoot getFeature(String name)
This method returns an undefined value.

Specified by:
getFeature in interface OclRoot
Specified by:
getFeature in class OclAny

oclIsKindOf

public OclBoolean oclIsKindOf(OclType type)
Description copied from class: OclAny
This method returns true if the OclType given as parameter is a type of the object whose method is called or a supertype of such a type.

Overrides:
oclIsKindOf in class OclAny
See Also:
OclAny.oclIsKindOf(OclType type)

oclIsTypeOf

public OclBoolean oclIsTypeOf(OclType type)
Description copied from class: OclAny
This method returns true if the OclType given as parameter is a "type" of this object. "Type" is to be understood in the UML/OCL sense of the word, meaning that a Java object has exactly one type (its class) and this types supertypes are not types of the object.

Overrides:
oclIsTypeOf in class OclAny

name

public OclString name()
Returns:
the name of this type, in the format defined for java.lang.Class names and represented by a OclString object
See Also:
Class.getName()

attributes

public OclSet attributes()
Returns:
an OclSet containing OclString representations of the names of all attributes of this type; it also contains all names of association ends of the corresponding UML model class, since these are represented by attributes in the Java class

associationEnds

public OclSet associationEnds()
Returns:
an OclSet containing all possible names of association ends for all fields of the backing java.lang.Class instance, as returned by Ocl.getPossibleAssociationNames().
See Also:
Ocl.getPossibleAssociationNames(String n)

operations

public OclSet operations()
Returns:
an OclSet containing the names of all public methods of the Java class encapsulated by this OclType object, represented as OclStrings

supertypes

public OclSet supertypes()
Returns:
an OclSet that contains OclType objects for this class' superclass and all interfaces

allSupertypes

public OclSet allSupertypes()
Returns:
an OclSet that contains OclType objects for this class' superclasses and all interfaces

allInstances

public OclSet allInstances()
In general, it is not possible to get all instances of a class or type in Java. It might be possible in certain environments, e.g. in a CASE platform through accessing the repository. This method calls Ocl.getAllInstances(OclType), which needs an implementation of AllInstancesAdapter.

Throws:
OclException - if no AllInstancesAdapter is set in the class Ocl
See Also:
Ocl.getAllInstances(OclType t), AllInstancesAdapter

Dresden OCL Toolkit

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