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


java.lang.Object
   org.apache.commons.configuration.tree.NodeCombiner
      org.apache.commons.configuration.tree.UnionCombiner

UnionCombiner
public class UnionCombiner extends NodeCombiner (Code)

A specialized implementation of the NodeCombiner interface that constructs a union from two passed in node hierarchies.

The given source hierarchies are traversed and their nodes are added to the resulting structure. Under some circumstances two nodes can be combined rather than adding both. This is the case if both nodes are single children (no lists) of their parents and do not have values. The corresponding check is implemented in the findCombineNode() method.

Sometimes it is not possible for this combiner to detect whether two nodes can be combined or not. Consider the following two node hierarchies:

 Hierarchy 1:
 Database
 +--Tables
 +--Table
 +--name [users]
 +--fields
 +--field
 |    +--name [uid]
 +--field
 |    +--name [usrname]
 ...
 

 Hierarchy 2:
 Database
 +--Tables
 +--Table
 +--name [documents]
 +--fields
 +--field
 |    +--name [docid]
 +--field
 |    +--name [docname]
 ...
 

Both hierarchies contain data about database tables. Each describes a single table. If these hierarchies are to be combined, the result should probably look like the following:

 Database
 +--Tables
 +--Table
 |    +--name [users]
 |    +--fields
 |          +--field
 |          |    +--name [uid]
 |            ...
 +--Table
 +--name [documents]
 +--fields
 +--field
 |    +--name [docid]
 ...
 

i.e. the Tables nodes should be combined, while the Table nodes should both be added to the resulting tree. From the combiner's point of view there is no difference between the Tables and the Table nodes in the source trees, so the developer has to help out and give a hint that the Table nodes belong to a list structure. This can be done using the addListNode() method; this method expects the name of a node, which should be treated as a list node. So if addListNode("Table"); was called, the combiner knows that it must not combine the Table nodes, but add it both to the resulting tree.


author:
   author:
   href="http://jakarta.apache.org/commons/configuration/team-list.html">Commons
author:
   Configuration team
version:
   $Id: UnionCombiner.java 439648 2006-09-02 20:42:10Z oheger $
since:
   1.3




Method Summary
public  ConfigurationNodecombine(ConfigurationNode node1, ConfigurationNode node2)
     Combines the given nodes to a new union node.
protected  ConfigurationNodefindCombineNode(ConfigurationNode node1, ConfigurationNode node2, ConfigurationNode child, List children)
    

Tries to find a child node of the second source node, with whitch a child of the first source node can be combined.




Method Detail
combine
public ConfigurationNode combine(ConfigurationNode node1, ConfigurationNode node2)(Code)
Combines the given nodes to a new union node.
Parameters:
  node1 - the first source node
Parameters:
  node2 - the second source node the union node



findCombineNode
protected ConfigurationNode findCombineNode(ConfigurationNode node1, ConfigurationNode node2, ConfigurationNode child, List children)(Code)

Tries to find a child node of the second source node, with whitch a child of the first source node can be combined. During combining of the source nodes an iteration over the first source node's children is performed. For each child node it is checked whether a corresponding child node in the second source node exists. If this is the case, these corresponsing child nodes are recursively combined and the result is added to the combined node. This method implements the checks whether such a recursive combination is possible. The actual implementation tests the following conditions:

  • In both the first and the second source node there is only one child node with the given name (no list structures).
  • The given name is not in the list of known list nodes, i.e. it was not passed to the addListNode() method.
  • None of these matching child nodes has a value.

If all of these tests are successfull, the matching child node of the second source node is returned. Otherwise the result is null.


Parameters:
  node1 - the first source node
Parameters:
  node2 - the second source node
Parameters:
  child - the child node of the first source node to be checked
Parameters:
  children - a list with all children of the second source node the matching child node of the second source node or nullif there is none



Fields inherited from org.apache.commons.configuration.tree.NodeCombiner
protected Set listNodes(Code)(Java Doc)

Methods inherited from org.apache.commons.configuration.tree.NodeCombiner
public void addListNode(String nodeName)(Code)(Java Doc)
abstract public ConfigurationNode combine(ConfigurationNode node1, ConfigurationNode node2)(Code)(Java Doc)
protected ViewNode createViewNode()(Code)(Java Doc)
public Set getListNodes()(Code)(Java Doc)
public boolean isListNode(ConfigurationNode node)(Code)(Java Doc)

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.