de.ispsoft.jaxme.generator.javaclasswriter
Class BasicJavaClassWriter

java.lang.Object
  extended byde.ispsoft.jaxme.generator.javaclasswriter.BasicJavaClassWriter
All Implemented Interfaces:
JavaClassWriter
Direct Known Subclasses:
JdbcTableClassWriter

public class BasicJavaClassWriter
extends java.lang.Object
implements JavaClassWriter

Author:
Jochen Wiedmann

Field Summary
protected  SourceWriterImpl sourceWriter
           
 
Constructor Summary
BasicJavaClassWriter(SourceWriterImpl pSourceWriter, SchemaComplexElement pElement)
          Creates a new instance of BasicJavaClassWriter
 
Method Summary
protected  void addRestrictions(JavaSource pSource, JavaMethod pMethod, SchemaAbstractSimpleElement pChild, java.lang.String pFieldName, java.lang.String pContext, java.lang.String pIndent)
          Adds handling for restrictions to the validateMe() method.
protected  void addValidationException(JavaMethod pMethod, java.lang.Integer pErrorCode, java.lang.String pIndent, java.lang.String pMsg, java.lang.String pContext)
          Adds a ValidationException to the validateMe() method.
protected  void fillPrefixList(SchemaElement pElement, java.util.Map pUris, java.util.Set pPrefixes)
          Fills the list generated by getPrefixListField().
protected  int generateCloneFor(JavaMethod pJm, SchemaElement pElement, int i)
          Clones a single attribute or child element.
protected  void generateField(JavaSource pJs, SchemaElement pChild)
          Generates a single attribute or subelement.
protected  void generateFields(SchemaElement pElement, JavaSource pJs)
          Adds properties for a complex elements attributes and subelements.
protected  JavaMethod getAddFieldMethod(JavaSource pJs, SchemaElement pChild)
          Creates a fields add method.
protected  java.util.Map getChildMap(java.util.Iterator pIterator)
           
protected  JavaMethod getChildsToSAXMethod(JavaSource pJs)
          Generates the childsToSAX() method.
protected  JavaMethod getCloneMethod()
          Generates the clone() method.
protected  JavaConstructor getDefaultConstructor(JavaSource pJs)
          Generates the default constructor.
protected  JavaConstructor getDefaultHandlerConstructor(JavaSource pJs)
          Generates a default constructor for the handler class.
protected  JavaField getFieldDeclaration(JavaSource pJs, SchemaElement pChild)
          Generates a single attributes or subelements declaration.
protected  JavaMethod getGetAttributeMethod(JavaSource pJs)
          Generates the methods getAttribute() method.
protected  JavaMethod getGetAttributesMethod()
          Generates the method getAttributes().
protected  JavaMethod getGetElementMethod(JavaSource pJs)
          Generates the methods getElement() method.
protected  JavaMethod getGetFieldMethod(JavaSource pJs, SchemaElement pChild)
          Creates a fields get method.
 JavaMethod getGetPrefixListMethod()
          Generates the getPrefixList method.
 JavaSource getHandlerClass()
          Generates a JMContentHandler.
 java.util.List getImports()
          Looks for additional import statements.
protected  JavaField getLocalNameField(JavaSource pJs)
          Generates the local name field.
protected  boolean getLogWithLog4j()
          Returns whether logging code for log4j should be generated.
 JavaSource getManagerClass()
          Generates a JMManager class.
protected  JavaField getMyElemField(JavaSource pJs)
          Generates the handles myelem field.
protected  JavaField getNamespaceUriField(JavaSource pJs)
          Generates the namespace declaration field.
protected  JavaMethod getNewContentHandlerMethod(JavaSource pJs)
          Generates the handlers newHandler() method.
protected  JavaMethod getNewResultNodeMethod(JavaSource pJs)
          Generates a newResultNode() method for the handler class.
protected  JavaField getPrefixListField(JavaSource pJs)
          Generated the PREFIX_LIST field.
protected  JavaMethod getProcessResultNodeMethod(JavaSource pJs)
          Generates the processResultNode() method.
protected  JavaConstructor getProtectedConstructor(JavaSource pJs)
          Generates the protected constructor.
protected  JavaMethod getSetAttributeMethod(JavaSource pJs)
          Generates the methods setAttribute() method.
protected  JavaMethod getSetFieldMethod(JavaSource pJs, SchemaElement pChild)
          Creates a fields set method.
protected  JavaField getStateField(JavaSource pJs)
          Generates the handles state field.
protected  JavaMethod getValidateMeMethod(JavaSource pJs)
          Generates the validateMe() method.
protected  JavaMethod getValidateMethod(JavaSource pJs)
          Generates the validate() method.
 JavaSource getXmlClass()
          Generates a JMAnyElement class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourceWriter

protected SourceWriterImpl sourceWriter
Constructor Detail

BasicJavaClassWriter

public BasicJavaClassWriter(SourceWriterImpl pSourceWriter,
                            SchemaComplexElement pElement)
Creates a new instance of BasicJavaClassWriter

Method Detail

getLogWithLog4j

protected boolean getLogWithLog4j()

Returns whether logging code for log4j should be generated.


getNamespaceUriField

