Package org.intermine.codegen
Class JavaModelOutput
- java.lang.Object
-
- org.intermine.codegen.JavaModelOutput
-
public class JavaModelOutput extends java.lang.ObjectMaps InterMine metadata to Java source files
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDELIMThe string that delimits the sections of the NotXml.static java.lang.StringENCODED_DELIMThe character that denotes an encoded delimiter in the string.protected static java.lang.StringENDLprotected java.io.Filefileprotected static java.lang.StringINDENTprotected Modelmodel
-
Constructor Summary
Constructors Constructor Description JavaModelOutput(Model model, java.io.File file)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Stringgenerate(AttributeDescriptor attr, boolean field)Generates code for a single attribute.protected java.lang.Stringgenerate(ClassDescriptor cld, boolean shadow)Generate the output for a ClassDescriptor.protected java.lang.Stringgenerate(CollectionDescriptor col, boolean field)Generates code for a single collection.protected java.lang.Stringgenerate(ReferenceDescriptor ref, boolean field)Generates code for a single reference.java.lang.StringgenerateAddCollectionElement(ClassDescriptor cld)Generates the addCollectionElement method.protected java.lang.StringgenerateEquals(ClassDescriptor cld)Generate a .equals() method for the given class.protected java.lang.StringgenerateFieldDescriptors(ClassDescriptor cld, boolean supers)Generate all FieldDescriptors for a class/interfacejava.lang.StringgenerateGetElementType(ClassDescriptor cld)Generates the getElementType method.java.lang.StringgenerateGetFieldType(ClassDescriptor cld)Generates the getFieldType method.java.lang.StringgenerateGetFieldValue(ClassDescriptor cld, boolean proxy)Generates the getFieldValue method.protected java.lang.StringgenerateGetObject(ClassDescriptor cld)Generates the getoBJECT method for producing NotXml.protected java.lang.StringgenerateGetSet(FieldDescriptor field, boolean fieldPresent)Write code for getters and setters for given field.protected java.lang.StringgenerateHashCode(ClassDescriptor cld)Generate a .hashCode() method for the given class.java.lang.StringgenerateSetFieldValue(ClassDescriptor cld)Generates the setFieldValue method.java.lang.StringgenerateSetObject(ClassDescriptor cld)Generates the setoBJECT method for deserialising objects.protected java.lang.StringgenerateToString(ClassDescriptor cld)Generate a .toString() method for the given class .protected java.lang.StringgetType(FieldDescriptor field)Return the java type of a particular field.voidprocess()Perform the mapping.
-
-
-
Field Detail
-
INDENT
protected static final java.lang.String INDENT
- See Also:
- Constant Field Values
-
ENDL
protected static final java.lang.String ENDL
-
DELIM
public static final java.lang.String DELIM
The string that delimits the sections of the NotXml.- See Also:
- Constant Field Values
-
ENCODED_DELIM
public static final java.lang.String ENCODED_DELIM
The character that denotes an encoded delimiter in the string.- See Also:
- Constant Field Values
-
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 Modelfile- 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 ClassDescriptorshadow- 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 classsupers- 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 AttributeDescriptorfield- 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 ReferenceDescriptorfield- 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 CollectionDescriptorfield- 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 fieldfieldPresent- 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 ClassDescriptorproxy- 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
-
-