Java Doc for DOMUtil.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » xml » dom » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » apache lenya 2.0 » org.apache.cocoon.xml.dom 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.cocoon.xml.dom.DOMUtil

DOMUtil
final public class DOMUtil (Code)
This class is a utility class for miscellaneous DOM functions, like getting and setting values of nodes.
author:
   Carsten Ziegeler
version:
   $Id: DOMUtil.java 433543 2006-08-22 06:22:54Z crossley $




Method Summary
public static  String[]buildPathArray(String xpath)
     Build the input for the get...FromPath methods.
public static  booleancompareAttributes(Element first, Element second)
     Compare all attributes of two elements.
public static  DocumentcreateDocument()
     Create a new empty DOM document.
public static  SourceParameterscreateParameters(Node fragment, SourceParameters source)
     Create a parameter object from xml.
public static  StringcreateText(DocumentFragment fragment)
     Create a string from a DOM document fragment.
public static  DocumentFragmentgetDocumentFragment(SAXParser parser, Reader stream)
     Get a document fragment from a Reader.
public static  NodegetFirstNodeFromPath(Node contextNode, String[] path, boolean create)
     Use a path to select the first occurence of a node.
public static  NodeListgetNodeListFromPath(Node contextNode, String[] path)
     Use a path to select all occurences of a node.
public static  DocumentgetOwnerDocument(Node node)
     Get the owner of the DOM document belonging to the node.
public static  NodegetSingleNode(Node contextNode, String str, XPathProcessor processor)
     Use an XPath string to select a single node.
public static  NodegetSingleNode(Node contextNode, String str)
     Use an XPath string to select a single node.
public static  booleangetValueAsBooleanOf(Node root, String path)
     Get the boolean value of the node specified by the XPath.
public static  booleangetValueAsBooleanOf(Node root, String path, XPathProcessor processor)
     Get the boolean value of the node specified by the XPath.
public static  booleangetValueAsBooleanOf(Node root, String path, boolean defaultValue)
     Get the boolean value of the node specified by the XPath.
public static  booleangetValueAsBooleanOf(Node root, String path, boolean defaultValue, XPathProcessor processor)
     Get the boolean value of the node specified by the XPath.
public static  StringgetValueOf(Node root, String path)
     Get the value of the node specified by the XPath.
public static  StringgetValueOf(Node root, String path, XPathProcessor processor)
     Get the value of the node specified by the XPath.
public static  StringgetValueOf(Node root, String path, String defaultValue)
     Get the value of the node specified by the XPath.
public static  StringgetValueOf(Node root, String path, String defaultValue, XPathProcessor processor)
     Get the value of the node specified by the XPath.
public static  StringgetValueOfNode(XPathProcessor processor, Node root, String path)
     Get the value of the node specified by the XPath.
public static  StringgetValueOfNode(XPathProcessor processor, Node root, String path, String defaultValue)
     Get the value of the node specified by the XPath.
public static  StringgetValueOfNode(Node node)
     Get the value of the DOM node.
public static  StringgetValueOfNode(Node node, String defaultValue)
     Get the value of the node.
public static  booleangetValueOfNodeAsBoolean(XPathProcessor processor, Node root, String path)
     Get the boolean value of the node specified by the XPath.
public static  booleangetValueOfNodeAsBoolean(XPathProcessor processor, Node root, String path, boolean defaultValue)
     Get the boolean value of the node specified by the XPath.
public static  Stringnode2String(Node node)
     Converts a org.w3c.dom.Node to a String.
public static  Stringnode2String(Node node, boolean pretty)
     Create a string representation of a org.w3c.dom.Node and any (most) subtypes.
public static  StringBuffernode2StringBuffer(Node node)
     Create a string representation of a org.w3c.dom.Node and any (most) subtypes.
public static  StringBuffernode2StringBuffer(Node node, boolean pretty, String indent)
     Create a string representation of a org.w3c.dom.Node and any (most) subtypes.
Parameters:
  node - a org.w3c.dom.Node value
Parameters:
  pretty - a boolean value whether to format the XML
Parameters:
  indent - a String value containing spaces as initialindent, if null defaults to empty string.
public static  NodeListselectNodeList(Node contextNode, String str)
     Use an XPath string to select a nodelist.
public static  NodeListselectNodeList(Node contextNode, String str, XPathProcessor processor)
     Use an XPath string to select a nodelist.
public static  NodeselectSingleNode(Node rootNode, String path)
     Return the Node from the DOM Node rootNode using the XPath expression path.
public static  NodeselectSingleNode(Node rootNode, String path, XPathProcessor processor)
     Return the Node from the DOM Node rootNode using the XPath expression path.
public static  voidsetValueOfNode(Node node, String value)
     Set the value of the DOM node.
public static  voidvalueOf(Node parent, String text)
     Implementation for String : outputs characters representing the value.
public static  voidvalueOf(Node parent, XMLizable v)
     Implementation for XMLizable : outputs the value by calling v.toSax(contentHandler).
public static  voidvalueOf(Node parent, Node v)
     Implementation for org.w3c.dom.Node : converts the Node to a SAX event stream.
public static  voidvalueOf(Node parent, Collection v)
     Implementation for java.util.Collection : outputs the value by calling DOMUtil.valueOf(Node,Object) on each element of the collection.
public static  voidvalueOf(Node parent, Map v)
     Implementation for java.util.Map : For each entry an element is created with the childs key and value Outputs the value and the key by calling DOMUtil.valueOf(Node,Object) on each value and key of the Map.
public static  voidvalueOf(Node parent, Object v)
    



Method Detail
buildPathArray
public static String[] buildPathArray(String xpath)(Code)
Build the input for the get...FromPath methods. If the XPath expression cannot be handled by the methods, null is returned.



compareAttributes
public static boolean compareAttributes(Element first, Element second)(Code)
Compare all attributes of two elements. This method returns true only if both nodes have the same number of attributes and the same attributes with equal values. Namespace definition nodes are ignored



createDocument
public static Document createDocument() throws ProcessingException(Code)
Create a new empty DOM document.



createParameters
public static SourceParameters createParameters(Node fragment, SourceParameters source)(Code)
Create a parameter object from xml. The xml is flat and consists of elements which all have exactly one text node: value_one value_two A parameter can occur more than once with different values. If source is not specified a new parameter object is created otherwise the parameters are added to source.



createText
public static String createText(DocumentFragment fragment)(Code)
Create a string from a DOM document fragment. Only the top level text nodes are chained together to build the text.



getDocumentFragment
public static DocumentFragment getDocumentFragment(SAXParser parser, Reader stream) throws ProcessingException(Code)
Get a document fragment from a Reader. The reader must provide valid XML, but it is allowed that the XML has more than one root node. This xml is parsed by the specified parser instance and a DOM DocumentFragment is created.



getFirstNodeFromPath
public static Node getFirstNodeFromPath(Node contextNode, String[] path, boolean create)(Code)
Use a path to select the first occurence of a node. The namespace of a node is ignored!
Parameters:
  contextNode - The node starting the search.
Parameters:
  path - The path to search the node. The contextNode is searched for achild named path[0], this node is searched for a child namedpath[1]...
Parameters:
  create - If a child with the corresponding name is not found and createis set, this node will be created.



getNodeListFromPath
public static NodeList getNodeListFromPath(Node contextNode, String[] path)(Code)
Use a path to select all occurences of a node. The namespace of a node is ignored!
Parameters:
  contextNode - The node starting the search.
Parameters:
  path - The path to search the node. The contextNode is searched for achild named path[0], this node is searched for a child namedpath[1]...



getOwnerDocument
public static Document getOwnerDocument(Node node)(Code)
Get the owner of the DOM document belonging to the node. This works even if the node is the document itself.
Parameters:
  node - The node. The corresponding document.



getSingleNode
public static Node getSingleNode(Node contextNode, String str, XPathProcessor processor) throws TransformerException(Code)
Use an XPath string to select a single node. XPath namespace prefixes are resolved from the context node, which may not be what you want (see the next method).
Parameters:
  contextNode - The node to start searching from.
Parameters:
  str - A valid XPath string.
Parameters:
  processor - The XPath processor to use The first node found that matches the XPath, or null.
throws:
  TransformerException -



getSingleNode
public static Node getSingleNode(Node contextNode, String str) throws TransformerException(Code)
Use an XPath string to select a single node. XPath namespace prefixes are resolved from the context node, which may not be what you want (see the next method).
Parameters:
  contextNode - The node to start searching from.
Parameters:
  str - A valid XPath string. The first node found that matches the XPath, or null.
throws:
  TransformerException - To be removed in 2.2.



getValueAsBooleanOf
public static boolean getValueAsBooleanOf(Node root, String path) throws ProcessingException(Code)
Get the boolean value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node exists and has a value this value is converted to a boolean, e.g. "true" or "false" as value will result into the corresponding boolean values.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression. The boolean value of the node.
throws:
  ProcessingException - If the node is not found.



getValueAsBooleanOf
public static boolean getValueAsBooleanOf(Node root, String path, XPathProcessor processor) throws ProcessingException(Code)
Get the boolean value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node exists and has a value this value is converted to a boolean, e.g. "true" or "false" as value will result into the corresponding boolean values.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression.
Parameters:
  processor - The XPath Processor The boolean value of the node.
throws:
  ProcessingException - If the node is not found.



getValueAsBooleanOf
public static boolean getValueAsBooleanOf(Node root, String path, boolean defaultValue) throws ProcessingException(Code)
Get the boolean value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node exists and has a value this value is converted to a boolean, e.g. "true" or "false" as value will result into the corresponding boolean values. If the node does not exist, the defaultValue is returned.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression.
Parameters:
  defaultValue - Default boolean value. The value of the node or defaultValue



getValueAsBooleanOf
public static boolean getValueAsBooleanOf(Node root, String path, boolean defaultValue, XPathProcessor processor) throws ProcessingException(Code)
Get the boolean value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node exists and has a value this value is converted to a boolean, e.g. "true" or "false" as value will result into the corresponding boolean values. If the node does not exist, the defaultValue is returned.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression.
Parameters:
  defaultValue - Default boolean value.
Parameters:
  processor - The XPath Processor The value of the node or defaultValue



getValueOf
public static String getValueOf(Node root, String path) throws ProcessingException(Code)
Get the value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node does not exist null is returned.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression. The value of the node or null



getValueOf
public static String getValueOf(Node root, String path, XPathProcessor processor) throws ProcessingException(Code)
Get the value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node does not exist null is returned.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression.
Parameters:
  processor - The XPath processor to use The value of the node or null



getValueOf
public static String getValueOf(Node root, String path, String defaultValue) throws ProcessingException(Code)
Get the value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node is not found the defaultValue is returned.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression.
Parameters:
  defaultValue - The default value if the node does not exist. The value of the node or defaultValue



getValueOf
public static String getValueOf(Node root, String path, String defaultValue, XPathProcessor processor) throws ProcessingException(Code)
Get the value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node is not found the defaultValue is returned.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression.
Parameters:
  defaultValue - The default value if the node does not exist.
Parameters:
  processor - The XPath Processor The value of the node or defaultValue



getValueOfNode
public static String getValueOfNode(XPathProcessor processor, Node root, String path) throws ProcessingException(Code)
Get the value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node does not exist null is returned.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression. The value of the node or null



getValueOfNode
public static String getValueOfNode(XPathProcessor processor, Node root, String path, String defaultValue) throws ProcessingException(Code)
Get the value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node is not found the defaultValue is returned.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression.
Parameters:
  defaultValue - The default value if the node does not exist. The value of the node or defaultValue



getValueOfNode
public static String getValueOfNode(Node node)(Code)
Get the value of the DOM node. The value of a node is the content of the first text node. If the node has no text nodes, null is returned.



getValueOfNode
public static String getValueOfNode(Node node, String defaultValue)(Code)
Get the value of the node. The value of the node is the content of the first text node. If the node has no text nodes the defaultValue is returned.



getValueOfNodeAsBoolean
public static boolean getValueOfNodeAsBoolean(XPathProcessor processor, Node root, String path) throws ProcessingException(Code)
Get the boolean value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node exists and has a value this value is converted to a boolean, e.g. "true" or "false" as value will result into the corresponding boolean values.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression. The boolean value of the node.
throws:
  ProcessingException - If the node is not found.



getValueOfNodeAsBoolean
public static boolean getValueOfNodeAsBoolean(XPathProcessor processor, Node root, String path, boolean defaultValue) throws ProcessingException(Code)
Get the boolean value of the node specified by the XPath. This works similar to <xsl:value-of>. If the node exists and has a value this value is converted to a boolean, e.g. "true" or "false" as value will result into the corresponding boolean values. If the node does not exist, the defaultValue is returned.
Parameters:
  root - The node to start the search.
Parameters:
  path - XPath search expression.
Parameters:
  defaultValue - Default boolean value. The value of the node or defaultValue



node2String
public static String node2String(Node node)(Code)
Converts a org.w3c.dom.Node to a String. Uses javax.xml.transform.Transformer to convert from a Node to a String.
Parameters:
  node - a org.w3c.dom.Node value String representation of the documentXMLUtils.serializeNodeToXML(Node)



node2String
public static String node2String(Node node, boolean pretty)(Code)
Create a string representation of a org.w3c.dom.Node and any (most) subtypes.
Parameters:
  node - a org.w3c.dom.Node value
Parameters:
  pretty - a boolean value whether to format the XML a String valueXMLUtils.serializeNode(NodeProperties)



