Source Code Cross Referenced for NodeCombiner.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 Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.commons.configuration.tree;
018:
019:        import java.util.Collections;
020:        import java.util.HashSet;
021:        import java.util.Set;
022:
023:        /**
024:         * <p>
025:         * A base class for node combiner implementations.
026:         * </p>
027:         * <p>
028:         * A <em>node combiner</em> is an object that knows how two hierarchical node
029:         * structures can be combined into a single one. Of course, there are many
030:         * possible ways of implementing such a combination, e.g. constructing a union,
031:         * an intersection, or an "override" structure (were nodes in the first
032:         * hierarchy take precedence over nodes in the second hierarchy). This abstract
033:         * base class only provides some helper methods and defines the common interface
034:         * for node combiners. Concrete sub classes will implement the diverse
035:         * combination algorithms.
036:         * </p>
037:         * <p>
038:         * For some concrete combiner implementations it is important to distinguish
039:         * whether a node is a single node or whether it belongs to a list structure.
040:         * Alone from the input structures, the combiner will not always be able to make
041:         * this decision. So sometimes it may be necessary for the developer to
042:         * configure the combiner and tell it, which nodes should be treated as list
043:         * nodes. For this purpose the <code>addListNode()</code> method exists. It
044:         * can be passed the name of a node, which should be considered a list node.
045:         * </p>
046:         *
047:         * @author <a
048:         * href="http://jakarta.apache.org/commons/configuration/team-list.html">Commons
049:         * Configuration team</a>
050:         * @version $Id: NodeCombiner.java 439648 2006-09-02 20:42:10Z oheger $
051:         * @since 1.3
052:         */
053:        public abstract class NodeCombiner {
054:            /** Stores a list with node names that are known to be list nodes. */
055:            protected Set listNodes;
056:
057:            /**
058:             * Creates a new instance of <code>NodeCombiner</code>.
059:             */
060:            public NodeCombiner() {
061:                listNodes = new HashSet();
062:            }
063:
064:            /**
065:             * Adds the name of a node to the list of known list nodes. This means that
066:             * nodes with this name will never be combined.
067:             *
068:             * @param nodeName the name to be added
069:             */
070:            public void addListNode(String nodeName) {
071:                listNodes.add(nodeName);
072:            }
073:
074:            /**
075:             * Returns a set with the names of nodes that are known to be list nodes.
076:             *
077:             * @return a set with the names of list nodes
078:             */
079:            public Set getListNodes() {
080:                return Collections.unmodifiableSet(listNodes);
081:            }
082:
083:            /**
084:             * Checks if a node is a list node. This implementation tests if the given
085:             * node name is contained in the set of known list nodes. Derived classes
086:             * which use different criteria may overload this method.
087:             *
088:             * @param node the node to be tested
089:             * @return a flag whether this is a list node
090:             */
091:            public boolean isListNode(ConfigurationNode node) {
092:                return listNodes.contains(node.getName());
093:            }
094:
095:            /**
096:             * Combines the hierarchies represented by the given root nodes. This method
097:             * must be defined in concrete sub classes with the implementation of a
098:             * specific combination algorithm.
099:             *
100:             * @param node1 the first root node
101:             * @param node2 the second root node
102:             * @return the resulting combined node structure
103:             */
104:            public abstract ConfigurationNode combine(ConfigurationNode node1,
105:                    ConfigurationNode node2);
106:
107:            /**
108:             * Creates a new view node. This method will be called whenever a new view
109:             * node is to be created. It can be overriden to create special view nodes.
110:             * This base implementation returns a new instance of
111:             * <code>{@link ViewNode}</code>.
112:             *
113:             * @return the new view node
114:             */
115:            protected ViewNode createViewNode() {
116:                return new ViewNode();
117:            }
118:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.