org.intermine.codegen
Class JavaModelOutput

java.lang.Object
  extended by org.intermine.codegen.JavaModelOutput

public class JavaModelOutput
extends java.lang.Object

Maps InterMine metadata to Java source files


Field Summary
protected static java.lang.String ENDL
           
protected  java.io.File file
           
protected static java.lang.String INDENT
           
protected  Model model
           
 
Constructor Summary
JavaModelOutput(Model model, java.io.File file)
          Constructor.
 
Method Summary
protected  java.lang.String generate(AttributeDescriptor attr, boolean field)
          Generates code for a single attribute.
protected  java.lang.String generate(ClassDescriptor cld, boolean shadow)
          Generate the output for a ClassDescriptor.
protected  java.lang.String generate(CollectionDescriptor col, boolean field)
          Generates code for a single collection.
protected  java.lang.String generate(ReferenceDescriptor ref, boolean field)
          Generates code for a single reference.
 java.lang.String generateAddCollectionElement(ClassDescriptor cld)
          Generates the addCollectionElement method.
protected  java.lang.String generateEquals(ClassDescriptor cld)
          Generate a .equals() method for the given class.
protected  java.lang.String generateFieldDescriptors(ClassDescriptor cld, boolean supers)
          Generate all FieldDescriptors for a class/interface
 java.lang.String generateGetElementType(ClassDescriptor cld)
          Generates the getElementType method.
 java.lang.String generateGetFieldType(ClassDescriptor cld)
          Generates the getFieldType method.
 java.lang.String generateGetFieldValue(ClassDescriptor cld, boolean proxy)
          Generates the getFieldValue method.
protected  java.lang.String generateGetObject(ClassDescriptor cld)
          Generates the getoBJECT method for producing NotXml.
protected  java.lang.String generateGetSet(FieldDescriptor field, boolean fieldPresent)
          Write code for getters and setters for given field.
protected  java.lang.String generateHashCode(ClassDescriptor cld)
          Generate a .hashCode() method for the given class.
 java.lang.String generateSetFieldValue(ClassDescriptor cld)
          Generates the setFieldValue method.
 java.lang.String generateSetObject(ClassDescriptor cld)
          Generates the setoBJECT method for deserialising objects.
protected  java.lang.String generateToString(ClassDescriptor cld)
          Generate a .toString() method for the given class .
protected  java.lang.String getType(FieldDescriptor field)
          Return the java type of a particular field.
 void process()
          Perform the mapping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDENT

protected static final java.lang.String INDENT
See Also:
Constant Field Values

ENDL

protected static final java.lang.String ENDL

model

protected Model model

file

protected java.io.File file
Constructor Detail

JavaModelOutput

public JavaModelOutput(Model model,
                       java.io.File file)
                throws java.lang.Exception
Constructor.

Parameters:
model - a Model
file - a File
Throws:
java.lang.Exception - if something goes wrong
Method Detail

process

public void process()
Perform the mapping.


generate

protected java.lang.String generate(ClassDescriptor cld,
                                    boolean shadow)
Generate the output for a ClassDescriptor.

Parameters:
cld - the ClassDescriptor
shadow - whether to generate the shadow class of an interface
Returns:
the relevant String representation

generateFieldDescriptors

protected java.lang.String generateFieldDescriptors(ClassDescriptor cld,
                                                    boolean supers)
Generate all FieldDescriptors for a class/interface

Parameters:
cld - the ClassDescriptor of the class
supers - true if go up the inheritence tree and output fields
Returns:
the generated String

generate

protected java.lang.String generate(AttributeDescriptor attr,
                                    boolean field)
Generates code for a single attribute.

Parameters:
attr - the AttributeDescriptor
field - true if the class should have the associated field, or false if the field is in the superclass
Returns:
java code

generate

protected java.lang.String generate(ReferenceDescriptor ref,
                                    boolean field)
Generates code for a single reference.

Parameters:
ref - the ReferenceDescriptor
field - true if the class should have the associated field, or false if the field is in the superclass
Returns:
java code

generate

protected java.lang.String generate(CollectionDescriptor col,
                                    boolean field)
Generates code for a single collection.

Parameters:
col - the CollectionDescriptor
field - true if the class should have the associated field, or false if the field is in the superclass
Returns:
java code

generateGetSet

protected java.lang.String generateGetSet(FieldDescriptor field,
                                          boolean fieldPresent)
Write code for getters and setters for given field.

Parameters:
field - descriptor for field
fieldPresent - true if this class has the associated field
Returns:
string with generated java code

generateEquals

protected java.lang.String generateEquals(ClassDescriptor cld)
Generate a .equals() method for the given class.

Parameters:
cld - descriptor for class in question
Returns:
generated java code as string

generateHashCode

protected java.lang.String generateHashCode(ClassDescriptor cld)
Generate a .hashCode() method for the given class.

Parameters:
cld - descriptor for the class in question
Returns:
generate java code as a string

generateToString

protected java.lang.String generateToString(ClassDescriptor cld)
Generate a .toString() method for the given class .

Parameters:
cld - descriptor for the class in question
Returns:
generated java code as a string

getType

protected java.lang.String getType(FieldDescriptor field)
Return the java type of a particular field.

Parameters:
field - descriptor for the field in question
Returns:
the java type

generateGetObject

protected java.lang.String generateGetObject(ClassDescriptor cld)
Generates the getoBJECT method for producing NotXml.

Parameters:
cld - the ClassDescriptor
Returns:
generated java code as a String

generateSetObject

public java.lang.String generateSetObject(ClassDescriptor cld)
Generates the setoBJECT method for deserialising objects.

Parameters:
cld - a ClassDescriptor
Returns:
a String containing the method

generateGetFieldValue

public java.lang.String generateGetFieldValue(ClassDescriptor cld,
                                              boolean proxy)
Generates the getFieldValue method.

Parameters:
cld - the ClassDescriptor
proxy - false to make the getFieldValue method, true to make the getFieldProxy method
Returns:
a String with the method

generateSetFieldValue

public java.lang.String generateSetFieldValue(ClassDescriptor cld)
Generates the setFieldValue method.

Parameters:
cld - the ClassDescriptor
Returns:
a String with the method

generateAddCollectionElement

public java.lang.String generateAddCollectionElement(ClassDescriptor cld)
Generates the addCollectionElement method.

Parameters:
cld - the ClassDescriptor
Returns:
a String with the method

generateGetFieldType

public java.lang.String generateGetFieldType(ClassDescriptor cld)
Generates the getFieldType method.

Parameters:
cld - the ClassDescriptor
Returns:
a String with the method

generateGetElementType

public java.lang.String generateGetElementType(ClassDescriptor cld)
Generates the getElementType method.

Parameters:
cld - the ClassDescriptor
Returns:
a String with the method