com.ashridgetech.jamda.uml
Class ClassType

java.lang.Object
  |
  +--com.ashridgetech.jamda.uml.ModelElement
        |
        +--com.ashridgetech.jamda.uml.Type
              |
              +--com.ashridgetech.jamda.uml.StructuredType
                    |
                    +--com.ashridgetech.jamda.uml.ClassType
Direct Known Subclasses:
DataTransferObjectType

public class ClassType
extends StructuredType

A UML Class.

Version:
1.0
Author:
paulb

Nested Class Summary
 
Nested classes inherited from class com.ashridgetech.jamda.uml.StructuredType
StructuredType.Aggregation, StructuredType.PropertyImpl, StructuredType.Visibility
 
Nested classes inherited from class com.ashridgetech.jamda.uml.ModelElement
ModelElement.DuplicateElementException, ModelElement.ElementListStore, ModelElement.ElementNameListStore, ModelElement.ElementNameStore, ModelElement.ElementStore, ModelElement.TaggedValue, ModelElement.UnknownElementException
 
Field Summary
 
Fields inherited from class com.ashridgetech.jamda.uml.StructuredType
READ_ONLY, UNBOUNDED, WRITABLE
 
Fields inherited from class com.ashridgetech.jamda.uml.ModelElement
DUMMY_STORE
 
Constructor Summary
protected ClassType(ru.novosoft.uml.foundation.core.MClass mc, ModelPackage parentPackage)
          Initialises new ClassType during loading.
  ClassType(ModelPackage parentPackage, java.lang.String name)
          Creates new ClassType belonging to a ModelPackage.
 
Method Summary
 ClassType addInterface(InterfaceType type)
          Add an InterfaceType which this ClassType implements.
 Property addProperty(java.lang.String name, Type type, boolean writable, java.lang.String comment, ModelElement source)
          Add a property to this StructuredType.
 void checkValid()
          Check whether this object is valid.
 java.util.Collection getAssociationEnds()
          Get the Association.Ends at the other end of Associations from this ClassType.
 Attribute getAttribute(ModelElement source)
          Get the single Attribute of this StructuredType with a given source ModelElement
 Attribute getAttribute(Stereotype stereotype, ModelElement source)
          Get the single Attribute of this StructuredType with a given Stereotype and source ModelElement.
 Attribute getAttribute(java.lang.String name)
          Get the Attribute of this ClassType with a given name
 java.util.List getAttributes()
          Get the Attributes of this ClassType.
 java.util.List getAttributes(ModelElement element)
          Get the Attribute(s) of this ClassType which have the same original source ModelElement as a given element, or whose direct source is the element.
 java.util.List getAttributes(Stereotype stereotype)
          Get the Attribute(s) of this StructuredType with a given Stereotype
 java.util.List getAttributes(Stereotype stereotype, ModelElement source)
          Get the Attribute(s) of this StructuredType with a given Stereotype and source ModelElement
 java.util.List getConstructors()
          Get the Constructors of this ClassType.
 java.util.Collection getInterfaces()
          Get the InterfaceTypes which this ClassType implements.
protected  ModelElement.ElementStore getSubElementStore(java.lang.Class meClass)
          Overridden to return the sub-element ModelElement.ElementStore into which an object of the class meClass should be stored.
 ClassType getSuperClass()
          Get the one ClassType which is the superclass of this one, if there is one other than java.lang.Object.
(package private)  void invalidate(ModelElement changedObject)
          Inform this object that its cached details may be out of date.
 boolean isAbstract()
          Show whether this ClassType is abstract.
 boolean isSimple()
          Show whether this Type is a simple type, such as a number or String , or composed of other parts.
protected  java.util.List makeProperties()
          Return a list of ModelElements which implement the Property interface.
protected  StructuredType.PropertyImpl makeProperty(Operation getter)
          Make one StructuredType.PropertyImpl from an Operation.
 java.lang.String propertyInitCode(Operation operation)
          Create the property initialisation code in Java for an Operation .
 ClassType setAbstract(boolean isAbstract)
          Set whether this ClassType is abstract.
 ClassType setSuperClass(ClassType superclass)
          Set the one ClassType which is the superclass of this one, if there is one other than java.lang.Object.
 ClassType setVisibility(StructuredType.Visibility visibility)
          Set the visibility of this ClassType.
 
