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
strictXmlAttributesFields inherited from class org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
DEFAULT_DATE_FORMAT, domAsXpp3 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddCodeToAddReferences(ModelAssociation association, JClass jClass, JSourceCode sc, ModelField referenceIdentifierField, String referredFromClass) private JMethodconvertNumericalType(String methodName, JType returnType, String expression, String typeDesc) private GeneratorNodefindRequiredReferenceResolvers(ModelClass modelClass, GeneratorNode parent) voidgenerate(Model model, Properties parameters) private voidGenerate a StAX reader, aModelNameStaxReaderclass inio.staxsub-package withpublic RootClass read( ...private voidgenerateStaxReaderDelegate(List<String> versions) private static Stringprivate static StringgetRefFieldName(ModelAssociation association) private voidprocessField(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 voidwriteAllClassesParser(Model objectModel, JClass jClass) Write code to parse every classes from a model.private voidwriteAttributes(ModelClass modelClass, 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 voidprivate static voidprivate static voidwriteNamespaceVersionGetMethod(String namespace, JClass jClass) private voidwritePrimitiveField(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 voidwriteReferenceResolvers(GeneratorNode node, JClass jClass) Methods inherited from class org.codehaus.modello.plugin.stax.AbstractStaxGenerator
getReferenceIdentifierField, initialize, isAssociationPartToClassMethods inherited from class org.codehaus.modello.plugins.xml.AbstractXmlJavaGenerator
getContentField, getFieldsForXml, getFileName, getValue, resolveTagName, resolveTagName, resolveTagName, writeDateParsingHelperMethods inherited from class org.codehaus.modello.plugin.java.AbstractJavaModelloGenerator
addModelImport, addModelImports, getClasses, getDefaultValue, getJavaDefaultValue, getPrefix, getValueChecker, hasJavaSourceSupport, initHeader, initHeader, isJavaEnabled, isRelevant, isTrackingSupport, newJSourceWriter, suppressAllWarningsMethods 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, uncapitaliseMethods 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, aModelNameStaxReaderclass inio.staxsub-package withpublic RootClass read( ... )methods.- Throws:
ModelloExceptionIOException
-
generateStaxReaderDelegate
- Throws:
ModelloExceptionIOException
-
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 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, 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
-