Class JavaModelOutput


  • public class JavaModelOutput
    extends java.lang.Object
    Maps InterMine metadata to Java source files
    Author:
    Mark Woodbridge, Matthew Wakeling
    • Field Detail

      • 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 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