com.ashridgetech.jamda.code
Class UmlTypeGenerator

java.lang.Object
  |
  +--com.ashridgetech.jamda.code.ClassGenerator
        |
        +--com.ashridgetech.jamda.code.UmlTypeGenerator
Direct Known Subclasses:
UmlClassGenerator, UmlInterfaceGenerator

public abstract class UmlTypeGenerator
extends ClassGenerator

Superclass for Java code generators which generate a Java class or interface with features corresponding to those of a StructuredType. Contains common functionality for its subclasses. 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
(package private)  boolean 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
protected UmlTypeGenerator(StructuredType source)
          Construct a UmlTypeGenerator attached to a StructuredType.
 
Method Summary
protected static void addOperationImports(java.util.Collection operationColl, java.util.Set importSet)
          Add the imports for a set of Operation's parameters to a given Set.
protected  java.util.Set findImports()
          Work out the types used by attributes and operation parameters, extended and implemented types by this generator's StructuredType.
 int findModifiers()
          Work out the Java modifiers needed for this generator's StructuredType.
static int findModifiers(Feature feature)
          Work out the Java modifiers needed for a Attribute or Operation.
 void generate(java.io.Writer writer)
          Override the superclass method to call setup() before generating.
 java.io.File getDirectory()
          Get the top level directory for the output files.
protected  java.util.Collection getExtraImports()
          Get any extra imports not catered for by findImports().
 java.io.Writer getFileWriter()
          Get a writer for the appropriate output file.
 StructuredType getSource()
          Get the UML StructuredType which is the source for the generation.
 void setDirectory(java.io.File directory)
          Set the the top level directory for the output files.
protected  void setup()
           
protected  ClassGenerator.MethodGenerator setupMethod(Operation op)
          Set up a method from an Operation or Constructor.
 
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
 

Field Detail

createDone

boolean createDone
Constructor Detail

UmlTypeGenerator

protected UmlTypeGenerator(StructuredType source)
Construct a UmlTypeGenerator attached to a StructuredType.

Parameters:
source - the source StructuredType for which the code is generated - must not be null. irrespective of whether umlStructuredType is an InterfaceType
Method Detail

getDirectory

public java.io.File getDirectory()
Get the top level directory for the output files.

Returns:
the top of the package structure

setDirectory

public void setDirectory(java.io.File directory)
Set the the top level directory for the output files.

Parameters:
directory - top of the package structure

getSource

public StructuredType getSource()
Get the UML StructuredType which is the source for the generation.

Returns:
the StructuredType object

generate

public void generate(java.io.Writer writer)
              throws java.io.IOException
Override the superclass method to call setup() before generating.

Overrides:
generate in class ClassGenerator
Parameters:
writer - the destination for the generated code
Throws:
java.lang.IllegalStateException - if this method has already been called
java.io.IOException

setup

protected void setup()

getFileWriter

public java.io.Writer getFileWriter()
                             throws java.io.IOException
Get a writer for the appropriate output file.

Returns:
the Writer to generate into
java.io.IOException

setupMethod

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

Parameters:
op - the Operation or Constructor to set up

findModifiers

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

Returns:
the modifiers OR'ed into a single int

findModifiers

public static int findModifiers(Feature feature)
Work out the Java modifiers needed for a Attribute or Operation. XXX cannot currently handle FINAL, TRANSIENT, VOLATILE or SYNCHRONIZED

Parameters:
feature - the Attribute or Operationto find modifiers for
Returns:
the modifiers OR'ed into a single int

findImports

protected java.util.Set findImports()
Work out the types used by attributes and operation parameters, extended and implemented types by this generator's StructuredType.

Returns:
a Set of StructuredType objects

addOperationImports

protected static void addOperationImports(java.util.Collection operationColl,
                                          java.util.Set importSet)
Add the imports for a set of Operation's parameters to a given Set.

Parameters:
operationColl - the Operations for whcih the imports are needed
Returns:
the import types

getExtraImports

protected java.util.Collection getExtraImports()
Get any extra imports not catered for by findImports(). This implementation returns an empty Set. It should be overridden by subclasses which need to add extra import types.

Returns:
the Collection of import types


Copyright © 2003 Ashridge Technologies Ltd. All Rights Reserved.