|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.xml.xmlc.dom.generic.BuildMethodMappings
Class to calculate which node are to have build methods created for them based on trying to optimize the amount of code (create-cost) in each build methods without overflowing the maximum create-cost.
Build methods are normally rooted at a subtree. Costs are adjusted by moving the creation of children into sub-build methods. This leaves just the cost of calling the build method. If the build cost is till too high after moving all children into build methods, the methods are chained together to handle creating the children.
Note that the tree is a bit more comple than just the child nodes. Elements have attributes and DocumentTypes have lists of nodes. Collectively, these are refered to as contained nodes.
The advantage of this object determining where build methods are created in a seperate traversal from creating the build methods is that the determination is best down from the bottom up, while creating the methods is done top-down. The seperation also keeps the code cleaner and easier to understand. The cost is building an intermediate table.
Field Summary | |
static int |
BUILD_METHOD_CALL_CREATE_COST
Create-cost to call a build-method. |
static int |
CREATE_ELEMENT_CREATE_COST
Create-cost to create an element node. |
static int |
CREATE_NODE_CREATE_COST
Create-cost to create other nodes. |
Constructor Summary | |
BuildMethodMappings(int maxCreateCostPerBuildMethod,
Document document)
Constructor. |
Method Summary | |
(package private) boolean |
canBeMethodRoot(Node node)
Policy control: Determine if a node can be the root of a build method. |
int |
getCreateCost(Node node)
Get the create cost of a node in it's method. |
int |
getNodeTypeCost(Node node)
Policy control: Get the cost of creating a single node based on its type. |
boolean |
isMethodRoot(Node node)
Should a new method be created at the root of this node. |
String |
toString(Node node)
Get a string repersentation of an entry for debugging. |
boolean |
useChainedChildrenMethods(Node node)
Should the children be created in a chained method? |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final int BUILD_METHOD_CALL_CREATE_COST
public static final int CREATE_ELEMENT_CREATE_COST
public static final int CREATE_NODE_CREATE_COST
Constructor Detail |
public BuildMethodMappings(int maxCreateCostPerBuildMethod, Document document)
Method Detail |
boolean canBeMethodRoot(Node node)
public int getNodeTypeCost(Node node)
public boolean isMethodRoot(Node node)
public boolean useChainedChildrenMethods(Node node)
public int getCreateCost(Node node)
public String toString(Node node)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |