Package org.codehaus.modello.plugin.stax
Class StaxReaderGenerator
- java.lang.Object
-
- org.codehaus.plexus.logging.AbstractLogEnabled
-
- org.codehaus.modello.plugin.AbstractModelloGenerator
-
- org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
-
- org.codehaus.modello.plugins.xml.AbstractXmlJavaGenerator
-
- org.codehaus.modello.plugin.stax.AbstractStaxGenerator
-
- org.codehaus.modello.plugin.stax.StaxReaderGenerator
-
- All Implemented Interfaces:
ModelloGenerator,org.codehaus.plexus.logging.LogEnabled,org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
public class StaxReaderGenerator extends AbstractStaxGenerator
-
-
Field Summary
Fields Modifier and Type Field Description private booleanrequiresDomSupport-
Fields inherited from class org.codehaus.modello.plugins.xml.AbstractXmlJavaGenerator
strictXmlAttributes
-
Fields inherited from class org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
DEFAULT_DATE_FORMAT, domAsXpp3, useJava5
-
-
Constructor Summary
Constructors Constructor Description StaxReaderGenerator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidaddCodeToAddReferences(ModelAssociation association, JClass jClass, JSourceCode sc, ModelField referenceIdentifierField, java.lang.String referredFromClass)private JMethodconvertNumericalType(java.lang.String methodName, JType returnType, java.lang.String expression, java.lang.String typeDesc)private GeneratorNodefindRequiredReferenceResolvers(ModelClass modelClass, GeneratorNode parent)voidgenerate(Model model, java.util.Properties parameters)private voidgenerateStaxReader()Generate a StAX reader, aModelNameStaxReaderclass inio.staxsub-package withpublic RootClass read( ...private voidgenerateStaxReaderDelegate(java.util.List<java.lang.String> versions)private static java.lang.StringgetInstanceFieldName(java.lang.String to)private static java.lang.StringgetRefFieldName(ModelAssociation association)private voidprocessField(ModelField field, XmlFieldMetadata xmlFieldMetadata, boolean addElse, JSourceCode sc, java.lang.String objectName, boolean rootElement, JClass jClass)Generate code to process a field represented as an XML element.private voidwriteAllClassesParser(Model objectModel, JClass jClass)Write code to parse every classes from a model.private voidwriteAttributes(ModelClass modelClass, java.lang.String uncapClassName, JSourceCode sc)Add code to parse fields of a model class that are XML attributes.private voidwriteBuildDomMethod(JClass jClass)private voidwriteClassParser(ModelClass modelClass, JClass jClass, boolean rootElement)Write aprivate ClassName parseClassName( ...private voidwriteDetermineVersionMethod(JClass jClass, Model objectModel)private static voidwriteFieldVersionGetMethod(ModelField field, JClass jClass)private voidwriteHelpers(JClass jClass)private voidwriteModelVersionCheck(JSourceCode sc)private static voidwriteModelVersionHack(JSourceCode sc)private static voidwriteNamespaceVersionGetMethod(java.lang.String namespace, JClass jClass)private voidwritePrimitiveField(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.private voidwriteReferenceResolvers(GeneratorNode node, JClass jClass)-
Methods inherited from class org.codehaus.modello.plugin.stax.AbstractStaxGenerator
getReferenceIdentifierField, initialize, isAssociationPartToClass
-
Methods inherited from class org.codehaus.modello.plugins.xml.AbstractXmlJavaGenerator
getContentField, getFieldsForXml, getFileName, getValue, resolveTagName, resolveTagName, resolveTagName, writeDateParsingHelper
-
Methods inherited from class org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
addModelImport, addModelImports, getClasses, getDefaultValue, getJavaDefaultValue, getPrefix, getValueChecker, initHeader, initHeader, isJavaEnabled, isRelevant, isTrackingSupport, newJSourceWriter, suppressAllWarnings
-
Methods inherited from class org.codehaus.modello.plugin.AbstractModelloGenerator
capitalise, contextualize, getBuildContext, getEncoding, getFieldsForClass, getGeneratedVersion, getHeader, getModel, getOutputDirectory, getParameter, getParameter, getParameter, isClassInModel, isCollection, isEmpty, isInnerAssociation, isMap, isPackageWithVersion, singular, uncapitalise
-
-
-
-
Method Detail
-
generate
public void generate(Model model, java.util.Properties parameters) throws ModelloException
- Throws:
ModelloException
-
generateStaxReader
private void generateStaxReader() throws ModelloException, java.io.IOExceptionGenerate a StAX reader, aModelNameStaxReaderclass inio.staxsub-package withpublic RootClass read( ... )methods.- Throws:
ModelloExceptionjava.io.IOException
-
generateStaxReaderDelegate
private void generateStaxReaderDelegate(java.util.List<java.lang.String> versions) throws ModelloException, java.io.IOException- Throws:
ModelloExceptionjava.io.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(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 modeljClass- the generated class source file- Throws:
ModelloException
-
writeClassParser
private void writeClassParser(ModelClass modelClass, JClass jClass, boolean rootElement) throws ModelloException
Write aprivate ClassName parseClassName( ... )method to parse a class from a model.- Parameters:
modelClass- the model classjClass- the generated class source filerootElement- 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 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 classuncapClassName-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 processxmlFieldMetadata- its XML metadataaddElse- add anelsestatement before generating a newifsc- the method source code to add toobjectName- the object name in the sourcerootElement- 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, java.lang.String referredFromClass)
-
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 XMLobjectName- the object name in sourcesetterName- the setter method namesc- the source code to add to
-
writeBuildDomMethod
private void writeBuildDomMethod(JClass jClass)
-
writeHelpers
private void writeHelpers(JClass jClass)
-
-