Methods inherited from class com.ashridgetech.jamda.uml.StructuredType
addProperties, addReadOnlyProperty, addSuperType, addWritableProperty, getAllProperties, getAllTaggedValues, getOperation, getOperation, getOperations, getOperations, getOperations, getOperations, getOperations, getParentPackage, getProperties, getProperty, getSubTypes, getSuperTypes, getVisibility, load, setStructuredTypeVisibility
 
Methods inherited from class com.ashridgetech.jamda.uml.ModelElement
add, addStereotype, addTaggedValue, addTaggedValue, addTaggedValues, addTaggedValuesInternal, checkInitialised, checkState, findTaggedValueCollection, getBooleanTaggedValue, getChildElements, getComment, getDescription, getDirectSource, getElement, getElementType, getFullName, getId, getModel, getName, getNsElement, getOriginalSource, getParentElement, getProperties, getStereotypes, getStringTaggedValue, getTaggedValue, getTaggedValues, getXpathContext, hasStereotype, hasTaggedValue, init, initLoad, isInitialised, load, load, loadElement, logChange, logger, logger, logLoad, logLoadWarning, logNew, logWarning, removeTaggedValue, select, setComment, setDirectSource, setTaggedValue, setTaggedValue, setTaggedValue, setTaggedValues, stereotype, tag, tagError, toString, type, type, type, xpath, xpathList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassType

public ClassType(ModelPackage parentPackage,
                 java.lang.String name)
Creates new ClassType belonging to a ModelPackage.


ClassType

protected ClassType(ru.novosoft.uml.foundation.core.MClass mc,
                    ModelPackage parentPackage)
Initialises new ClassType during loading.

Method Detail

isAbstract

public boolean isAbstract()
Show whether this ClassType is abstract.

Returns:
true if this is abstract

setAbstract

public ClassType setAbstract(boolean isAbstract)
Set whether this ClassType is abstract.

Parameters:
isAbstract - true if this is to be abstract
Returns:
this object

setVisibility

public ClassType setVisibility(StructuredType.Visibility visibility)
Set the visibility of this ClassType.

Parameters:
visibility - the Visibility instance representing this ClassType's visibility - must not be null
Returns:
this object

getSuperClass

public ClassType getSuperClass()
Get the one ClassType which is the superclass of this one, if there is one other than java.lang.Object.

Returns:
the superclass, or null if there is no explicit superclass
Throws:
java.lang.IllegalStateException - if there is more than one superclass

setSuperClass

public ClassType setSuperClass(ClassType superclass)
Set the one ClassType which is the superclass of this one, if there is one other than java.lang.Object. The superclass must not already have been set, and it cannot be removed by setting a null superclass.

Parameters:
superclass - the superclass to set for this ClassType - must not be null
Returns:
this instance
Throws:
java.lang.IllegalStateException - if there is already a superclass

getInterfaces

public java.util.Collection getInterfaces()
Get the InterfaceTypes which this ClassType implements.

Returns:
an unmodifiable list of InterfaceType objects

getAttributes

public java.util.List getAttributes(Stereotype stereotype)
Get the Attribute(s) of this StructuredType with a given Stereotype

Parameters:
stereotype - the stereotype of the required Attribute(s)
Returns:
an unmodifiable list of the Attributes whose stereotype is stereotype, which may be empty if there are no Attributes with that stereotype

getAttributes

public java.util.List getAttributes(ModelElement element)
Get the Attribute(s) of this ClassType which have the same original source ModelElement as a given element, or whose direct source is the element.

Parameters:
element - the element for which the required Attribute(s) are found - may not be null
Returns:
an unmodifiable list of the Attributes found, which may be empty if there are no Attributes with that source
See Also:
ModelElement.getOriginalSource(), ModelElement.getDirectSource()

getAttribute

public Attribute getAttribute(ModelElement source)
Get the single Attribute of this StructuredType with a given source ModelElement

Parameters:
source - the source element of the required Attribute(s)
Returns:
the Attribute found, or null if there is no Attribute with the given source
Throws:
java.lang.IllegalStateException - if there is more than one Attribute with the given source

getAttributes

public java.util.List getAttributes(Stereotype stereotype,
                                    ModelElement source)
Get the Attribute(s) of this StructuredType with a given Stereotype and source ModelElement

Parameters:
stereotype - the stereotype of the required Attribute(s)
source - the source element of the required Attribute(s)
Returns:
an unmodifiable list of the Attributes , which may be empty

getAttribute

