Source Code Cross Referenced for Nodes.java in  » XML » xom » nu » xom » 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 » XML » xom » nu.xom 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2002, 2003, 2005 Elliotte Rusty Harold
002:           
003:           This library is free software; you can redistribute it and/or modify
004:           it under the terms of version 2.1 of the GNU Lesser General Public 
005:           License as published by the Free Software Foundation.
006:           
007:           This library is distributed in the hope that it will be useful,
008:           but WITHOUT ANY WARRANTY; without even the implied warranty of
009:           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
010:           GNU Lesser General Public License for more details.
011:           
012:           You should have received a copy of the GNU Lesser General Public
013:           License along with this library; if not, write to the 
014:           Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
015:           Boston, MA 02111-1307  USA
016:           
017:           You can contact Elliotte Rusty Harold by sending e-mail to
018:           elharo@metalab.unc.edu. Please include the word "XOM" in the
019:           subject line. The XOM home page is located at http://www.xom.nu/
020:         */
021:
022:        package nu.xom;
023:
024:        import java.util.ArrayList;
025:        import java.util.List;
026:
027:        /**
028:         * 
029:         * <p>
030:         * Implements a list of nodes for traversal purposes.
031:         * Changes to the document from which this list was generated
032:         * are not reflected in this list, nor are changes to the list
033:         * reflected in the document. Changes to the individual
034:         * <code>Node</code> objects in the list and the document
035:         * are reflected in the other one.
036:         * </p>
037:         * 
038:         * <p>
039:         * There is no requirement that the list not contain duplicates,
040:         * or that all the members come from the same document. It is simply
041:         * a list of nodes. 
042:         * </p>
043:         * 
044:         * @author Elliotte Rusty Harold
045:         * @version 1.1b4
046:         *
047:         */
048:        public final class Nodes {
049:
050:            private final List nodes;
051:
052:            /**
053:             * <p>
054:             * Creates an empty node list. 
055:             * </p>
056:             */
057:            public Nodes() {
058:                nodes = new ArrayList();
059:            }
060:
061:            /**
062:             * <p>
063:             * Creates a node list containing a single node.
064:             * </p>
065:             * 
066:             * @param node the node to insert in the list
067:             * 
068:             * @throws NullPointerException if <code>node</code> is null
069:             */
070:            public Nodes(Node node) {
071:
072:                if (node == null) {
073:                    throw new NullPointerException(
074:                            "Nodes content must be non-null");
075:                }
076:                nodes = new ArrayList(1);
077:                nodes.add(node);
078:
079:            }
080:
081:            Nodes(List results) {
082:                this .nodes = results;
083:            }
084:
085:            /**
086:             * <p>
087:             * Returns the number of nodes in the list.
088:             * This is guaranteed to be non-negative. 
089:             * </p>
090:             * 
091:             * @return the number of nodes in the list
092:             */
093:            public int size() {
094:                return nodes.size();
095:            }
096:
097:            /**
098:             * <p>
099:             * Returns the index<sup>th</sup> node in the list.
100:             * The first node has index 0. The last node
101:             * has index <code>size()-1</code>.
102:             * </p>
103:             * 
104:             * @param index the node to return
105:             * 
106:             * @return the node at the specified position
107:             * 
108:             * @throws IndexOutOfBoundsException if <code>index</code> is  
109:             *     negative or greater than or equal to the size of the list
110:             */
111:            public Node get(int index) {
112:                return (Node) nodes.get(index);
113:            }
114:
115:            /**
116:             * <p>
117:             * Removes the index<sup>th</sup>node in the list.
118:             * Subsequent nodes have their indexes reduced by one.
119:             * </p>
120:             * 
121:             * @param index the node to remove
122:             * 
123:             * @return the node at the specified position
124:             * 
125:             * @throws <code>IndexOutOfBoundsException</code> if index is  
126:             *     negative or greater than or equal to the size of the list
127:             */
128:            public Node remove(int index) {
129:                return (Node) nodes.remove(index);
130:            }
131:
132:            /**
133:             * <p>
134:             * Inserts a node at the index<sup>th</sup> position in the list.
135:             * Subsequent nodes have their indexes increased by one.
136:             * </p>
137:             * 
138:             * @param node the node to insert
139:             * @param index the position at which to insert the node
140:             * 
141:             * @throws IndexOutOfBoundsException if <code>index</code> is  
142:             *     negative or strictly greater than the size of the list
143:             * @throws NullPointerException if <code>node</code> is null
144:             */
145:            public void insert(Node node, int index) {
146:                if (node == null) {
147:                    throw new NullPointerException(
148:                            "Nodes content must be non-null");
149:                }
150:                nodes.add(index, node);
151:            }
152:
153:            /**
154:             * <p>
155:             * Adds a node at the end of this list.
156:             * </p>
157:             * 
158:             * @param node the node to add to the list
159:             * 
160:             * @throws NullPointerException if <code>node</code> is null
161:             */
162:            public void append(Node node) {
163:                if (node == null) {
164:                    throw new NullPointerException(
165:                            "Nodes content must be non-null");
166:                }
167:                nodes.add(node);
168:            }
169:
170:            /**
171:             * <p>
172:             * Determines whether a node is contained in this list.
173:             * </p>
174:             * 
175:             * @param node the node to search for
176:             * 
177:             * @return true if this list contains the specified node;
178:             *     false otherwise
179:             */
180:            public boolean contains(Node node) {
181:                return nodes.contains(node);
182:            }
183:
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.