Class StaxReaderGenerator

  • All Implemented Interfaces:
    ModelloGenerator, org.codehaus.plexus.logging.LogEnabled, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable

    public class StaxReaderGenerator
    extends AbstractStaxGenerator
    • Field Detail

      • requiresDomSupport

        private boolean requiresDomSupport
    • Constructor Detail

      • StaxReaderGenerator

        public StaxReaderGenerator()
    • Method Detail

      • generateStaxReader

        private void generateStaxReader()
                                 throws ModelloException,
                                        java.io.IOException
        Generate a StAX reader, a ModelNameStaxReader class in io.stax sub-package with public RootClass read( ... ) methods.
        Throws:
        ModelloException
        java.io.IOException
      • generateStaxReaderDelegate

        private void generateStaxReaderDelegate​(java.util.List<java.lang.String> versions)
                                         throws ModelloException,
                                                java.io.IOException
        Throws:
        ModelloException
        java.io.IOException
      • writeModelVersionHack

        private static void writeModelVersionHack​(JSourceCode sc)
      • writeFieldVersionGetMethod

        private static void writeFieldVersionGetMethod​(ModelField field,
                                                       JClass jClass)
      • writeNamespaceVersionGetMethod

        private static void writeNamespaceVersionGetMethod​(java.lang.String namespace,
                                                           JClass jClass)
      • writeAllClassesParser

        private void writeAllClassesParser​(Model objectModel,
                                           JClass jClass)
                                    throws ModelloException
        Write code to parse every classes from a model.
        Parameters:
        objectModel - the model
        jClass - the generated class source file
        Throws:
        ModelloException
      • writeClassParser

        private void writeClassParser​(ModelClass modelClass,
                                      JClass jClass,
                                      boolean rootElement)
                               throws ModelloException
        Write a private ClassName parseClassName( ... ) method to parse a class from a model.
        Parameters:
        modelClass - the model class
        jClass - the generated class source file
        rootElement - is this class the root from the model?
        Throws:
        ModelloException
      • writeReferenceResolvers

        private void writeReferenceResolvers​(GeneratorNode node,
                                             JClass jClass)
      • getRefFieldName

        private static java.lang.String getRefFieldName​(ModelAssociation association)
      • getInstanceFieldName

        private static java.lang.String getInstanceFieldName​(java.lang.String to)
      • writeAttributes

        private void writeAttributes​(ModelClass modelClass,
                                     java.lang.String uncapClassName,
                                     JSourceCode sc)
                              throws ModelloException
        Add code to parse fields of a model class that are XML attributes.
        Parameters:
        modelClass - the model class
        uncapClassName -
        sc - the source code to add to
        Throws:
        ModelloException
      • processField

        private void processField​(ModelField field,
                                  XmlFieldMetadata xmlFieldMetadata,
                                  boolean addElse,
                                  JSourceCode sc,
                                  java.lang.String objectName,
                                  boolean rootElement,
                                  JClass jClass)
                           throws ModelloException
        Generate code to process a field represented as an XML element.
        Parameters:
        field - the field to process
        xmlFieldMetadata - its XML metadata
        addElse - add an else statement before generating a new if
        sc - the method source code to add to
        objectName - the object name in the source
        rootElement - is the enclosing model class the root class (for model version field handling)
        jClass - the generated class source file
        Throws:
        ModelloException
      • writeModelVersionCheck

        private void writeModelVersionCheck​(JSourceCode sc)
      • writePrimitiveField

        private void writePrimitiveField​(ModelField field,
                                         java.lang.String type,
                                         java.lang.String objectName,
                                         java.lang.String setterName,
                                         JSourceCode sc)
        Write code to set a primitive field with a value got from the parser, with appropriate default value, trimming and required check logic.
        Parameters:
        field - the model field to set (either XML attribute or element)
        type - the type of the value read from XML
        objectName - the object name in source
        setterName - the setter method name
        sc - the source code to add to
      • writeBuildDomMethod

        private void writeBuildDomMethod​(JClass jClass)
      • writeHelpers

        private void writeHelpers​(JClass jClass)
      • convertNumericalType

        private JMethod convertNumericalType​(java.lang.String methodName,
                                             JType returnType,
                                             java.lang.String expression,
                                             java.lang.String typeDesc)