node2StringBuffer
public static StringBuffer node2StringBuffer(Node node)(Code)
Create a string representation of a org.w3c.dom.Node and any (most) subtypes.
Parameters:
  node - a org.w3c.dom.Node value a StringBuffer valueXMLUtils.serializeNodeToXML(Node)



node2StringBuffer
public static StringBuffer node2StringBuffer(Node node, boolean pretty, String indent)(Code)
Create a string representation of a org.w3c.dom.Node and any (most) subtypes.
Parameters:
  node - a org.w3c.dom.Node value
Parameters:
  pretty - a boolean value whether to format the XML
Parameters:
  indent - a String value containing spaces as initialindent, if null defaults to empty string. a StringBuffer valueXMLUtils.serializeNode(NodeProperties)



selectNodeList
public static NodeList selectNodeList(Node contextNode, String str) throws TransformerException(Code)
Use an XPath string to select a nodelist. XPath namespace prefixes are resolved from the contextNode.
Parameters:
  contextNode - The node to start searching from.
Parameters:
  str - A valid XPath string. A NodeIterator, should never be null.
throws:
  TransformerException -



selectNodeList
public static NodeList selectNodeList(Node contextNode, String str, XPathProcessor processor) throws TransformerException(Code)
Use an XPath string to select a nodelist. XPath namespace prefixes are resolved from the contextNode.
Parameters:
  contextNode - The node to start searching from.
Parameters:
  str - A valid XPath string.
Parameters:
  processor - The XPath Processor A NodeIterator, should never be null.
throws:
  TransformerException -



selectSingleNode
public static Node selectSingleNode(Node rootNode, String path) throws ProcessingException(Code)
Return the Node from the DOM Node rootNode using the XPath expression path. If the node does not exist, it is created and then returned. This is a very simple method for creating new nodes. If the XPath contains selectors ([,,,]) or "*" it is of course not possible to create the new node. So if you use such XPaths the node must exist beforehand. An simple exception is if the expression contains attribute test to values (e.g. [@id = 'du' and
Parameters:
  rootNode - The node to start the search.
Parameters:
  path - XPath expression for searching the node. The node specified by the path.
throws:
  ProcessingException - If no path is specified or the XPath engine fails.



selectSingleNode
public static Node selectSingleNode(Node rootNode, String path, XPathProcessor processor) throws ProcessingException(Code)
Return the Node from the DOM Node rootNode using the XPath expression path. If the node does not exist, it is created and then returned. This is a very simple method for creating new nodes. If the XPath contains selectors ([,,,]) or "*" it is of course not possible to create the new node. So if you use such XPaths the node must exist beforehand. An simple exception is if the expression contains attribute test to values (e.g. [@id = 'du' and
Parameters:
  rootNode - The node to start the search.
Parameters:
  path - XPath expression for searching the node.
Parameters:
  processor - The XPath processor to use The node specified by the path.
throws:
  ProcessingException - If no path is specified or the XPath engine fails.



setValueOfNode
public static void setValueOfNode(Node node, String value)(Code)
Set the value of the DOM node. All current children of the node are removed and a new text node with the value is appended.



valueOf
public static void valueOf(Node parent, String text) throws ProcessingException(Code)
Implementation for String : outputs characters representing the value.
Parameters:
  parent - The node getting the value
Parameters:
  text - the value



valueOf
public static void valueOf(Node parent, XMLizable v) throws ProcessingException(Code)
Implementation for XMLizable : outputs the value by calling v.toSax(contentHandler).
Parameters:
  parent - The node getting the value
Parameters:
  v - the XML fragment



valueOf
public static void valueOf(Node parent, Node v) throws ProcessingException(Code)
Implementation for org.w3c.dom.Node : converts the Node to a SAX event stream.
Parameters:
  parent - The node getting the value
Parameters:
  v - the value



valueOf
public static void valueOf(Node parent, Collection v) throws ProcessingException(Code)
Implementation for java.util.Collection : outputs the value by calling DOMUtil.valueOf(Node,Object) on each element of the collection.
Parameters:
  parent - The node getting the value
Parameters:
  v - the XML fragment



valueOf
public static void valueOf(Node parent, Map v) throws ProcessingException(Code)
Implementation for java.util.Map : For each entry an element is created with the childs key and value Outputs the value and the key by calling DOMUtil.valueOf(Node,Object) on each value and key of the Map.
Parameters:
  parent - The node getting the value
Parameters:
  v - the Map



valueOf
public static void valueOf(Node parent, Object v) throws ProcessingException(Code)
Implementation for Object depending on its class :
Parameters:
  parent - The node getting the value
Parameters:
  v - the value



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.