Java Doc for XPathExpressionEngine.java in  » Library » Apache-commons-configuration-1.4-src » org » apache » commons » configuration » tree » xpath » 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 » Library » Apache commons configuration 1.4 src » org.apache.commons.configuration.tree.xpath 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.configuration.tree.xpath.XPathExpressionEngine

XPathExpressionEngine
public class XPathExpressionEngine implements ExpressionEngine(Code)

A specialized implementation of the ExpressionEngine interface that is able to evaluate XPATH expressions.

This class makes use of Commons JXPath for handling XPath expressions and mapping them to the nodes of a hierarchical configuration. This makes the rich and powerfull XPATH syntax available for accessing properties from a configuration object.

For selecting properties arbitrary XPATH expressions can be used, which select single or multiple configuration nodes. The associated Configuration instance will directly pass the specified property keys into this engine. If a key is not syntactically correct, an exception will be thrown.

For adding new properties, this expression engine uses a specific syntax: the "key" of a new property must consist of two parts that are separated by whitespace:

  1. An XPATH expression selecting a single node, to which the new element(s) are to be added. This can be an arbitrary complex expression, but it must select exactly one node, otherwise an exception will be thrown.
  2. The name of the new element(s) to be added below this parent node. Here either a single node name or a complete path of nodes (separated by the "/" character) can be specified.
Some examples for valid keys that can be passed into the configuration's addProperty() method follow:

 "/tables/table[1] type"
 

This will add a new type node as a child of the first table element.

 "/tables/table[1] @type"
 

Similar to the example above, but this time a new attribute named type will be added to the first table element.

 "/tables table/fields/field/name"
 

This example shows how a complex path can be added. Parent node is the tables element. Here a new branch consisting of the nodes table, fields, field, and name will be added.


since:
   1.3
author:
   Oliver Heger
version:
   $Id: XPathExpressionEngine.java 466413 2006-10-21 15:23:45Z oheger $


Field Summary
final static  StringATTR_DELIMITER
     Constant for the attribute delimiter.
final static  StringPATH_DELIMITER
     Constant for the path delimiter.


Method Summary
protected  JXPathContextcreateContext(ConfigurationNode root, String key)
     Creates the JXPathContext used for executing a query.
protected  voidinitNodeAddData(NodeAddData data, String path)
     Initializes most properties of a NodeAddData object.
public  StringnodeKey(ConfigurationNode node, String parentKey)
     Returns a (canonic) key for the given node based on the parent's key. This implementation will create an XPATH expression that selects the given node (under the assumption that the passed in parent key is valid). As the nodeKey() implementation of org.apache.commons.configuration.tree.DefaultExpressionEngine DefaultExpressionEngine this method will not return indices for nodes.
public  NodeAddDataprepareAdd(ConfigurationNode root, String key)
     Prepares an add operation for a configuration property.
public  Listquery(ConfigurationNode root, String key)
     Executes a query.

Field Detail
ATTR_DELIMITER
final static String ATTR_DELIMITER(Code)
Constant for the attribute delimiter.



PATH_DELIMITER
final static String PATH_DELIMITER(Code)
Constant for the path delimiter.





Method Detail
createContext
protected JXPathContext createContext(ConfigurationNode root, String key)(Code)
Creates the JXPathContext used for executing a query. This method will create a new context and ensure that it is correctly initialized.
Parameters:
  root - the configuration root node
Parameters:
  key - the key to be queried the new context



initNodeAddData
protected void initNodeAddData(NodeAddData data, String path)(Code)
Initializes most properties of a NodeAddData object. This method is called by prepareAdd() after the parent node has been found. Its task is to interprete the passed in path of the new node.
Parameters:
  data - the data object to initialize
Parameters:
  path - the path of the new node



nodeKey
public String nodeKey(ConfigurationNode node, String parentKey)(Code)
Returns a (canonic) key for the given node based on the parent's key. This implementation will create an XPATH expression that selects the given node (under the assumption that the passed in parent key is valid). As the nodeKey() implementation of org.apache.commons.configuration.tree.DefaultExpressionEngine DefaultExpressionEngine this method will not return indices for nodes. So all child nodes of a given parent whith the same name will have the same key.
Parameters:
  node - the node for which a key is to be constructed
Parameters:
  parentKey - the key of the parent node the key for the given node



prepareAdd
public NodeAddData prepareAdd(ConfigurationNode root, String key)(Code)
Prepares an add operation for a configuration property. The expected format of the passed in key is explained in the class comment.
Parameters:
  root - the configuration's root node
Parameters:
  key - the key describing the target of the add operation and thepath of the new node a data object to be evaluated by the calling configuration object



query
public List query(ConfigurationNode root, String key)(Code)
Executes a query. The passed in property key is directly passed to a JXPath context.
Parameters:
  root - the configuration root node
Parameters:
  key - the query to be executed a list with the nodes that are selected by the query



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.