|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.xoetrope.builder.w3c.html.tags.XHtmlTagHandler
public abstract class XHtmlTagHandler
An generic processor for html tag/element processing. The handlers are managed as a singlely linked list such that navigating the parent handlers will ultimately lead to the handler for the root element. Each node stores its attribute set so the context for a particular node can always be determined.
The handler also stores the handlers for child nodes so that a complete model of the node hierarchy is created. This hierarchy can be navigated both forwards and backwards. Visitors can used to build up properties such as fonts and styling by iterating over the node hierarchy, with each node being given the option to stop the iteration should the visitor go out of scope, for example if a style applies within a DIV element it should not be applied in the parent of the DIV, so the DIV handler should stop the iteration.
The tag handlers are abstract so that derived classes are forced to define the newInstance method, this is necessary as the XHtmlBuilder holds a set of prototype objects for each tag type. Thus, to customize the handling of a particular tag type a new handler should be inserted into the builder. The builder can then instantiate the correct type of handler for each tag encountered.
Copyright (c) Xoetrope Ltd., 2002-2006
$Revision: 1.2 $
License: see License.txt
| Field Summary | |
|---|---|
protected javax.swing.text.MutableAttributeSet |
attribSet
|
protected XHtmlBuilder |
builder
|
protected java.util.ArrayList<XHtmlTagHandler> |
children
|
protected javax.swing.JComponent |
comp
|
protected java.lang.String |
content
|
protected XHtmlTagHandler |
parent
|
protected java.awt.Container |
parentComponent
|
protected XHtmlStyle |
style
|
| Constructor Summary | |
|---|---|
XHtmlTagHandler()
|
|
| Method Summary | |
|---|---|
void |
addChild(XHtmlTagHandler c)
Add a child to this handler. |
boolean |
addElement(XHtmlTagHandler child)
Add a child element, possibly data such as when an option is added to a SELECT element. |
void |
applyAlignment(java.lang.String value)
Set the alignment for the component |
void |
applyStyle(java.lang.String styleStr)
Apply a style to the component |
boolean |
breaksFlow()
Does this tag break the flow? |
boolean |
decorateAttribute(java.lang.Object attribute)
Decorate an attribute such as a font according to the relevant attributes that this element includes. |
void |
endProcessing(XComponentFactory cf)
The closing tag has been parsed and now the element can calulate its complete setup should it be dependant on its children for any information. |
java.lang.Object |
getAttribute(javax.swing.text.html.HTML.Attribute name)
Get an attribute value |
java.util.ArrayList<XHtmlTagHandler> |
getChildren()
Get teh children of this node, if any |
javax.swing.JComponent |
getComponent()
Get the component corresponding to this tag, if any |
java.lang.String |
getComponentName()
Get the component name, preferring the document ID over the name attribute |
java.lang.String |
getContent()
Get the content of this tag/element |
int |
getHeight(java.awt.Dimension parentSize)
Get a width in pixels or in percent of the parent width |
int |
getHeight(java.awt.Dimension parentSize,
double height)
Get a height in pixels or in percent of the parent width |
double |
getLength(java.lang.String lenStr)
Get the value of the width string |
XHtmlTagHandler |
getParent()
Get the parent handler |
java.lang.String |
getTextStyleAttributes(javax.swing.JComponent comp,
boolean openingTag)
Get the text formatting tags for this element |
int |
getWidth(java.awt.Dimension parentSize)
Get a width in pixels or in percent of the parent width |
int |
getWidth(java.awt.Dimension parentSize,
double width)
Get a width in pixels or in percent of the parent width |
abstract XHtmlTagHandler |
newInstance(XHtmlBuilder builder,
XHtmlTagHandler parent)
Create a new instance of this object |
void |
processComment(java.lang.String comment)
Process the element comment |
void |
processCommonAttributes(java.lang.String attribName,
java.lang.Object attribValue)
Process the common html attributes, includeing style, class, id, and lang. |
void |
processText(XComponentFactory cf,
java.lang.String text)
Process the element text |
void |
setBuilder(XHtmlBuilder htmlBuilder)
Set the html builder that instantiated this tag handler and that owns the document being processed. |
void |
setComponent(javax.swing.JComponent c)
Set the component used to represent this tag |
void |
setParent(XHtmlTagHandler p)
Set the parent handler for this object |
void |
startProcessing(XHtmlBuilder htmlBuilder,
XComponentFactory cf,
javax.swing.text.MutableAttributeSet as)
Process the opening html tag/element |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected XHtmlTagHandler parent
protected javax.swing.JComponent comp
protected javax.swing.text.MutableAttributeSet attribSet
protected java.lang.String content
protected java.util.ArrayList<XHtmlTagHandler> children
protected java.awt.Container parentComponent
protected XHtmlBuilder builder
protected XHtmlStyle style
| Constructor Detail |
|---|
public XHtmlTagHandler()
| Method Detail |
|---|
public java.lang.String getComponentName()
public void startProcessing(XHtmlBuilder htmlBuilder,
XComponentFactory cf,
javax.swing.text.MutableAttributeSet as)
htmlBuilder - the xui builder instance that is processing the html filecf - the component factory to use for the creation of individual componentsas - the attributes of this html tag.public void endProcessing(XComponentFactory cf)
cf - the component factory to use for the creation of individual componentspublic void processComment(java.lang.String comment)
comment - the content
public void processText(XComponentFactory cf,
java.lang.String text)
cf - the component factory to use for the creation of individual componentstext - the content
public void processCommonAttributes(java.lang.String attribName,
java.lang.Object attribValue)
public boolean addElement(XHtmlTagHandler child)
child - the child element
public abstract XHtmlTagHandler newInstance(XHtmlBuilder builder,
XHtmlTagHandler parent)
builder - the html builder and processor for the documentparent - the parent handler
public void setParent(XHtmlTagHandler p)
public XHtmlTagHandler getParent()
public void setBuilder(XHtmlBuilder htmlBuilder)
htmlBuilder - the page builderpublic java.util.ArrayList<XHtmlTagHandler> getChildren()
public void addChild(XHtmlTagHandler c)
c - the child handlerpublic java.lang.Object getAttribute(javax.swing.text.html.HTML.Attribute name)
name - the attribute name
public javax.swing.JComponent getComponent()
public void setComponent(javax.swing.JComponent c)
c - the componentpublic boolean decorateAttribute(java.lang.Object attribute)
attribute - the object that needs decoration
public void applyStyle(java.lang.String styleStr)
the - style stringpublic void applyAlignment(java.lang.String value)
value - the alignment LEFT|RIGHT|CENTERpublic double getLength(java.lang.String lenStr)
public int getWidth(java.awt.Dimension parentSize)
parentSize - the dimensions of the parent componentthe - width specification in pixels or a fraction of the paret
public int getWidth(java.awt.Dimension parentSize,
double width)
parentSize - the dimensions of the parent component
public int getHeight(java.awt.Dimension parentSize)
parentSize - the dimensions of the parent componentthe - width specification in pixels or a fraction of the paret
public int getHeight(java.awt.Dimension parentSize,
double height)
parentSize - the dimensions of the parent componentthe - height specification in pixels or a fraction of the paret
public java.lang.String getContent()
public java.lang.String getTextStyleAttributes(javax.swing.JComponent comp,
boolean openingTag)
comp - the component to formatopeningTag - true if the opening tags are being requested, false for the closing tags
public boolean breaksFlow()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||