protected JavaField getNamespaceUriField(JavaSource pJs)

Generates the namespace declaration field.


getLocalNameField

protected JavaField getLocalNameField(JavaSource pJs)

Generates the local name field.


getDefaultConstructor

protected JavaConstructor getDefaultConstructor(JavaSource pJs)

Generates the default constructor.


getProtectedConstructor

protected JavaConstructor getProtectedConstructor(JavaSource pJs)

Generates the protected constructor.


getFieldDeclaration

protected JavaField getFieldDeclaration(JavaSource pJs,
                                        SchemaElement pChild)

Generates a single attributes or subelements declaration.


getGetFieldMethod

protected JavaMethod getGetFieldMethod(JavaSource pJs,
                                       SchemaElement pChild)

Creates a fields get method.


getSetFieldMethod

protected JavaMethod getSetFieldMethod(JavaSource pJs,
                                       SchemaElement pChild)

Creates a fields set method.


getAddFieldMethod

protected JavaMethod getAddFieldMethod(JavaSource pJs,
                                       SchemaElement pChild)

Creates a fields add method.


generateField

protected void generateField(JavaSource pJs,
                             SchemaElement pChild)

Generates a single attribute or subelement.


generateFields

protected void generateFields(SchemaElement pElement,
                              JavaSource pJs)

Adds properties for a complex elements attributes and subelements.


getGetElementMethod

protected JavaMethod getGetElementMethod(JavaSource pJs)

Generates the methods getElement() method.


getGetAttributeMethod

protected JavaMethod getGetAttributeMethod(JavaSource pJs)

Generates the methods getAttribute() method.


getSetAttributeMethod

protected JavaMethod getSetAttributeMethod(JavaSource pJs)

Generates the methods setAttribute() method.


getValidateMethod

protected JavaMethod getValidateMethod(JavaSource pJs)

Generates the validate() method.


addValidationException

protected void addValidationException(JavaMethod pMethod,
                                      java.lang.Integer pErrorCode,
                                      java.lang.String pIndent,
                                      java.lang.String pMsg,
                                      java.lang.String pContext)

Adds a ValidationException to the validateMe() method.


addRestrictions

protected void addRestrictions(JavaSource pSource,
                               JavaMethod pMethod,
                               SchemaAbstractSimpleElement pChild,
                               java.lang.String pFieldName,
                               java.lang.String pContext,
                               java.lang.String pIndent)

Adds handling for restrictions to the validateMe() method.


getValidateMeMethod

protected JavaMethod getValidateMeMethod(JavaSource pJs)
                                  throws SchemaException

Generates the validateMe() method.

Throws:
SchemaException

getChildsToSAXMethod

protected JavaMethod getChildsToSAXMethod(JavaSource pJs)

Generates the childsToSAX() method.


getGetAttributesMethod

protected JavaMethod getGetAttributesMethod()

Generates the method getAttributes().


generateCloneFor

protected int generateCloneFor(JavaMethod pJm,
                               SchemaElement pElement,
                               int i)

Clones a single attribute or child element.


getCloneMethod

protected JavaMethod getCloneMethod()

Generates the clone() method.


getImports

public java.util.List getImports()

Looks for additional import statements.


fillPrefixList

protected void fillPrefixList(SchemaElement pElement,
                              java.util.Map pUris,
                              java.util.Set pPrefixes)

Fills the list generated by getPrefixListField().

Parameters:
pElement - The element to search for namespace declarations.
pUris - A Map of namespace/prefix pairs.
pPrefixes - A Set of prefixes in pUris; note that this implies that neither namespaces nor prefixes can be declared twice.

getPrefixListField

protected JavaField getPrefixListField(JavaSource pJs)

Generated the PREFIX_LIST field.


getGetPrefixListMethod

public JavaMethod getGetPrefixListMethod()

Generates the getPrefixList method.


getXmlClass

public JavaSource getXmlClass()
                       throws java.lang.Exception

Generates a JMAnyElement class.

Specified by:
getXmlClass in interface JavaClassWriter
Throws:
java.lang.Exception

getManagerClass

public JavaSource getManagerClass()

Generates a JMManager class.

Specified by:
getManagerClass in interface JavaClassWriter

getDefaultHandlerConstructor

protected JavaConstructor getDefaultHandlerConstructor(JavaSource pJs)

Generates a default constructor for the handler class.


getNewResultNodeMethod

protected JavaMethod getNewResultNodeMethod(JavaSource pJs)

Generates a newResultNode() method for the handler class.


getMyElemField

protected JavaField getMyElemField(JavaSource pJs)

Generates the handles myelem field.


getStateField

protected JavaField getStateField(JavaSource pJs)

Generates the handles state field.


getNewContentHandlerMethod

protected JavaMethod getNewContentHandlerMethod(JavaSource pJs)

Generates the handlers newHandler() method.


getProcessResultNodeMethod

protected JavaMethod getProcessResultNodeMethod(JavaSource pJs)

Generates the processResultNode() method.


getHandlerClass

public JavaSource getHandlerClass()

Generates a JMContentHandler.

Specified by:
getHandlerClass in interface JavaClassWriter

getChildMap

protected java.util.Map getChildMap(java.util.Iterator pIterator)