org.infoglue.cms.util.dom
Class DOMBuilder

java.lang.Object
  extended by org.infoglue.cms.util.dom.DOMBuilder

public class DOMBuilder
extends java.lang.Object

This class is a utility-class for handling DOM-objects.

Author:
Mattias Bogeblad

Constructor Summary
DOMBuilder()
           
 
Method Summary
 void addAttribute(org.dom4j.Element element, java.lang.String attributeName, java.lang.String attributeValue)
          This method adds an attribute with a given name and value to a given element.
 org.dom4j.Element addCDATAElement(org.dom4j.Element element, java.lang.String text)
          This method adds a cdata-element with a given name to a given parent element.
 org.dom4j.Element addElement(org.dom4j.Document document, java.lang.String elementName)
          This method adds an element with a given name to a given document.
 org.dom4j.Element addElement(org.dom4j.Element element, java.lang.String elementName)
          This method adds an element with a given name to a given parent element.
 org.dom4j.Element addTextElement(org.dom4j.Element element, java.lang.String text)
          This method adds a text-element with a given name to a given parent element.
 org.dom4j.Document buildDocment(org.w3c.dom.Document domDocument)
          converts a W3C DOM document into a dom4j document
 org.dom4j.Document createDocument()
          This method creates a new Document.
 java.lang.String encodeString(java.lang.String value, java.lang.String encoding)
           
 org.dom4j.Document getDocument(java.io.File file)
          This method creates a new Document from a file.
 org.dom4j.Document getDocument(java.lang.String xml)
          This method creates a new Document from an xml-string.
 void insertElement(org.dom4j.Element element, org.dom4j.Element childElement)
          This method adds an element to a given parent element.
 org.dom4j.Node selectSingleNode(org.dom4j.Node contextNode, java.lang.String xpathExpression, java.lang.String namespaceName, java.lang.String namespaceValue)
          A helper method to get nodes that has a namespace.
 void write(org.dom4j.Document document, java.lang.String fileName)
          This method writes a document to file.
 void writeDebug(org.dom4j.Document document)
          This method writes a document to System.out.
 void writeDebug(org.dom4j.Element element)
          This method writes a element to System.out.
 void writePretty(org.dom4j.Document document, java.lang.String fileName)
          This method writes a document to file nicely.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMBuilder

public DOMBuilder()
Method Detail

createDocument

public org.dom4j.Document createDocument()
This method creates a new Document.


getDocument

public org.dom4j.Document getDocument(java.lang.String xml)
                               throws java.lang.Exception
This method creates a new Document from an xml-string.

Throws:
java.lang.Exception

buildDocment

public org.dom4j.Document buildDocment(org.w3c.dom.Document domDocument)
converts a W3C DOM document into a dom4j document


getDocument

public org.dom4j.Document getDocument(java.io.File file)
                               throws java.lang.Exception
This method creates a new Document from a file.

Throws:
java.lang.Exception

selectSingleNode

public org.dom4j.Node selectSingleNode(org.dom4j.Node contextNode,
                                       java.lang.String xpathExpression,
                                       java.lang.String namespaceName,
                                       java.lang.String namespaceValue)
A helper method to get nodes that has a namespace.


addElement

public org.dom4j.Element addElement(org.dom4j.Document document,
                                    java.lang.String elementName)
This method adds an element with a given name to a given document.


addElement

public org.dom4j.Element addElement(org.dom4j.Element element,
                                    java.lang.String elementName)
This method adds an element with a given name to a given parent element.


insertElement

public void insertElement(org.dom4j.Element element,
                          org.dom4j.Element childElement)
This method adds an element to a given parent element.


addTextElement

public org.dom4j.Element addTextElement(org.dom4j.Element element,
                                        java.lang.String text)
This method adds a text-element with a given name to a given parent element.


addCDATAElement

public org.dom4j.Element addCDATAElement(org.dom4j.Element element,
                                         java.lang.String text)
This method adds a cdata-element with a given name to a given parent element.


addAttribute

public void addAttribute(org.dom4j.Element element,
                         java.lang.String attributeName,
                         java.lang.String attributeValue)
This method adds an attribute with a given name and value to a given element.


write

public void write(org.dom4j.Document document,
                  java.lang.String fileName)
           throws java.lang.Exception
This method writes a document to file.

Throws:
java.lang.Exception

writePretty

public void writePretty(org.dom4j.Document document,
                        java.lang.String fileName)
                 throws java.io.IOException
This method writes a document to file nicely.

Throws:
java.io.IOException

writeDebug

public void writeDebug(org.dom4j.Document document)
                throws java.lang.Exception
This method writes a document to System.out.

Throws:
java.lang.Exception

encodeString

public java.lang.String encodeString(java.lang.String value,
                                     java.lang.String encoding)
                              throws java.lang.Exception
Throws:
java.lang.Exception

writeDebug

public void writeDebug(org.dom4j.Element element)
                throws java.lang.Exception
This method writes a element to System.out.

Throws:
java.lang.Exception


Copyright © 2005 InfoGlue.org All Rights Reserved.