|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.taursys.xml.ComponentFactory
Abstract class used to automate the creation of Components based on
the XML Document and its Elements. It determines the Component type based
on its element tag and "id" attribute). Concrete subclasses must override
the initTagTable
method and populate the tagTable with
suggested components for the elements in the XML document.
This class contains two primary methods:
getSuggestedComponents
- for use by design tools.createComponents
- to automatically create and bind
Components
at runtime.
Field Summary | |
static java.lang.String |
ID_DELIMITER
|
protected java.util.Hashtable |
tagTable
|
static java.lang.String |
TEMPLATE_NODE
|
Constructor Summary | |
ComponentFactory()
Default constructor which initializes tag table by calling initTagTable |
Method Summary | |
protected boolean |
bindComponent(NodeDescriptor nd,
org.w3c.dom.Element element,
ValueHolder[] holders,
Component component)
|
protected abstract Component |
createComponentForElement(org.w3c.dom.Element element,
NodeDescriptor nd)
|
protected abstract Component |
createComponentForElement(java.lang.String id,
org.w3c.dom.Element element,
ValueHolder[] holders)
Create a component for given element and set its properties. |
void |
createComponents(Container container,
ValueHolder[] holders)
Creates components based on document, set their properties (including valueHolder) and adds them to the container. |
void |
createComponents(Container container,
ValueHolder[] holders,
boolean bindExisting)
Creates components based on document, set their properties (including valueHolder) and adds them to the container. |
abstract java.util.Vector |
getSuggestedComponents(org.w3c.dom.Element element)
Returns a Vector of suggested Component class names for given Element. |
protected java.util.Vector |
getSuggestedComponents(java.lang.String tagName,
java.lang.String id,
org.w3c.dom.Element element)
Returns a Vector of suggested Component class names for given Element. |
protected abstract void |
initTagTable()
Initialize values in the tag table |
protected NodeDescriptor |
parseBindSyntax(java.lang.String value)
|
void |
printComponentTree(Container parent,
java.lang.String level)
Prints the component tree contents to the console |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String ID_DELIMITER
public static final java.lang.String TEMPLATE_NODE
protected java.util.Hashtable tagTable
Constructor Detail |
public ComponentFactory()
Method Detail |
public abstract java.util.Vector getSuggestedComponents(org.w3c.dom.Element element)
If the Element has an ID, then the DocumentElement Component will be added to the end of the suggestion list.
If the id contains the TEMPLATE_NODE keyword, then a Template will be added to the top of the suggestion list.
If there are no suggested types of Component for the given Element, then an empty Vector will be returned.
Subclasses should override this method if more than the Element tag name is needed to determine the suggested components.
element
- to return default Component type for
public void createComponents(Container container, ValueHolder[] holders)
Creates components based on document, set their properties (including valueHolder) and adds them to the container. As it moves through the document, it first checks to see if the component is already in the container (by matching id's). If it is, the existing component is moved to the proper place in the heirarchy. Otherwise it will create a component.
This method builds a component heirarchy which matches the document order and heirarchy. If any newly created component is itself a Container type, then all children of that component are added to it rather than its parent container.
Only bound components which are bound to one of the given value holders are created.
container
- the Container to add components toholders
- an array of valueholders.public void printComponentTree(Container parent, java.lang.String level)
parent
- starting parent containerlevel
- spaces to indent initiallypublic void createComponents(Container container, ValueHolder[] holders, boolean bindExisting)
Creates components based on document, set their properties (including valueHolder) and adds them to the container. As it moves through the document, it first checks to see if the component is already in the container (by matching id's). If it is, the existing component is moved to the proper place in the heirarchy. Otherwise it will create a component.
This method builds a component heirarchy which matches the document order and heirarchy. If any newly created component is itself a Container type, then all children of that component are added to it rather than its parent container.
Only bound components which are bound to one of the given value holders are created.
container
- the Container to add components toholders
- an array of valueholders.protected abstract void initTagTable()
protected java.util.Vector getSuggestedComponents(java.lang.String tagName, java.lang.String id, org.w3c.dom.Element element)
If an ID is given, then the DocumentElement Component will be added to the end of the suggestion list.
If the id contains the TEMPLATE_NODE keyword, then a Template will be added to the top of the suggestion list.
If an ID is given and the id does not contain the TEMPLATE_NODE keyword, but the given element has child nodes, then a Template will be added before the DocumentElement suggestion.
If there are no suggested types of Component for the given tag, then an empty Vector will be returned.
tagName
- to return default Component type forid
- of the tag or nullelement
- the Element to get suggestions for
protected abstract Component createComponentForElement(java.lang.String id, org.w3c.dom.Element element, ValueHolder[] holders)
id
- the id of the Element to create the Component for.element
- the Element to create the Component for.holders
- the array of ValueHolders for bindingprotected abstract Component createComponentForElement(org.w3c.dom.Element element, NodeDescriptor nd)
protected NodeDescriptor parseBindSyntax(java.lang.String value)
protected boolean bindComponent(NodeDescriptor nd, org.w3c.dom.Element element, ValueHolder[] holders, Component component)
nd
- element
- holders
- component
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |