Package org.jppf.ui.options.xml
Class OptionDescriptorParser
java.lang.Object
org.jppf.ui.options.xml.OptionDescriptorParser
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProperty(OptionDescriptor desc, Node node) Add a property to an option descriptor from a DOM node.createItemDescriptor(Node node) Create an item descriptor from a DOM node.createListenerDescriptor(Node node) Create a listener descriptor from a DOM node.createScriptDescriptor(Node node) Create a script descriptor from a DOM node.findFirstElement(Document doc) Find the first node in a document that is an element node.generateTree(Node node) Generate anOptionDescriptortree from a DOM subtree.getTextNodeValue(Node node) Get the value of a node's text subelement.loadImport(Node node) Import an external XML descriptor.Parse an XML document in a reader into a tree of option descriptors.Parse an XML document in a file into a tree of option descriptors.voidSet the attributes of a listener descriptor.
-
Constructor Details
-
OptionDescriptorParser
Initialize this parser.- Throws:
Exception- if the DOM parser could not be initialized.
-
-
Method Details
-
parse
Parse an XML document in a file into a tree of option descriptors.- Parameters:
docPath- the path to XML document to parse.- Returns:
- an
OptionDescriptorinstance, root of the generated tree, or null if the document could not be parsed. - Throws:
Exception- if an error occurs while parsing the document.
-
parse
Parse an XML document in a reader into a tree of option descriptors.- Parameters:
reader- the reader providing the XML document.- Returns:
- an
OptionDescriptorinstance, root of the generated tree, or null if the document could not be parsed. - Throws:
Exception- if an error occurs while parsing the document.
-
findFirstElement
Find the first node in a document that is an element node.- Parameters:
doc- the document whose children are looked up.- Returns:
- a
Nodeinstance if one was found, or null otherwise.
-
generateTree
Generate anOptionDescriptortree from a DOM subtree.- Parameters:
node- the document to generate the tree from.- Returns:
- an
OptionDescriptorinstance, root of the generated tree, or null if the document could not be parsed.
-
createItemDescriptor
Create an item descriptor from a DOM node.- Parameters:
node- the node to generate the listener from.- Returns:
- a
ItemDescriptorinstance.
-
createListenerDescriptor
Create a listener descriptor from a DOM node.- Parameters:
node- the node to generate the listener from.- Returns:
- a
ListenerDescriptorinstance.
-
setListenerAttributes
Set the attributes of a listener descriptor.- Parameters:
node- the parent listener node.desc- the listener descriptor whose attributes have to be set.
-
getTextNodeValue
Get the value of a node's text subelement.- Parameters:
node- the node to generate whose child is a text node.- Returns:
- the text as a string.
-
createScriptDescriptor
Create a script descriptor from a DOM node.- Parameters:
node- the node to generate the listener from.- Returns:
- a
ScriptDescriptorinstance.
-
addProperty
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
Import an external XML descriptor.- Parameters:
node- the node to get the import description from.- Returns:
- a
OptionDescriptorinstance.
-