public Attribute getAttribute(Stereotype stereotype,
                              ModelElement source)
Get the single Attribute of this StructuredType with a given Stereotype and source ModelElement.

Parameters:
stereotype - the stereotype of the required Attribute
source - the source element of the required Attribute
Returns:
the Attribute found, or null if there is no Attribute with the given source and stereotype
Throws:
java.lang.IllegalStateException - if there is more than one Attribute with the given source and stereotype

addInterface

public ClassType addInterface(InterfaceType type)
Add an InterfaceType which this ClassType implements.

Parameters:
type - the new interface which this ClassType implements - must not already be one of the interfaces implemented
Returns:
this object
Throws:
java.lang.IllegalArgumentException - if type is already implemented by this ClassType
See Also:
getInterfaces()

addProperty

public Property addProperty(java.lang.String name,
                            Type type,
                            boolean writable,
                            java.lang.String comment,
                            ModelElement source)
Add a property to this StructuredType.

Overrides:
addProperty in class StructuredType
Parameters:
name - the name of the property - must not be null or empty
type - the type of the property - must not be null
writable - true if the property is writable. Use the constants StructuredType.READ_ONLY and StructuredType.WRITABLE for clarity.
comment - the description of the property - if null, will use the comment from source, if that is not null
source - the source of this property - may be null
Returns:
the set of features created for the property - see StructuredType.addProperty(java.lang.String, com.ashridgetech.jamda.uml.Type, boolean, java.lang.String, com.ashridgetech.jamda.uml.ModelElement)

getConstructors

public java.util.List getConstructors()
Get the Constructors of this ClassType.

Returns:
an unmodifiable list of Constructor objects, in the order in which they are defined in the model.

getAttributes

public java.util.List getAttributes()
Get the Attributes of this ClassType.

Returns:
an unmodifiable list of Attribute objects, in the order in which they are defined in the model.

getAttribute

public Attribute getAttribute(java.lang.String name)
Get the Attribute of this ClassType with a given name

Parameters:
name - the name of the required Attribute
Returns:
the Attribute whose name is name, or null if there is no such object

getAssociationEnds

public java.util.Collection getAssociationEnds()
Get the Association.Ends at the other end of Associations from this ClassType.

Returns:
an unmodifiable list of Association.End objects.

propertyInitCode

public java.lang.String propertyInitCode(Operation operation)
Create the property initialisation code in Java for an Operation . Assigns each Parameter with the UmlStereotypes.PROPERTY_SETTER stereotype to the Attribute with the same original source element. If there is no Attribute with the same source element, and the class which contains operation has a superclass, that parameter value is passed to the superclass in a super() call.

Parameters:
operation - the Operation for which the code is needed
Returns:
the code
Throws:
java.lang.IllegalStateException - if there is no Attribute to which a parameter value may be assigned
java.lang.IllegalArgumentException - if the owner of this Operation is not this ClassType

checkValid

public void checkValid()
                throws java.lang.IllegalStateException
Check whether this object is valid. Subclasses should call the superclass method if they override this method.

Overrides:
checkValid in class StructuredType
Throws:
java.lang.IllegalStateException - if a problem is found

isSimple

public boolean isSimple()
Show whether this Type is a simple type, such as a number or String , or composed of other parts.

Overrides:
isSimple in class StructuredType
Returns:
true if the package is java.lang or the full name is java.util.Date, false otherwise

makeProperties

protected java.util.List makeProperties()
Return a list of ModelElements which implement the Property interface.

Overrides:
makeProperties in class StructuredType
Returns:
list combining the public non-static attributes and the navigable association ends at the other end of an association with this type, with the properties from StructuredType.

makeProperty

protected StructuredType.PropertyImpl makeProperty(Operation getter)
Make one StructuredType.PropertyImpl from an Operation.

Overrides:
makeProperty in class StructuredType

getSubElementStore

protected ModelElement.ElementStore getSubElementStore(java.lang.Class meClass)
Overridden to return the sub-element ModelElement.ElementStore into which an object of the class meClass should be stored.

Overrides:
getSubElementStore in class StructuredType
Returns:
the store to use, or the superclass implementation if the class of the object is not stored by this class.

invalidate

void invalidate(ModelElement changedObject)
Inform this object that its cached details may be out of date.

Overrides:
invalidate in class StructuredType
Parameters:
changedObject - the new or modified object which may affect this one


Copyright © 2003 Ashridge Technologies Ltd. All Rights Reserved.