com.theloutons.search.utils
Class XHTMLviaDOM

java.lang.Object
  extended bycom.theloutons.search.utils.XHTMLviaDOM

public class XHTMLviaDOM
extends java.lang.Object

Author:
Tom Louton

This class has the object of creating an empty XHTML DOM object and then has methods to add tags of various sorts. There is a method to write it to a file. It can be instantiated via file (a sort of template) or string (name of a file) or null and then it starts from scratch.


Constructor Summary
XHTMLviaDOM()
          just creates an empty structured XHTM file
XHTMLviaDOM(java.io.File f)
          this reads in
XHTMLviaDOM(java.lang.String fName)
           
 
Method Summary
 org.w3c.dom.Node addAttribs(org.w3c.dom.Node nd, java.util.Properties attribs)
           
 void addForm(java.util.Properties attribs, java.lang.String url)
          /* sets up a form, needed to get info back to the servlet
 org.w3c.dom.Node addInputButton(org.w3c.dom.Node nd, java.lang.String name, java.lang.String value, java.util.Properties attribs)
          Adds an inputbutton to the document where one wishes.
 org.w3c.dom.Node addInputCkBox(org.w3c.dom.Node nd, java.lang.String name, java.lang.String value, java.util.Properties attribs, boolean cked)
          This adds an check box to the nd (if nd null, to the form) tag and gives it some standard attributes needed.
 org.w3c.dom.Node addInputPassWd(org.w3c.dom.Node nd, java.lang.String name, java.util.Properties attribs)
          this adds an input to the nd (if nd null, to the form) tag and gives it some standard attributes needed.
 org.w3c.dom.Node addInputRadio(org.w3c.dom.Node nd, java.lang.String name, java.lang.String value, java.util.Properties attribs, boolean cked)
          This adds an input to the nd (if nd null, to the form) tag and gives it some standard attributes needed.
 org.w3c.dom.Node addInputReset(org.w3c.dom.Node nd, java.lang.String name, java.lang.String value, java.util.Properties attribs)
          This adds a reset button to the nd (if nd null, to the form) tag and gives it some standard attributes needed.
 org.w3c.dom.Node addInputSubmit(org.w3c.dom.Node nd, java.lang.String name, java.lang.String value, java.util.Properties attribs)
          This adds a submitt button
 org.w3c.dom.Node addInputText(org.w3c.dom.Node nd, java.lang.String name, java.lang.String value, java.util.Properties attribs)
          Adds a general text entry field to the node nd (or form if nd is null)
 org.w3c.dom.Node addKnot(org.w3c.dom.Node nd, java.lang.String nodeName, java.util.Properties attribs, java.lang.String contents)
          /* adds a node to the dom.
 boolean addMeta(java.util.Properties meta)
          it is the resposibility of the user to get the properties correctly.
 void addStyles(java.lang.String isEverything)
          adds styles to the css
 void addStylesComment(java.lang.String isEverything)
          This just adds a comment to the styles tage
 org.w3c.dom.Node getBody()
          gets the body node (body tag)
 org.w3c.dom.Node getForm()
           
 boolean writeDOMtoFile(java.lang.String fName)
          The method writes the xhtml document to a file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XHTMLviaDOM

public XHTMLviaDOM()
just creates an empty structured XHTM file


XHTMLviaDOM

public XHTMLviaDOM(java.io.File f)
this reads in

Parameters:
f - is the name of the file to be read in. If it does not exist or cannot be read an empty dom is created.

XHTMLviaDOM

public XHTMLviaDOM(java.lang.String fName)
Parameters:
fName - the name of the file to be read in as template
Method Detail

addKnot

public org.w3c.dom.Node addKnot(org.w3c.dom.Node nd,
                                java.lang.String nodeName,
                                java.util.Properties attribs,
                                java.lang.String contents)
/* adds a node to the dom.

Parameters:
nd - is the node into which this will be written
nodeName - the name of the new node String
attribs - Java Properties contaings the atributes. The attribute name is the name of the property and the value is the value of the key.
contents - String, the value of the node.
Returns:
the new node which was added to nd added.

addAttribs

public org.w3c.dom.Node addAttribs(org.w3c.dom.Node nd,
                                   java.util.Properties attribs)

addStylesComment

public void addStylesComment(java.lang.String isEverything)
This just adds a comment to the styles tage

Parameters:
isEverything - the contents of the comment

addStyles

public void addStyles(java.lang.String isEverything)
adds styles to the css

Parameters:
isEverything - A String the styles to append CSS

addMeta

public boolean addMeta(java.util.Properties meta)
it is the resposibility of the user to get the properties correctly.

Parameters:
meta - is a properties contianing name and content of the meta data
Returns:
true if it worked.

addForm

public void addForm(java.util.Properties attribs,
                    java.lang.String url)
/* sets up a form, needed to get info back to the servlet

Parameters:
attribs - a set of attribs for the form
url - the address to be returned by the do get/put HTTP protocol

addInputText

public org.w3c.dom.Node addInputText(org.w3c.dom.Node nd,
                                     java.lang.String name,
                                     java.lang.String value,
                                     java.util.Properties attribs)
Adds a general text entry field to the node nd (or form if nd is null)

Parameters:
nd - the node in which to put the input
name - the name of the text node
value - the node value
attribs - list of attribs as a Java properties
Returns:
the new node which was added.

addInputPassWd

public org.w3c.dom.Node addInputPassWd(org.w3c.dom.Node nd,
                                       java.lang.String name,
                                       java.util.Properties attribs)
this adds an input to the nd (if nd null, to the form) tag and gives it some standard attributes needed. @param nd the node to which to add the password input @param the name of the input @param value the value @param attibs any extra attibutes needed

Parameters:
nd - the node to which it is written
name - the name of the new node
attribs - attributes as Java Properties
Returns:
the new node which was added

addInputRadio

public org.w3c.dom.Node addInputRadio(org.w3c.dom.Node nd,
                                      java.lang.String name,
                                      java.lang.String value,
                                      java.util.Properties attribs,
                                      boolean cked)
This adds an input to the nd (if nd null, to the form) tag and gives it some standard attributes needed.

Parameters:
nd - the node to which to add the radio button
name - the name of the button
value - the value value field
attribs - Java attribs containing attributes for the button
cked - true if the button is to be checked. If on has more than one button marked as checked, then the first is.
Returns:
the new node.

addInputCkBox

public org.w3c.dom.Node addInputCkBox(org.w3c.dom.Node nd,
                                      java.lang.String name,
                                      java.lang.String value,
                                      java.util.Properties attribs,
                                      boolean cked)
This adds an check box to the nd (if nd null, to the form) tag and gives it some standard attributes needed.

Parameters:
nd - the node to which to add the check box
name - the name of the check box
value - the value for the value attribute
attribs - extra attribues (as Java Properties)
cked - true if to be checked.
Returns:
the new node, the check box

addInputReset

public org.w3c.dom.Node addInputReset(org.w3c.dom.Node nd,
                                      java.lang.String name,
                                      java.lang.String value,
                                      java.util.Properties attribs)
This adds a reset button to the nd (if nd null, to the form) tag and gives it some standard attributes needed.

Parameters:
nd - the node to which to add the reset button or the if null the form
name - the name of the reset button
value - the string value for the value attribute
attribs - extra attributes for this button
Returns:
the new node

addInputSubmit

public org.w3c.dom.Node addInputSubmit(org.w3c.dom.Node nd,
                                       java.lang.String name,
                                       java.lang.String value,
                                       java.util.Properties attribs)
This adds a submitt button

Parameters:
nd - the node to which to add the button (usuall in a form)
name - the String containing the name of the button
value - value for the value attribute.
attribs - extra attributes as Java Properties.
Returns:
the new node

addInputButton

public org.w3c.dom.Node addInputButton(org.w3c.dom.Node nd,
                                       java.lang.String name,
                                       java.lang.String value,
                                       java.util.Properties attribs)
Adds an inputbutton to the document where one wishes. Usually in the form if not node is given, then just in the form

Parameters:
nd - the node to which the button is to be added.
name - the name of the button (String)
value - the value of the value attribute
attribs - extra attributes (Java Properties)
Returns:
the new node

getBody

public org.w3c.dom.Node getBody()
gets the body node (body tag)

Returns:
the body node (body tag)

getForm

public org.w3c.dom.Node getForm()
Returns:
the form node (form tag, I assume only one in the document)

writeDOMtoFile

public boolean writeDOMtoFile(java.lang.String fName)
The method writes the xhtml document to a file. Must get a stream writer too.

Parameters:
fName - the name of the file to be written
Returns:
successful or not