org.jppf.ui.options.xml
Class OptionDescriptorParser

java.lang.Object
  extended by org.jppf.ui.options.xml.OptionDescriptorParser

public class OptionDescriptorParser
extends Object

Instances of this class are used to parse an XML document, describing an options page, into a tree of option descriptors.

Author:
Laurent Cohen

Constructor Summary
OptionDescriptorParser()
          Initialize this parser.
 
Method Summary
 void addProperty(OptionDescriptor desc, Node node)
          Add a property to an option descriptor from a DOM node.
 OptionDescriptor.ItemDescriptor createItemDescriptor(Node node)
          Create an item descriptor from a DOM node.
 OptionDescriptor.ListenerDescriptor createListenerDescriptor(Node node)
          Create a listener descriptor from a DOM node.
 OptionDescriptor.ScriptDescriptor createScriptDescriptor(Node node)
          Create a script descriptor from a DOM node.
 Node findFirstElement(Document doc)
          Find the first node in a docuemnt that is an element node.
 OptionDescriptor generateTree(Node node)
          Generate an OptionDescriptor tree from a DOM subtree.
 String getTextNodeValue(Node node)
          Get the value of a node's text subelement.
 OptionDescriptor loadImport(Node node)
          Import an external XML descriptor.
 OptionDescriptor parse(Reader reader)
          Parse an XML document in a reader into a tree of option descriptors.
 OptionDescriptor parse(String docPath)
          Parse an XML document in a file into a tree of option descriptors.
 void setListenerAttributes(Node node, OptionDescriptor.ListenerDescriptor desc)
          Set the attributes of a listener descriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionDescriptorParser

public OptionDescriptorParser()
                       throws Exception
Initialize this parser.

Throws:
Exception - if the DOM parser could not be initialized.
Method Detail

parse

public OptionDescriptor parse(String docPath)
                       throws Exception
Parse an XML document in a file into a tree of option descriptors.

Parameters:
docPath - the path to XML document to parse.
Returns:
an OptionDescriptor instance, root of the generated tree, or null if the docuement could not be parsed.
Throws:
Exception - if an error occurs while parsing the document.

parse

public OptionDescriptor parse(Reader reader)
                       throws Exception
Parse an XML document in a reader into a tree of option descriptors.

Parameters:
reader - the reader providing the XML document.
Returns:
an OptionDescriptor instance, root of the generated tree, or null if the docuement could not be parsed.
Throws:
Exception - if an error occurs while parsing the document.

findFirstElement

public Node findFirstElement(Document doc)
Find the first node in a docuemnt that is an element node.

Parameters:
doc - the document whose children are looked up.
Returns:
a Node instance if one was found, or null otherwise.

generateTree

public OptionDescriptor generateTree(Node node)
Generate an OptionDescriptor tree from a DOM subtree.

Parameters:
node - the document to generate the tree from.
Returns:
an OptionDescriptor instance, root of the generated tree, or null if the docuement could not be parsed.

createItemDescriptor

public OptionDescriptor.ItemDescriptor createItemDescriptor(Node node)
Create an item descriptor from a DOM node.

Parameters:
node - the node to generate the listener from.
Returns:
a ItemDescriptor instance.

createListenerDescriptor

public OptionDescriptor.ListenerDescriptor createListenerDescriptor(Node node)
Create a listener descriptor from a DOM node.

Parameters:
node - the node to generate the listener from.
Returns:
a ListenerDescriptor instance.

setListenerAttributes

public void setListenerAttributes(Node node,
                                  OptionDescriptor.ListenerDescriptor desc)
Set the attributes of a listener descriptor.

Parameters:
node - the parent listener node.
desc - the listener descriptor whose attributeshave to be set.

getTextNodeValue

public String getTextNodeValue(Node node)
Get the value of a node's text subelement.

Parameters:
node - the node to generate whosde child is a text node.
Returns:
the text as a string.

createScriptDescriptor

public OptionDescriptor.ScriptDescriptor createScriptDescriptor(Node node)
Create a script descriptor from a DOM node.

Parameters:
node - the node to generate the listener from.
Returns:
a ScriptDescriptor instance.

addProperty

public void addProperty(OptionDescriptor desc,
                        Node node)
Add a property to an option descriptor from a DOM node.

Parameters:
desc - the option descriptor to add the property to.
node - the node to get the property name and value from.

loadImport

public OptionDescriptor loadImport(Node node)
Import an external XML descriptor.

Parameters:
node - the node to get the import description from.
Returns:
a OptionDescriptor instance.


Copyright © 2005-2010 JPPF Team.