|
DimDom v0.8.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.alltimeflashdreamer.dimdom.AbstractXHTMLDocument
Title: AbstractXHTMLDocument
Description: This class wraps the necessary functionality around the "logic"
that is implemented in the DimDom engine, reference implementation.
Each subclass of this class must perform extended, not referencial logic
operations using the specified SiteData instance of this class.
The ideal usage of a subclass would be to instantiate the fully filled
SiteData object (e.g. as a subclass) and pass it to the DimDom, e.g. from
within a servlet:
//fill every information into the SiteData within a subclass' constructor
MySiteData mySiteData = new MySiteData();
//call your own subclass' print method (this class knows which file it shall use)
response.getWriter().write(DimDom.print(mySiteData));
Inner Class Summary | |
protected class |
AbstractXHTMLDocument.RepeatedElement
This simple class stored the template information on a repeated element, i.e. |
Field Summary | |
protected Hashtable |
hIDNodeList
the list of template nodes having an "id" attribute |
protected Hashtable |
hMicroTemplateNodes
the list of nodes and their repeated child elements (micro-template structure nodes) |
protected Hashtable |
hProcessedIDs
the list of already processed id nodes, to find out whether it's a repeated command on the same node or not, stored together with the number of repetitions; this number is altered on each repetition of the node |
protected AbstractXHTMLSiteData |
siteData
pointer to AbstractXHTMLSiteData object which is used to process the dynamic data within the reference implementation |
Constructor Summary | |
AbstractXHTMLDocument()
|
Method Summary | |
protected Hashtable |
buildListOfIDNodes(Document doc)
Builds a hashtable containing ID/XHTML element pairs to find the nodes more easily when modifying them during the following update process with the dynamic values. |
protected void |
buildMicroTemplateNodeList(Hashtable hClonedIDNodeList)
(Re)Builds the internal list of micro-template nodes, i.e. |
protected Element |
createAndAddNextDimDomChild(Element element,
boolean bIsRepeatedCommand)
A new child element is created, appended and returned. Which node is chosen, is up to the specifications of the DimDom. |
protected Node |
createEmptyTextNode(Document doc)
Creates an "empty text node", i.e. |
protected Element |
createSelectedElement(Document doc,
String sText)
Creates a new node of type "b" and appends a text node to it, containing sText. |
protected void |
findAndAddRepeatedElements(NodeList nodes,
Vector vRepeatedElements)
This method recursively searches the given NodeList for each member of the DOM tree having a defined "dimdom" attribute. |
protected Element |
findFirstLeafElement(Node node)
Searches the tree down until he finds a leaf node of type Element. |
protected Node |
findFirstNodeByName(Node node,
String sNodeName)
Searches the tree recursively, starting with node, for a node having the given name. |
protected Text |
findFirstText(Node node)
Finds the first text down the tree, starting with node. |
protected Element |
getElement(Hashtable hIDNodeList,
String sElementIDValue,
Document clonedDoc)
This method can be called be extending classes to directly access an Element specified by the id attribute value within the template. |
protected Text |
getFirstText(Element element)
Searches the first text node done the tree, starting with element. |
protected abstract Element |
getNextRepeatedElement(String sNodeIdentifier,
Element element)
This class doesn't implement the logic that is necessary to find out which node is the next to be processed in micro-template structures. |
protected int |
getProcessedRepetitionsCount(String sNodeIdentifier)
Returns the total number of already processed repetitions of the node having the given identifier. |
protected AbstractXHTMLDocument.RepeatedElement[] |
getRepeatedElements(String sNodeIdentifier)
Returns the list of RepeatedElement instances that were initialized for the given node or null, if no such nodes exist for the given node in the template. |
protected int |
getStoredTableDataChildCount(String sNodeIdentifier)
Returns the stored value for the amount of td/th child nodes, as calculated int getTableDataChildCount. |
protected int |
getTableDataChildCount(Element element)
Returns the current amount of td or th (see isTableDataNode method) child elements for the given node identifier. |
protected void |
hide(Element element,
Node replacingNode)
Hides the Element parameter by replacing it with another node. If the element is a "tr" element, then the children of type "th" or "td" are searched and their content is hided, and its height attribute is removed. |
protected void |
hideChildElements(Element element,
Node replacingNode)
Hides each child element (!) of element, i.e. |
protected boolean |
isDimDomListNode(Node node)
Returns whether node is a DimDom list node or not, i.e. |
protected boolean |
isEmpty(String sTestString)
Returns whether the given test string is null or equals the empty string. |
protected boolean |
isHTMLListNode(Node node)
Returns whether node is a HTML list node or not, i.e. |
protected boolean |
isRepeatedCommand(String sNodeIdentifier,
Element element)
Returns whether the given element is a micro-template node or not. |
protected boolean |
isTableDataNode(Node node)
Returns whether node is a table dent node or not, i.e. |
protected boolean |
isTableRowNode(Node node)
Returns whether node is a table row node or not, i.e. |
protected void |
parseFile(File file)
Parses the parameter file, but only during initialization or if the specified file has a new last modification date. |
protected void |
parseFile(String sFileName)
Parses the file specified in sFileName, but only during initialization or if the specified file has a new last modification date. |
protected void |
parseInputStream(InputStream stream)
Parses the InputStream specified in stream (parsing is done any time the method is executed). |
protected void |
parseString(String sInput)
Parses the InputStream specified in stream (parsing is done any time the method is executed). |
String |
print()
Forces the XHTMLDocument instance to print out its dynamically adapted content as a fully qualified XHTML String. This is done after the cloning of the internal Document pointer and the calling of the processDynamicData method, which updates the DOM. |
protected void |
processDimDomNode(DimDomNodeImpl dimdomNode,
Element element,
boolean bIsRepeatedCommand)
Processes one node of the template having an id attribute value, along the specifications of DimDom. |
protected void |
removeChildElements(Node node)
Removes the child nodes that are Element nodess. |
protected void |
removeChildTextNodes(Node node)
Removes the child nodes that are Text nodess. |
protected void |
removeNodes(Vector vNodesToDelete)
Removes each node in the given list. |
protected void |
setAttribute(Element element,
Attr attribute)
Sets an attribute name and value to the parameter Element. |
protected void |
setCommonAttribute(Element element,
Attr attribute)
Sets the attribute and its value to each node found within the document that has the same node name as element. |
protected void |
setContent(String sNodeIdentifier,
Element element,
String[] sValues,
boolean bIsSelectedRow,
int iSelectedColumn,
boolean bIsRepeatedCommand)
Sets the children's content of element using the value list parameter. |
protected void |
setContent(String sNodeIdentifier,
Element element,
String sContent,
boolean bIsSelected,
boolean bIsRepeatedCommand)
Sets the content of element to sContent. |
protected void |
setOptionTagSelected(Element option,
boolean bIsSelected)
Sets or unsets the selected attribute of the option tag, depending on the boolean parameter. |
protected void |
setRepeatedElements(String sNodeIdentifier,
AbstractXHTMLDocument.RepeatedElement[] repeatedElements)
Sets the list of RepeatedElement instances of the given node. |
void |
setSiteData(XHTMLSiteData siteData)
This method is (typically) called by the servlet instantiating a specific subclass of this class that needs to be filled with dynamic data. It is defined within a separate interface to hide the functionality of implementing classes to the servlet programmer, because the updating process is uni-directional (thread safety!). |
protected void |
setText(Element element,
String sText)
Sets the given string content to the given node by setting the content to the first found text node. |
protected void |
setText(Element element,
String sText,
boolean bIsSelected)
Just calls setText(element, sText), if bIsSelected is false; else a selected element is created and appended to element. |
protected void |
setTexts(Element element,
Vector vNotListValues,
int iSelectedIndex)
Sets a list of string values to a node that is not a list node (see isDimDomListNode method). |
protected void |
setTexts(Element element,
Vector vNotListValues,
int iNColumnsPerRow,
int iSelectedRow,
int iSelectedColumn)
Sets a 2D field of string values to a node that is not a list node (see isDimDomListNode method). |
protected void |
wrapWithLink(Element element,
DimDomNodeImpl.EmbeddingLink embeddingLink)
Wraps the parameter Element with a link specified by its target URL and frame. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected AbstractXHTMLSiteData siteData
protected Hashtable hIDNodeList
protected Hashtable hMicroTemplateNodes
protected Hashtable hProcessedIDs
Constructor Detail |
public AbstractXHTMLDocument()
Method Detail |
public String print() throws IOException, DimDomException
print
in interface XHTMLDocument
IOException
- thrown by the parser (input source)DimDomException
- thrown by the processor, if something is/went
wrongpublic void setSiteData(XHTMLSiteData siteData) throws SAXException, IOException, DimDomException
setSiteData
in interface XHTMLDocument
siteData
- an instance of a class implementing
org.alltimeflashdreamer.dimdom.XHTMLSiteData interfaceSAXException
- thrown by the parserIOException
- thrown by the parser (input source)DimDomException
- thrown by the processor, if something is/went
wrongprotected Element getElement(Hashtable hIDNodeList, String sElementIDValue, Document clonedDoc) throws DimDomException
hIDNodeList
- where the found nodes are stored insElementIDValue
- the id value of the node (or the name, in
case of the setting of a common attribute)clonedDoc
- the Document object to search for a common
node template, in caseDimDomException
- thrown if the node to be processed is not a
Element nodeprotected void processDimDomNode(DimDomNodeImpl dimdomNode, Element element, boolean bIsRepeatedCommand) throws DimDomException
dimdomNode
- the object containing the dynamic information;
must not be null!element
- the element to which the dynamic information
shall be appliedbIsRepeatedCommand
- tells the engine about whether this node has
already been handled within the "getNextRepeatedElement
intelligence" or not; if not, the method has to take care on its own
about what to do with repeated data structures (not nodes)DimDomException
- if some error occurs while adding the
information to the nodeprotected abstract Element getNextRepeatedElement(String sNodeIdentifier, Element element) throws DimDomException
sNodeIdentifier
- the id attribute value of the node to be
processedelement
- the current node to be processed, for
deciding how to behaveDimDomException
- wrapper for unexpected errorsprotected void setText(Element element, String sText) throws DimDomException
element
- the element to set the content tosText
- the text to set to element; if null or empty,
the node's text is set to ""DimDomException
- wrapped DOMException, in caseprotected Text getFirstText(Element element)
element
- the root node to searchprotected void setTexts(Element element, Vector vNotListValues, int iSelectedIndex) throws DimDomException
element
- node to add the list tovNotListValues
- list of values (only String instances)iSelectedIndex
- the selected index; if out of range (e.g.
-1), no value is marked as boldDimDomException
- in case something went wrong, this is an own
or a wrapped DOMExceptionprotected void setTexts(Element element, Vector vNotListValues, int iNColumnsPerRow, int iSelectedRow, int iSelectedColumn) throws DimDomException
element
- node to add the list tovNotListValues
- list of values (only String instances)iNColumnsPerRow
- how many columns are there per row?iSelectedRow
- the selected row index; if out of range (e.g.
-1), no value is marked as boldiSelectedColumn
- the selected column index; if out of range
(e.g. -1), no value is marked as boldDimDomException
- in case something went wrong, this is an own
or a wrapped DOMExceptionprotected Element createSelectedElement(Document doc, String sText) throws DimDomException
doc
- the Document to create nodes withsText
- the text to show selected; if null, "" is addedDimDomException
- a wrapped DOMException, in caseprotected void setContent(String sNodeIdentifier, Element element, String sContent, boolean bIsSelected, boolean bIsRepeatedCommand) throws DimDomException
sNodeIdentifier
- the name of the currently processed
DimDomNodeelement
- the Element to set the content tosContent
- the content (if null, it's set to "")bIsSelected
- whether to select this element or notbIsRepeatedCommand
- tells the method whether this is a
micro-template structure node or notDimDomException
- if element is null, or a wrapped
DOMException, in caseprotected void setContent(String sNodeIdentifier, Element element, String[] sValues, boolean bIsSelectedRow, int iSelectedColumn, boolean bIsRepeatedCommand) throws DimDomException
sNodeIdentifier
- the name of the currently processed
DimDomNodeelement
- the Element to set the content tosValues
- the content (if null, it's set to "")bIsSelectedRow
- whether it's a selected row or notiSelectedColumn
- if it's selected row and the selected column
is a valid index, only this column entry will be selected, else the
whole row; if it's not the selected row, this parameter is ignoredbIsRepeatedCommand
- tells the method whether this is a
micro-template structure node or notDimDomException
- if element or sValues are null, or a wrapped
DOMException, in caseprotected final void setOptionTagSelected(Element option, boolean bIsSelected)
option
- the HTML option tag to updatebIsSelected
- set selected?protected void setText(Element element, String sText, boolean bIsSelected) throws DimDomException
element
- the node to set the text tosText
- the text to set to the nodebIsSelected
- whether to mark the text as selected or notDimDomException
- in case something went wrong, this is an own
or a wrapped DOMExceptionprotected void setCommonAttribute(Element element, Attr attribute) throws DimDomException
element
- the element having the common node id (may
not be null)attribute
- the Attr instance to add to these nodesDimDomException
- wrapped DOMException, in caseprotected void parseInputStream(InputStream stream) throws SAXException, IOException, DimDomException
stream
- the InputStream to parse fromSAXException
- thrown by the parserIOException
- thrown by the parser (input source)DimDomException
- thrown by the processor, if something is/went
wrongprotected void parseString(String sInput) throws SAXException, IOException, DimDomException
sInput
- the String to parseSAXException
- thrown by the parserIOException
- thrown by the parser (input source)DimDomException
- thrown by the processor, if something is/went
wrongprotected void parseFile(String sFileName) throws SAXException, IOException, DimDomException
sFileName
- the name of the file to be parsedSAXException
- thrown by the parserIOException
- thrown by the parser (input source)DimDomException
- thrown by the processor, if something is/went
wrongprotected void parseFile(File file) throws SAXException, IOException, DimDomException
file
- the file to parseSAXException
- thrown by the parserIOException
- thrown by the parser (input source)DimDomException
- thrown by the processor, if something is/went
wrongprotected void setAttribute(Element element, Attr attribute) throws DimDomException
element
- the Element to set the attribute toattribute
- the Attr to addDimDomException
- thrown if element or attribute is nullprotected void wrapWithLink(Element element, DimDomNodeImpl.EmbeddingLink embeddingLink) throws DimDomException
element
- the Element to embed in a linkembeddingLink
- the instance of DimDomNodeImpl describing the
embedding "a" tag and its attributesDimDomException
- if element is null or a wrapped DOMException,
in caseprotected void hide(Element element, Node replacingNode) throws DimDomException
element
- element to hide or replace with a Text nodereplacingNode
- the node to replace element withDimDomException
- if element or replacingNode is null or a
wrapped DOMException, in caseprotected Hashtable buildListOfIDNodes(Document doc) throws DimDomException
doc
- the org.w3c.dom.Document containing the DOM
root node to be searchedDimDomException
- thrown if an id attribute value is found more
than once in the templateprotected Node createEmptyTextNode(Document doc)
doc
- the owner document which shall created the nodeprotected Element findFirstLeafElement(Node node)
node
- the starting node for the searchprotected boolean isDimDomListNode(Node node)
node
- the node to queryprotected boolean isHTMLListNode(Node node)
node
- the node to queryprotected boolean isTableDataNode(Node node)
node
- the node to be checkedprotected boolean isTableRowNode(Node node)
node
- the node to be checkedprotected boolean isRepeatedCommand(String sNodeIdentifier, Element element)
sNodeIdentifier
- the id attribute value of the nodeelement
- the element to checkprotected int getProcessedRepetitionsCount(String sNodeIdentifier)
sNodeIdentifier
- the value of the node's id attribute, i.e. the
node identifierprotected Node findFirstNodeByName(Node node, String sNodeName)
node
- root node to searchsNodeName
- name to search forprotected Element createAndAddNextDimDomChild(Element element, boolean bIsRepeatedCommand) throws DimDomException
element
- element to which a new child shall be addedbIsRepeatedCommand
- tells the method whether this is a
micro-template structure node or notDimDomException
- a wrapped DOMException, in caseprotected final void findAndAddRepeatedElements(NodeList nodes, Vector vRepeatedElements) throws DimDomException
nodes
- the list of (child) nodes to search
repeatedlyvRepeatedElements
- the list to add the found repeated elements
toDimDomException
- thrown by the CommandParser, in caseprotected AbstractXHTMLDocument.RepeatedElement[] getRepeatedElements(String sNodeIdentifier)
sNodeIdentifier
- the id attribute of the node to get the repeated
elements forprotected void setRepeatedElements(String sNodeIdentifier, AbstractXHTMLDocument.RepeatedElement[] repeatedElements)
sNodeIdentifier
- the id attribute of the node to get the repeated
elements forrepeatedElements
- the list of repeated elements or nullprotected int getTableDataChildCount(Element element)
element
- the Element for which the value shall be returnedprotected int getStoredTableDataChildCount(String sNodeIdentifier)
sNodeIdentifier
- the id node for which the value shall be returnedprotected void hideChildElements(Element element, Node replacingNode)
element
- the element to hidereplacingNode
- the node to replace element withprotected final Text findFirstText(Node node)
node
- the starting node for the searchprotected final void removeNodes(Vector vNodesToDelete)
vNodesToDelete
- protected void removeChildTextNodes(Node node)
node
- the node to remove the child Texts ofprotected void removeChildElements(Node node)
node
- the node to remove the child Elements ofprotected final void buildMicroTemplateNodeList(Hashtable hClonedIDNodeList) throws DimDomException
hClonedIDNodeList
- list of id nodes to checkDimDomException
- thrown by the command parserprotected final boolean isEmpty(String sTestString)
sTestString
- the String to be tested
|
Copyright (c) 2001/02 by Florian Steinsiepe | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |