Dresden OCL Toolkit

tudresden.ocl.codegen.decl
Class MappedClass

java.lang.Object
  extended bytudresden.ocl.codegen.decl.MappedClass

public class MappedClass
extends Object

This class represents a mapped class from the object model. The class should be mapped using an implementation of ORMappingScheme. The four basic characteristics of a mapped class are:

  1. - a class can be mapped to one or more tables;
  2. - the mapped class knows about the kind of joins necessary to navigate to association ends;
  3. - an object identifier, necessary to uniquely identify instances of the class, can be mapped to one or more table columns;
  4. - an attribute can be mapped to one or more columns.
To query all that important information about a mapped class, MappedClass provides a number of service methodes.

Author:
Sten Loecher
See Also:
ORMappingScheme

Nested Class Summary
private  class MappedClass.AssociationEnd
           
 
Field Summary
private  Set associationEnds
          a Set of association ends
(package private)  String className
          the name of the class
private static String EX_MC_ND
           
private static String EX_MC_NULL
           
private static String EX_NAME_NULL
           
private static String EX_NO_AE
           
private static String EX_NO_GUIDE
           
private static String EX_OP_NULL
           
private static String EX_PAR_NULL
           
private static String EX_TABLE_NULL
           
private  Set queries
          a Set containing all method names of the class for which isQuery holds
private  Map superclasses
          a Map of all direct superclass names to the MappedClass objects of the superclasses
private  List tables
          a List of tables this class is mapped to
 
Constructor Summary
MappedClass(String name)
          Creates a new MappedClass object.
 
Method Summary
 void addAssociationEnd(String roleName, MappedClass ae)
          Adds an asscociation end to the MappedClass object.
 void addJoinGuide(String name, Guide guide)
          Adds a join guide to the MappedClass object.
 void addQuery(String name)
           
 void addSuperclass(String name, MappedClass mc)
           
 void addTable(Table table)
           
 Set allSupertypes()
           
 Set associationEnds()
           
 Set attributes()
           
private  MappedClass.AssociationEnd getAssEnd(String name)
          Note: This methode does not consider superclasses !
 MappedClass getAssociationEnd(String name)
           
 Guide getAttributeGuide(String name)
           
 List getAttributeGuides(String name)
           
 String getClassName()
           
 Guide getJoinGuide(String name)
           
 List getJoinGuides(String name)
           
 List getTables()
           
 boolean hasTable(String name)
           
 boolean isAssociationEnd(String name)
           
 boolean isAttribute(String name)
           
 boolean isQuery(String name)
           
 Set operations()
           
 Set supertypes()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EX_NAME_NULL

private static String EX_NAME_NULL

EX_TABLE_NULL

private static String EX_TABLE_NULL

EX_OP_NULL

private static String EX_OP_NULL

EX_MC_NULL

private static String EX_MC_NULL

EX_PAR_NULL

private static String EX_PAR_NULL

EX_NO_GUIDE

private static String EX_NO_GUIDE

EX_NO_AE

private static String EX_NO_AE

EX_MC_ND

private static String EX_MC_ND

className

String className
the name of the class


tables

private List tables
a List of tables this class is mapped to


queries

private Set queries
a Set containing all method names of the class for which isQuery holds


associationEnds

private Set associationEnds
a Set of association ends


superclasses

private Map superclasses
a Map of all direct superclass names to the MappedClass objects of the superclasses

Constructor Detail

MappedClass

public MappedClass(String name)
            throws NullPointerException
Creates a new MappedClass object.

Parameters:
name - the class name from the object model
Throws:
NullPointerException - if the name is null
Method Detail

addTable

public void addTable(Table table)
              throws NullPointerException
Parameters:
table - a table the class is mapped to
Throws:
NullPointerException - if table is null

addQuery

public void addQuery(String name)
              throws NullPointerException
Parameters:
name - the methode for which isQuery holds
Throws:
NullPointerException - if the name is null

addAssociationEnd

public void addAssociationEnd(String roleName,
                              MappedClass ae)
                       throws NullPointerException
Adds an asscociation end to the MappedClass object. If no role Name for the association end is provided, the name of the given class is going to be used with the first letter changed to lower case. If the association end already exists, it is going to be replaced by the parameter values.

Parameters:
roleName - the role name of the association end or null
ae - the MappedClass object related to the rolename
Throws:
NullPointerException - if ae is null

