|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.dmonix.xml.XMLUtil
org.dmonix.xml.html.HTMLGenerator
Utility class for creating HTML-formatted documents.
The output documents are based on standard XML, thus all elements
will be correctly formatted.
Copyright: Copyright (c) 2004
Company: dmonix.org
| Field Summary | |
protected org.w3c.dom.Element |
bodyNode
|
protected org.w3c.dom.Document |
doc
|
protected org.w3c.dom.Element |
headNode
|
protected org.w3c.dom.Element |
htmlNode
|
| Constructor Summary | |
HTMLGenerator()
Creates a new empty HTML document. |
|
HTMLGenerator(java.io.File file)
Creates a HTML document using an existing HTML document. |
|
HTMLGenerator(java.net.URL url)
Creates a HTML document using an existing HTML document. |
|
| Method Summary | |
org.w3c.dom.Element |
addAnchor(org.w3c.dom.Element parent,
java.lang.String href,
java.lang.String text)
Adds a hyper link. |
org.w3c.dom.Element |
addBR()
Adds a <BR/> to the document body. |
org.w3c.dom.Element |
addBR(org.w3c.dom.Element parent)
Adds a <BR/> to the provided element. |
org.w3c.dom.Element |
addElement(org.w3c.dom.Element parent,
java.lang.String name)
Add a new element. |
org.w3c.dom.Element |
addElement(org.w3c.dom.Element parent,
java.lang.String name,
ClassAttribute classAttribute)
Add a new element. |
org.w3c.dom.Element |
addElement(org.w3c.dom.Element parent,
java.lang.String name,
ClassAttribute classAttribute,
java.lang.String text)
Add a new element. |
org.w3c.dom.Element |
addElement(org.w3c.dom.Element parent,
java.lang.String name,
java.lang.String text)
Add a new element. |
org.w3c.dom.Element |
addElementToBody(java.lang.String name)
Add a new element to the document body. |
org.w3c.dom.Element |
addElementToBody(java.lang.String name,
ClassAttribute classAttribute)
Add a new element to the document body. |
org.w3c.dom.Element |
addHR()
Adds a <HR/> to the document body. |
org.w3c.dom.Element |
addHR(org.w3c.dom.Element parent)
Adds a <HR/> to the provided element. |
org.w3c.dom.Element |
addIMG(org.w3c.dom.Element parent,
java.lang.String src)
Adds a <IMG/> to the document body. |
org.w3c.dom.Element |
addIMG(org.w3c.dom.Element parent,
java.lang.String src,
java.lang.String border)
Adds a <IMG/> to the document body. |
org.w3c.dom.Element |
addMetaTag()
Adds a <META/> to the document head. |
org.w3c.dom.Element |
addMetaTag(java.lang.String name,
java.lang.String content)
Adds a <META/> to the document head.
|
void |
addMetaTagForNoCache()
Add the meta tags for no cache. |
org.w3c.dom.Element |
addTable(org.w3c.dom.Element parent)
Adds a <TABLE/> to the provided element. |
org.w3c.dom.Element |
addTable(org.w3c.dom.Element parent,
ClassAttribute classAttribute)
Add a table element. |
org.w3c.dom.Element |
addTD()
Adds a <TD/> to the document body. |
org.w3c.dom.Element |
addTD(org.w3c.dom.Element parent)
Adds a <TD/> to the provided element. |
org.w3c.dom.Element |
addTD(org.w3c.dom.Element parent,
ClassAttribute classAttribute)
Adds a <TD CLASS="[classAttribute]"/> to the provided element. |
org.w3c.dom.Element |
addTR()
Adds a <TR/> to the document body. |
org.w3c.dom.Element |
addTR(org.w3c.dom.Element parent)
Adds a <TR/> to the provided element. |
org.w3c.dom.Element |
createElement(java.lang.String name,
ClassAttribute classAttribute)
Create a new element. |
org.w3c.dom.Element |
getBodyElement()
Get the <body> element; |
org.w3c.dom.Element |
getHeadElement()
Get the <head> element; |
boolean |
getUseUpperCase()
Returns if all the HTML tags are to be in upper case or not. |
void |
setClass(org.w3c.dom.Element parent,
ClassAttribute classAttribute)
Set the class attribute for the element. |
void |
setDocument(java.io.File file)
|
void |
setDocument(java.net.URL url)
|
void |
setText(org.w3c.dom.Element parent,
java.lang.String text)
Set the text content for a give element. |
void |
setUseUpperCase(boolean upperCase)
Sets if all the HTML tags are to be in upper case or not. |
boolean |
toFile(java.io.File file)
Write the HTML to a file. |
java.lang.String |
toString()
Write the HTML to a string. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected org.w3c.dom.Document doc
protected org.w3c.dom.Element htmlNode
protected org.w3c.dom.Element headNode
protected org.w3c.dom.Element bodyNode
| Constructor Detail |
public HTMLGenerator()
public HTMLGenerator(java.io.File file)
throws java.io.IOException,
org.xml.sax.SAXException
file - The HTML document
java.io.IOException
org.xml.sax.SAXException
public HTMLGenerator(java.net.URL url)
throws java.io.IOException,
org.xml.sax.SAXException
url - The HTML document
java.io.IOException
org.xml.sax.SAXException| Method Detail |
public void setDocument(java.io.File file)
throws java.io.IOException,
org.xml.sax.SAXException
java.io.IOException
org.xml.sax.SAXException
public void setDocument(java.net.URL url)
throws java.io.IOException,
org.xml.sax.SAXException
java.io.IOException
org.xml.sax.SAXExceptionpublic boolean getUseUpperCase()
public void setUseUpperCase(boolean upperCase)
upperCase - true = upper case
public org.w3c.dom.Element addAnchor(org.w3c.dom.Element parent,
java.lang.String href,
java.lang.String text)
<A HREF="[href]">[text]</A>
parent - The parent elementhref - The urltext - The text to display
public org.w3c.dom.Element addBR()
<BR/> to the document body.
public org.w3c.dom.Element addBR(org.w3c.dom.Element parent)
<BR/> to the provided element.
parent - The parent element
public org.w3c.dom.Element addHR()
<HR/> to the document body.
public org.w3c.dom.Element addHR(org.w3c.dom.Element parent)
<HR/> to the provided element.
parent - The parent element
public org.w3c.dom.Element addIMG(org.w3c.dom.Element parent,
java.lang.String src)
<IMG/> to the document body.
parent - The parent elementsrc - The URL to the image
public org.w3c.dom.Element addIMG(org.w3c.dom.Element parent,
java.lang.String src,
java.lang.String border)
<IMG/> to the document body.
parent - The parent elementsrc - The URL to the imageborder - The of the image
public org.w3c.dom.Element addTD()
<TD/> to the document body.
public org.w3c.dom.Element addTD(org.w3c.dom.Element parent)
<TD/> to the provided element.
parent - The parent element
public org.w3c.dom.Element addTD(org.w3c.dom.Element parent,
ClassAttribute classAttribute)
<TD CLASS="[classAttribute]"/> to the provided element.
parent - The parent elementclassAttribute - the CLASS attribute
public org.w3c.dom.Element addTR()
<TR/> to the document body.
public org.w3c.dom.Element addTR(org.w3c.dom.Element parent)
<TR/> to the provided element.
parent - The parent element
public org.w3c.dom.Element addMetaTag()
<META/> to the document head.
public org.w3c.dom.Element addMetaTag(java.lang.String name,
java.lang.String content)
<META/> to the document head.
<META name="[name]" content="[content]">
name - The namecontent - The content
public void addMetaTagForNoCache()
<META Http-Equiv="Cache-Control" Content="no-cache"/>
<META Http-Equiv="Pragma" Content="no-cache"/>
<META Http-Equiv="Expires" Content="0"/>
public org.w3c.dom.Element addElementToBody(java.lang.String name)
name - The name of the element
public org.w3c.dom.Element addElementToBody(java.lang.String name,
ClassAttribute classAttribute)
name - The name of the elementclassAttribute - The CLASS attribute
public org.w3c.dom.Element addElement(org.w3c.dom.Element parent,
java.lang.String name)
parent - The parent elementname - The name of the element
public org.w3c.dom.Element addElement(org.w3c.dom.Element parent,
java.lang.String name,
java.lang.String text)
parent - The parent elementname - The name of the elementtext - The text content
public org.w3c.dom.Element addElement(org.w3c.dom.Element parent,
java.lang.String name,
ClassAttribute classAttribute)
parent - The parent elementname - The name of the elementclassAttribute - The CLASS attribute
public org.w3c.dom.Element addElement(org.w3c.dom.Element parent,
java.lang.String name,
ClassAttribute classAttribute,
java.lang.String text)
parent - The parent elementname - The name of the elementclassAttribute - The CLASS attributetext - The text content
public org.w3c.dom.Element addTable(org.w3c.dom.Element parent)
<TABLE/> to the provided element.
parent - The parent element
public org.w3c.dom.Element addTable(org.w3c.dom.Element parent,
ClassAttribute classAttribute)
<TABLE CLASS="[classAttribute]"/>
parent - The parent elementclassAttribute - The CLASS attribute
public org.w3c.dom.Element createElement(java.lang.String name,
ClassAttribute classAttribute)
<[name] CLASS="[classAttribute]"/>
name - The name of the elementclassAttribute - The class attribute
public org.w3c.dom.Element getBodyElement()
public org.w3c.dom.Element getHeadElement()
public void setClass(org.w3c.dom.Element parent,
ClassAttribute classAttribute)
<FOO CLASS="[classAttribute]"/>
parent - The elementclassAttribute - The class attribute
public void setText(org.w3c.dom.Element parent,
java.lang.String text)
<FOO>[text]</FOO>
parent - The elementtext - The text to setpublic java.lang.String toString()
public boolean toFile(java.io.File file)
file - The output file
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||