com.ashridgetech.jamda.code
Class UmlClassGenerator

java.lang.Object
  |
  +--com.ashridgetech.jamda.code.ClassGenerator
        |
        +--com.ashridgetech.jamda.code.UmlTypeGenerator
              |
              +--com.ashridgetech.jamda.code.UmlClassGenerator

public class UmlClassGenerator
extends UmlTypeGenerator

Code generator which generates a Java class with the exact features of a UML ClassType. It must configured with MethodCoderFactory objects using setMethodCoderFactory(Stereotype,MethodCoderFactory) or setMethodCoderFactory(String,MethodCoderFactory)to create the method body statements. This may be done in a subclass's constructor or by a client class. Each instance may only be used to generate one class.

Author:
Paul Boocock version 1.0

Nested Class Summary
 
Nested classes inherited from class com.ashridgetech.jamda.code.ClassGenerator
ClassGenerator.FieldGenerator, ClassGenerator.MethodGenerator, ClassGenerator.PropertyDetails
 
Field Summary
 
Fields inherited from class com.ashridgetech.jamda.code.UmlTypeGenerator
createDone
 
Fields inherited from class com.ashridgetech.jamda.code.ClassGenerator
ABSTRACT, FINAL, PACKAGE, PRIVATE, PROTECTED, PUBLIC, READ_ONLY, READ_WRITE, STATIC, SYNCHRONIZED, TRANSIENT, VOLATILE
 
Constructor Summary
UmlClassGenerator(ClassType source)
          Construct a ClassGenerator.
 
Method Summary
 int findModifiers()
          Work out the Java modifiers needed for this generator's ClassType.
protected  java.util.Collection getExtraImports()
          Get any extra imports not catered for by UmlTypeGenerator.findImports().
 MethodCoder getMethodCoder(Operation operation)
          Get the MethodCoder which will be used for an Operation.
 MethodCoderFactory getMethodCoderFactory(Stereotype stereotype)
          Get the MethodCoderFactory which will be used for Operations with a particular Stereotype.
 MethodCoderFactory getMethodCoderFactory(java.lang.String operationName)
          Get the MethodCoderFactory which will be used for Operations with a particular name.
 ClassType getUmlClass()
          Get the UML Class which is the source for the generation.
 UmlClassGenerator setMethodCoderFactory(Stereotype stereotype, MethodCoderFactory factory)
          Set the MethodCoderFactory which will be used to create MethodCoders for Operations with a particular Stereotype.
 UmlClassGenerator setMethodCoderFactory(java.lang.String operationName, MethodCoderFactory factory)
          Set the MethodCoderFactory which will be used to create MethodCoders for Operations with a particular name.
protected  void setup()
          Set up the generator characteristics.
protected  ClassGenerator.MethodGenerator setupMethod(Operation op)
          Set up a method from an Operation or Constructor.
 
Methods inherited from class com.ashridgetech.jamda.code.UmlTypeGenerator
addOperationImports, findImports, findModifiers, generate, getDirectory, getFileWriter, getSource, setDirectory
 
Methods inherited from class com.ashridgetech.jamda.code.ClassGenerator
addConstructor, addExtends, addExtends, addExtends, addField, addField, addImplements, addImplements, addImplements, addImport, addImportClass, addImportPackage, addMethod, addProperty, addProperty, checkReadyToGenerate, classDecl, classDoc, constructors, doGenerate, endClass, fields, fileHeader, getClassDoc, getClassModifiers, getClassName, getExtendsNames, getFileName, getImplementsNames, getImportNames, getPackageName, getWriter, imports, isInterface, logger, makeClassWriter, methods, packageDecl, setClassDoc, setClassModifiers, setClassName, setPackageName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UmlClassGenerator

public UmlClassGenerator(ClassType source)
Construct a ClassGenerator.

Method Detail

getUmlClass

public ClassType getUmlClass()
Get the UML Class which is the source for the generation.

Returns:
the class object

setup

protected void setup()
Set up the generator characteristics. This implementation takes all its values from the ClassType set in the constructor.

Overrides:
setup in class UmlTypeGenerator

setupMethod

protected ClassGenerator.MethodGenerator setupMethod(Operation op)
Set up a method from an Operation or Constructor.

Overrides:
setupMethod in class UmlTypeGenerator
Parameters:
op - the Operation or Constructor to set up

getMethodCoderFactory

public MethodCoderFactory getMethodCoderFactory(Stereotype stereotype)
Get the MethodCoderFactory which will be used for Operations with a particular Stereotype. This must have been added using setMethodCoderFactory(Stereotype,MethodCoderFactory).

Parameters:
stereotype - the Stereotype for which the MethodCoder is required
Returns:
the MethodCoderFactory or null if there is no factory set for stereotype

setMethodCoderFactory

public UmlClassGenerator setMethodCoderFactory(Stereotype stereotype,
                                               MethodCoderFactory factory)
Set the MethodCoderFactory which will be used to create MethodCoders for Operations with a particular Stereotype.

Parameters:
stereotype - the Stereotype for which factory will be used - may not be null
factory - the MethodCoderFactory to use - may not be null
Returns:
this object

getMethodCoderFactory

public MethodCoderFactory getMethodCoderFactory(java.lang.String operationName)
Get the MethodCoderFactory which will be used for Operations with a particular name. This must have been added using setMethodCoderFactory(String,MethodCoderFactory).

Parameters:
operationName - the name of the Operations for which the coder will be used
Returns:
the MethodCoderFactory or null if there is no factory set for operationName
See Also:
setMethodCoderFactory(String,MethodCoderFactory)

setMethodCoderFactory

public UmlClassGenerator setMethodCoderFactory(java.lang.String operationName,
                                               MethodCoderFactory factory)
Set the MethodCoderFactory which will be used to create MethodCoders for Operations with a particular name.

Parameters:
operationName - the name of the Operations for which coder will be used - may not be null
factory - the MethodCoderFactory to use - may not be null
Returns:
this object
See Also:
setMethodCoderFactory(Stereotype, MethodCoderFactory)

getMethodCoder

public MethodCoder getMethodCoder(Operation operation)
Get the MethodCoder which will be used for an Operation. If there is Java code already specified for the Operation, a coder is returned which will generate this code. Then the method looks for the MethodCoderFactory for one of the operations stereotypes using getMethodCoderFactory(Stereotype), then if this is not found, it looks for the factory for the operation name using getMethodCoderFactory(String). If the operation has more than one stereotype, the first one found for which a factory has been set will be used.

Parameters:
operation - the Operation for which the coder is required
Returns:
the MethodCoder or null if there is no coder available

findModifiers

public int findModifiers()
Work out the Java modifiers needed for this generator's ClassType. XXX cannot currently handle FINAL and STATIC

Overrides:
findModifiers in class UmlTypeGenerator
Returns:
the modifiers OR'ed into a single int

getExtraImports

protected java.util.Collection getExtraImports()
Get any extra imports not catered for by UmlTypeGenerator.findImports(). This implementation returns the imports needed for Constructors, Attributes and the interfaces implemented.

Overrides:
getExtraImports in class UmlTypeGenerator
Returns:
the Collection of import types


Copyright © 2003 Ashridge Technologies Ltd. All Rights Reserved.