addJoinGuide

public void addJoinGuide(String name,
                         Guide guide)
                  throws NullPointerException
Adds a join guide to the MappedClass object. If the according name of the association end is not yet existing, a new association end is going to be added to the MappedClass object.

Parameters:
name - the name of the association end the join guide leads to
guide - the join guide
Throws:
NullPointerException - if one of the parameters is null

addSuperclass

public void addSuperclass(String name,
                          MappedClass mc)
                   throws NullPointerException
Parameters:
name - the name of the superclass
Throws:
NullPointerException - if one of the parameters is null

getClassName

public String getClassName()
Returns:
the class name of the mapped class

getJoinGuides

public List getJoinGuides(String name)
                   throws IllegalArgumentException
Parameters:
name - the name of the association end the join guide is supposed to lead to
Returns:
a List with all join guides that lead to the specified association end; if the parameter name equals the class name, join guides to this class will be returned
Throws:
IllegalArgumentException - if name is not the name of an association end

getJoinGuide

public Guide getJoinGuide(String name)
                   throws IllegalArgumentException,
                          IllegalStateException,
                          NullPointerException
Parameters:
name - the name of the association end the join guide is supposed to lead to
Returns:
the join guide leading to the specified association end
Throws:
IllegalArgumentException - if name is not the name of an association end
IllegalStateException - if the number of Guide objects to be returned is greater than 1
NullPointerException - if the association end exists but no Guide is defined

getAttributeGuides

public List getAttributeGuides(String name)
                        throws IllegalArgumentException
Parameters:
name - the name of an attribute of the mapped class
Returns:
a List of Guides to navigate to the specified attribute. If a guide is in mode isNavigation() == true, a navigation or join is necessary prior to query the attribute's column.
Throws:
IllegalArgumentException - if name is not a valid attribute name

getAttributeGuide

public Guide getAttributeGuide(String name)
                        throws IllegalStateException
Parameters:
name - the name of an attribute of the mapped class
Returns:
a Guide to navigate to the specified attribute
Throws:
IllegalStateException - if more than one Guide exists for the attribute
NullPointerException - if no attribute guide exists

getAssociationEnd

public MappedClass getAssociationEnd(String name)
                              throws IllegalArgumentException,
                                     NullPointerException,
                                     IllegalStateException
Parameters:
name - the name of the association end
Returns:
the MappedClass object representing the association end
Throws:
IllegalArgumentException - if name is not a valid association end
NullPointerException - if no MappedClass object is defined for the association end
IllegalStateException - if more than one MappedClass exists

isAttribute

public boolean isAttribute(String name)
                    throws NullPointerException
Parameters:
name - a classifier from the class model
Returns:
true if the classifier is an attribute name, false otherwise
Throws:
NullPointerException - if name is null

isAssociationEnd

public boolean isAssociationEnd(String name)
                         throws NullPointerException
Parameters:
name - a classifier from the class model
Returns:
name true if the classifier is the name of an association end, false otherwise
Throws:
NullPointerException - if the name is null

isQuery

public boolean isQuery(String name)
                throws NullPointerException
Parameters:
name - a classifier from the class model
Returns:
name true if the classifier is the name of a query methode, false otherwise
Throws:
NullPointerException - if the name is null

getTables

public List getTables()
Returns:
a List with all tables the class is mapped to

hasTable

public boolean hasTable(String name)
                 throws NullPointerException
Parameters:
name - a table name
Returns:
true if the mapped class contains a table with the specified name, false otherwise
Throws:
NullPointerException - if the name is null

attributes

public Set attributes()
Returns:
the set of names of the attributes of the mapped class

associationEnds

public Set associationEnds()
Returns:
the set of names of navigatable associationEnds of the mapped class

operations

public Set operations()
Returns:
the set of names of operations of the mapped class

supertypes

public Set supertypes()
Returns:
the set of names of direct supertypes of the mapped class

allSupertypes

public Set allSupertypes()
Returns:
the set of names of all supertypes of the mapped class

getAssEnd

private MappedClass.AssociationEnd getAssEnd(String name)
                                      throws NoSuchElementException
Note: This methode does not consider superclasses !

Returns:
the AssociationEnd with the given name
Throws:
if - no association end with the given name exists
NoSuchElementException

Dresden OCL Toolkit

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