Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.enhydra.xml.xmlc.dom.generic
Class DOMBuilderGenerator  view DOMBuilderGenerator download DOMBuilderGenerator.java

java.lang.Object
  extended byorg.enhydra.xml.xmlc.dom.generic.DOMBuilderGenerator

public class DOMBuilderGenerator
extends java.lang.Object

Class to generate code to build the document tree using only the W3C DOM interface. The document building code is generated in several functions to avoid the JVM limit on maximum method size. Since it is not possible to determine the amount of bytecode generate, a metic is defined called create-cost. A unit of create-cost is approximately the cost to create a node and append it to it's parent. The limit on create-cost is determined experimentally.

The following methods can be overridden to provide DOM implementation-specific code generation:


Nested Class Summary
private  class DOMBuilderGenerator.BuildMethodGenerator
          Class that represents a single subdocument building method.
 
Field Summary
protected static java.lang.String DOCUMENT_ARG
           
private static java.lang.String DOCUMENT_ELEMENT_VAR
           
private  org.enhydra.xml.xmlc.dom.AccessorGenerator fAccessorGenerator
          Generator of access methods, needed to generate access method initialization
private  BuildMethodMappings fBuildMethodMappings
          Object that determines where new methods will be created to prevent method overflow.
private  org.enhydra.xml.xmlc.codegen.JavaClass fDocClass
          Class being created.
private  org.w3c.dom.Document fDocument
          Source document.
private  java.lang.String fDocumentArgClassName
          Type of document argument of build methods.
private  org.enhydra.xml.xmlc.compiler.ElementTable fElementTable
          Table of element information.
private  int fMaxCreateCostPerBuildMethod
          Maximum creation-cost that a single build method can handle.
private  java.lang.String fMethodName
          Name of method to create.
private  NodeCreateGenerator fNodeCreateGenerator
          Object used to create DOM nodes.
private  boolean fStaticMethods
          Should the methods be static.
protected static java.lang.String PARENT_NODE_ARG
          Name of argument to method containing parent node.
 
Constructor Summary
DOMBuilderGenerator(java.lang.String methodName, org.w3c.dom.Document document, java.lang.String documentArgClassName, NodeCreateGenerator nodeCreateGenerator, org.enhydra.xml.xmlc.dom.AccessorGenerator accessorGenerator, org.enhydra.xml.xmlc.compiler.ElementTable elementTable, org.enhydra.xml.xmlc.codegen.JavaClass docClass, int maxCreateCostPerBuildMethod, boolean staticMethods)
          Constructor.
 
Method Summary
 void createMethodCall(java.lang.String docVarName, org.enhydra.xml.xmlc.codegen.JavaCode body)
          Create a call to the top level method that was generated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARENT_NODE_ARG

protected static final java.lang.String PARENT_NODE_ARG
Name of argument to method containing parent node.

See Also:
Constant Field Values

DOCUMENT_ARG

protected static final java.lang.String DOCUMENT_ARG
See Also:
Constant Field Values

DOCUMENT_ELEMENT_VAR

private static final java.lang.String DOCUMENT_ELEMENT_VAR
See Also:
Constant Field Values

fMaxCreateCostPerBuildMethod

private int fMaxCreateCostPerBuildMethod
Maximum creation-cost that a single build method can handle.


fDocumentArgClassName

private java.lang.String fDocumentArgClassName
Type of document argument of build methods. Allows derived DOMs to use a more specific argument type to avoid casting.


fMethodName

private java.lang.String fMethodName
Name of method to create.


fDocument

private org.w3c.dom.Document fDocument
Source document.


fNodeCreateGenerator

private NodeCreateGenerator fNodeCreateGenerator
Object used to create DOM nodes.


fElementTable

private org.enhydra.xml.xmlc.compiler.ElementTable fElementTable
Table of element information.


fBuildMethodMappings

private BuildMethodMappings fBuildMethodMappings
Object that determines where new methods will be created to prevent method overflow.


fDocClass

private org.enhydra.xml.xmlc.codegen.JavaClass fDocClass
Class being created.


fAccessorGenerator

private org.enhydra.xml.xmlc.dom.AccessorGenerator fAccessorGenerator
Generator of access methods, needed to generate access method initialization


fStaticMethods

private boolean fStaticMethods
Should the methods be static.

Constructor Detail

DOMBuilderGenerator

public DOMBuilderGenerator(java.lang.String methodName,
                           org.w3c.dom.Document document,
                           java.lang.String documentArgClassName,
                           NodeCreateGenerator nodeCreateGenerator,
                           org.enhydra.xml.xmlc.dom.AccessorGenerator accessorGenerator,
                           org.enhydra.xml.xmlc.compiler.ElementTable elementTable,
                           org.enhydra.xml.xmlc.codegen.JavaClass docClass,
                           int maxCreateCostPerBuildMethod,
                           boolean staticMethods)
                    throws org.enhydra.xml.xmlc.XMLCException
Constructor. Build the methods.

Method Detail

createMethodCall

public void createMethodCall(java.lang.String docVarName,
                             org.enhydra.xml.xmlc.codegen.JavaCode body)
Create a call to the top level method that was generated.