Dresden OCL Toolkit

tudresden.ocl.check.types.xmifacade
Class ModelClass

java.lang.Object
  extended bytudresden.ocl.check.types.xmifacade.ModelClass
All Implemented Interfaces:
Any, Comparable, Type

public final class ModelClass
extends Object
implements Any, Comparable


Nested Class Summary
 
Nested classes inherited from class tudresden.ocl.check.types.Any
Any.VoidAny
 
Field Summary
private  HashSet allSupertypes
           
private  HashMap attributes
          Maps attribute/relation partner names to the attributes with this name.
private  HashSet directSupertypes
           
private  String fullName
          Fully qualified name.
private  String implicitRoleName
           
private  Model model
           
private  HashMap operations
          Maps operation names to collections of operations with this name.
private  String shortName
          This name is unique in the package only.
 
Fields inherited from interface tudresden.ocl.check.types.Any
VOID
 
Constructor Summary
ModelClass(List packagePath, String name)
           
 
Method Summary
 void addAttribute(ModelAttribute attr)
          Adds an attribute/role name to the class.
 void addDirectSupertype(ModelClass s)
           
 void addOperation(ModelOperation oper)
          Adds an operation to a class.
private  void addOperationLesser(ModelOperation oper)
          This operation ist used internally only be method flatten().
 Map attributes()
           
 int compareTo(Object o)
           
 boolean conformsTo(Type t)
           
 boolean containsOperation(ModelOperation oper)
           
 void determineAllSupertypes()
          This methode will be called instead of flatten if the underlying model is rough.
 boolean equals(Object o)
          Does object identity comparision.
 void flatten()
          Flattens inheritance.
 String generalizationRoot()
           
 ModelOperation getEqualOperation(ModelOperation oper)
           
 String getFullName()
           
 String getImplicitRoleName()
          OCL specification 5.4.1: if role name is missing, use class name starting with lowercase letter.
 ModelOperation getMatchingOperation(String name, Type[] params)
           
 Model getModel()
           
 String getShortName()
           
 boolean hasState(String name)
          States are not supported.
 boolean hasSupertypes()
           
 boolean isDirectSupertype(ModelClass s)
           
 boolean isSupertype(ModelClass s)
          Return true, if and only if this is a (possibly indirect) generalization of this.
 Type navigateParameterized(String name, Type[] params)
          Assumes, that all methods are queried using this method, even method with empty parameter list.
 Type navigateQualified(String name, Type[] qualifiers)
          navigate to the association end or attribute name, possibly with qualifier types; unnamed association ends must by made available by implementing methods with the name of the association end's type, but beginning with a lower case character (see OCL specification for more details)
 Map operations()
           
 void printData(PrintStream o)
          Useful for debugging.
 void setModel(Model model)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface tudresden.ocl.check.types.Type
hashCode
 

Field Detail

fullName

private String fullName
Fully qualified name. This includes package prefix, without any spaces. This name is unique over the whole model.


shortName

private String shortName
This name is unique in the package only.


directSupertypes

private HashSet directSupertypes

allSupertypes

private HashSet allSupertypes

attributes

private final HashMap attributes
Maps attribute/relation partner names to the attributes with this name.


operations

private final HashMap operations
Maps operation names to collections of operations with this name.


implicitRoleName

private String implicitRoleName

model

private Model model
Constructor Detail

ModelClass

public ModelClass(List packagePath,
                  String name)
Method Detail

getFullName

public String getFullName()

getShortName

public String getShortName()

getImplicitRoleName

public String getImplicitRoleName()
OCL specification 5.4.1: if role name is missing, use class name starting with lowercase letter.


setModel

public void setModel(Model model)

getModel

public Model getModel()

addDirectSupertype

public void addDirectSupertype(ModelClass s)

isSupertype

public boolean isSupertype(ModelClass s)
Return true, if and only if this is a (possibly indirect) generalization of this.


addAttribute

public void addAttribute(ModelAttribute attr)
Adds an attribute/role name to the class. An attribute cannot be added twice to the same class or different classes. Note: this method cannot be used for flattening, due to special handling of ambiguities here.


containsOperation

public boolean containsOperation(ModelOperation oper)

getEqualOperation

public ModelOperation getEqualOperation(ModelOperation oper)

getMatchingOperation

public ModelOperation getMatchingOperation(String name,
                                           Type[] params)

addOperation

public void addOperation(ModelOperation oper)
Adds an operation to a class. An operation cannot be added twice to the same class or different classes. Thus, this method cannot be used for flattening. Use addOperationLesser instead.

See Also:
addOperationLesser(ModelOperation)

addOperationLesser

private void addOperationLesser(ModelOperation oper)
This operation ist used internally only be method flatten().

See Also:
flatten()

flatten

public void flatten()
Flattens inheritance. This method inserts all attributes/operations of supertypes into itself, which are not overridden in thes class. Additionally the supertypes relation is extended to be transitive.


printData

public void printData(PrintStream o)
Useful for debugging.


navigateQualified

public Type navigateQualified(String name,
                              Type[] qualifiers)
                       throws OclTypeException
Description copied from interface: Type
navigate to the association end or attribute name, possibly with qualifier types; unnamed association ends must by made available by implementing methods with the name of the association end's type, but beginning with a lower case character (see OCL specification for more details)

Specified by:
navigateQualified in interface Type
Parameters:
qualifiers - the qualifier types; may (and will in most cases) be null, but never an array with length 0
Throws:
OclTypeException

navigateParameterized

public Type navigateParameterized(String name,
                                  Type[] params)
                           throws OclTypeException
Assumes, that all methods are queried using this method, even method with empty parameter list.

Specified by:
navigateParameterized in interface Type
Parameters:
params - the actual argument types
Throws:
OclTypeException

hasState

public boolean hasState(String name)
States are not supported. This method always returns true.

Specified by:
hasState in interface Type
Returns:
true if this type has a state with the given name

conformsTo

public boolean conformsTo(Type t)
Specified by:
conformsTo in interface Type
Returns:
true if an instance of the type represented by the called object can replace an instance of the type given as parameter

equals

public boolean equals(Object o)
Does object identity comparision. There should be only one ModelClass instance for each Class in the xmi file. Object.hashCode() isn't overridden for the same reason.

Specified by:
equals in interface Type

toString

public String toString()
Specified by:
toString in interface Type

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable

determineAllSupertypes

public void determineAllSupertypes()
This methode will be called instead of flatten if the underlying model is rough. It determines all generalization relationships but does no flattening.


hasSupertypes

public boolean hasSupertypes()
Returns:
true if the model class has supertypes, false otherwise

generalizationRoot

public String generalizationRoot()
                          throws IllegalStateException
Returns:
the name of the topmost parent class of the generalization hierarchy of this model class
Throws:
IllegalStateException - if more than one generalization root exists

attributes

public Map attributes()
Returns:
an unmodifiable Map that contains all attributes (and association partners if model is not in rough mode)

operations

public Map operations()
Returns:
an unmodifiable Map that contains all operations of the class

isDirectSupertype

public boolean isDirectSupertype(ModelClass s)
Returns:
true if class s is a direct supertype of this class, false otherwise

Dresden OCL Toolkit

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