wox.serial
Class XMLUtil

java.lang.Object
  extended by wox.serial.XMLUtil
All Implemented Interfaces:
Serial

public class XMLUtil
extends java.lang.Object
implements Serial

The XMLUtil class provides static methods that are used by SimpleReader and SimpleWriter. The methods of this class are used by the serialization and de-serialization processes.

Version:
XMLUtil.java - 1.0
Author:
Carlos R. Jaimez Gonzalez
Simon M. Lucas

Field Summary
 
Fields inherited from interface wox.serial.Serial
ARRAY, ARRAYLIST, DECLARED, ELEMENT_TYPE, ENTRY, FIELD, ID, IDREF, KEY, KEY_TYPE, LENGTH, MAP, NAME, OBJECT, primitiveArrays, primitiveArraysWOX, primitives, primitiveWrappers, TYPE, VALUE, VALUE_TYPE
 
Constructor Summary
XMLUtil()
           
 
Method Summary
static java.lang.String convertXmlToString(java.lang.String xmlFileName)
          This method reads an XML file and returns its contents as String.
static boolean createFile(org.jdom.Element element, java.io.File filename)
          This method creates an XML file, and puts the JDOM Element as its contents.
static void disElement(org.jdom.Element element)
          This method displays the XML representation of the JDOM Element (object) passed as parameter.
static void disElement(java.lang.Object object)
          This method displays the XML representation of the object passed as parameter.
static java.lang.String element2BrowserString(org.jdom.Element element)
          This method takes a JDOM Element and returns its string representation in XML ready to be presented in a browser The method replaces the characters '<' and '>' by '<' and '>' respectively.
static java.lang.String element2String(org.jdom.Element element)
          This method takes a JDOM Element object and returns its string representation.
static java.lang.String generateRandomNo()
          It generates a random number and returns it as string.
static java.lang.String getXmlElementAsString(org.jdom.Element xmlElement)
          This method converts a JDOM Element to a String in XML.
static org.jdom.Element xmlToElement(java.lang.String xmlPath)
          This method converts an XML file into a JDOM Element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtil

public XMLUtil()
Method Detail

disElement

public static void disElement(java.lang.Object object)
                       throws java.lang.Exception
This method displays the XML representation of the object passed as parameter. The XML representation is based on the WOX standard.

Parameters:
object - The object to be displayed.
Throws:
java.lang.Exception - If there is a problem displaying the object.

disElement

public static void disElement(org.jdom.Element element)
                       throws java.lang.Exception
This method displays the XML representation of the JDOM Element (object) passed as parameter. The XML representation is based on the WOX standard.

Parameters:
element - The JDOM element (object) to be displayed
Throws:
java.lang.Exception - If there is a problem displaying the object.

element2String

public static java.lang.String element2String(org.jdom.Element element)
                                       throws java.lang.Exception
This method takes a JDOM Element object and returns its string representation.

Parameters:
element - The JDOM object.
Throws:
java.lang.Exception - If there is a problem. Author: Carlos Roberto Jaimez Gonzalez 3rd May 2005

element2BrowserString

public static java.lang.String element2BrowserString(org.jdom.Element element)
                                              throws java.lang.Exception
This method takes a JDOM Element and returns its string representation in XML ready to be presented in a browser The method replaces the characters '<' and '>' by '<' and '>' respectively.

Parameters:
element - The JDOM Element to be displayed.
Returns:
The string representation in XML.
Throws:
java.lang.Exception - If there is a problem.

xmlToElement

public static org.jdom.Element xmlToElement(java.lang.String xmlPath)
                                     throws java.lang.Exception
This method converts an XML file into a JDOM Element. The path of the XML file must be provided.

Parameters:
xmlPath - The path of the XML file to be converted.
Returns:
A JDOM element.
Throws:
java.lang.Exception - If there is a problem.

createFile

public static boolean createFile(org.jdom.Element element,
                                 java.io.File filename)
This method creates an XML file, and puts the JDOM Element as its contents.

Parameters:
element - The JDOM Element to be stored.
filename - The file to be created.
Returns:
True if the creation was successfull. False otherwise.

generateRandomNo

public static java.lang.String generateRandomNo()
It generates a random number and returns it as string. This is normally used to be concatenated with the XML filename.

Returns:
A random number.

convertXmlToString

public static java.lang.String convertXmlToString(java.lang.String xmlFileName)
                                           throws java.lang.Exception
This method reads an XML file and returns its contents as String.

Parameters:
xmlFileName - The name (path) of the XML file.
Returns:
The string (XML) representation of the XML file.
Throws:
java.lang.Exception - If there is a problem.

getXmlElementAsString

public static java.lang.String getXmlElementAsString(org.jdom.Element xmlElement)
This method converts a JDOM Element to a String in XML.

Parameters:
xmlElement - The JDOM Element to be converted.
Returns:
The string representation of the JDOM Element (in XML).