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
@Component(role=ModelloGenerator.class,
hint="stax-reader")
public class StaxReaderGenerator
extends AbstractStaxGenerator
-
Field Summary
FieldsFields inherited from class org.codehaus.modello.plugins.xml.AbstractXmlJavaGenerator
strictXmlAttributes
Fields inherited from class org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
DEFAULT_DATE_FORMAT, domAsXpp3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
addCodeToAddReferences
(ModelAssociation association, JClass jClass, JSourceCode sc, ModelField referenceIdentifierField, String referredFromClass) private JMethod
convertNumericalType
(String methodName, JType returnType, String expression, String typeDesc) private GeneratorNode
findRequiredReferenceResolvers
(ModelClass modelClass, GeneratorNode parent) void
generate
(Model model, Properties parameters) private void
Generate a StAX reader, aModelNameStaxReader
class inio.stax
sub-package withpublic RootClass read( ...
private void
generateStaxReaderDelegate
(List<String> versions) private static String
private static String
getRefFieldName
(ModelAssociation association) private void
processField
(ModelField field, XmlFieldMetadata xmlFieldMetadata, boolean addElse, JSourceCode sc, String objectName, boolean rootElement, JClass jClass) Generate code to process a field represented as an XML element.private void
writeAllClassesParser
(Model objectModel, JClass jClass) Write code to parse every classes from a model.private void
writeAttributes
(ModelClass modelClass, String uncapClassName, JSourceCode sc) Add code to parse fields of a model class that are XML attributes.private void
writeBuildDomMethod
(JClass jClass) private void
writeClassParser
(ModelClass modelClass, JClass jClass, boolean rootElement) Write aprivate ClassName parseClassName( ...
private void
writeDetermineVersionMethod
(JClass jClass, Model objectModel) private static void
writeFieldVersionGetMethod
(ModelField field, JClass jClass) private void
writeHelpers
(JClass jClass) private void
private static void
private static void
writeNamespaceVersionGetMethod
(String namespace, JClass jClass) 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.private void
writeReferenceResolvers
(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, hasJavaSourceSupport, 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, newWriter, newWriter, singular, uncapitalise
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
requiresDomSupport
private boolean requiresDomSupport
-
-
Constructor Details
-
StaxReaderGenerator
public StaxReaderGenerator()
-
-
Method Details
-
generate
- Throws:
ModelloException
-
generateStaxReader
Generate a StAX reader, aModelNameStaxReader
class inio.stax
sub-package withpublic RootClass read( ... )
methods.- Throws:
ModelloException
IOException
-
generateStaxReaderDelegate
- Throws:
ModelloException
IOException
-
writeModelVersionHack
-
writeDetermineVersionMethod
- Throws:
ModelloException
-
writeFieldVersionGetMethod
-
writeNamespaceVersionGetMethod
-
writeAllClassesParser
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
-
getRefFieldName
-
getInstanceFieldName
-
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 classuncapClassName
-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 processxmlFieldMetadata
- its XML metadataaddElse
- add anelse
statement before generating a newif
sc
- 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, String referredFromClass) -
writeModelVersionCheck
-
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 XMLobjectName
- the object name in sourcesetterName
- the setter method namesc
- the source code to add to
-
writeBuildDomMethod
-
writeHelpers
-
convertNumericalType
-