Class StaxReaderGenerator

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

@Component(role=ModelloGenerator.class, hint="stax-reader") public class StaxReaderGenerator extends AbstractStaxGenerator
  • Field Details

    • requiresDomSupport

      private boolean requiresDomSupport
  • Constructor Details

    • StaxReaderGenerator

      public StaxReaderGenerator()
  • Method Details

    • generate

      public void generate(Model model, Properties parameters) throws ModelloException
      Throws:
      ModelloException
    • generateStaxReader

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

      private void generateStaxReaderDelegate(List<String> versions) throws ModelloException, IOException
      Throws:
      ModelloException
      IOException
    • writeModelVersionHack

      private static void writeModelVersionHack(JSourceCode sc)
    • writeDetermineVersionMethod

      private void writeDetermineVersionMethod(JClass jClass, Model objectModel) throws ModelloException
      Throws:
      ModelloException
    • writeFieldVersionGetMethod

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

      private static void writeNamespaceVersionGetMethod(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
    • findRequiredReferenceResolvers

      private GeneratorNode findRequiredReferenceResolvers(ModelClass modelClass, GeneratorNode parent) throws ModelloException
      Throws:
      ModelloException
    • writeReferenceResolvers

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

      private static String getRefFieldName(ModelAssociation association)
    • getInstanceFieldName

      private static String getInstanceFieldName(String to)
    • writeAttributes

      private void writeAttributes(ModelClass modelClass, 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, 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
    • addCodeToAddReferences

      private static void addCodeToAddReferences(ModelAssociation association, JClass jClass, JSourceCode sc, ModelField referenceIdentifierField, String referredFromClass)
    • writeModelVersionCheck

      private void writeModelVersionCheck(JSourceCode sc)
    • writePrimitiveField

      private void writePrimitiveField(ModelField field, String type, String objectName, 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(String methodName, JType returnType, String expression, String typeDesc)