Source Code Cross Referenced for NodeSetImpl.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » page » document » proxy » 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 » Portal » jetspeed 2.1.3 » org.apache.jetspeed.page.document.proxy 
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.jetspeed.page.document.proxy;
018:
019:        import java.util.ArrayList;
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.regex.Pattern;
023:
024:        import org.apache.jetspeed.page.document.Node;
025:        import org.apache.jetspeed.page.document.NodeSet;
026:
027:        /**
028:         * This class implements generic NodeSet ordered lists
029:         * used with proxied instances of PSML Folders to create a
030:         * logical view of site content.
031:         * 
032:         * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
033:         * @version $Id: NodeSetImpl.java 552972 2007-07-03 20:42:07Z taylor $
034:         */
035:        public class NodeSetImpl implements  NodeSet {
036:            /**
037:             * nodes - list of proxy nodes
038:             */
039:            private List nodes;
040:
041:            /**
042:             * NodeSetImpl - construct immutable proxy Node NodeSet list
043:             *
044:             * @param nodes list of proxy Nodes
045:             */
046:            public NodeSetImpl(List nodes) {
047:                this .nodes = nodes;
048:            }
049:
050:            /**
051:             * get - return proxy Node by name or path
052:             *
053:             * @param name node name
054:             * @return Node proxy
055:             */
056:            public Node get(String name) {
057:                // search nodes for matching name or path
058:                Iterator nodesIter = nodes.iterator();
059:                while (nodesIter.hasNext()) {
060:                    Node node = (Node) nodesIter.next();
061:                    if (node.getName().equals(name)
062:                            || node.getPath().equals(name)) {
063:                        return node;
064:                    }
065:                }
066:                return null;
067:            }
068:
069:            /**
070:             * iterator - return iterator over ordered list
071:             *
072:             * @return proxy NodeSet list iterator
073:             */
074:            public Iterator iterator() {
075:                return nodes.listIterator();
076:            }
077:
078:            /**
079:             * subset - construct new NodeSet containing Node proxies
080:             *          of the specified type
081:             *
082:             * @param type node type 
083:             * @return proxy NodeSet list
084:             */
085:            public NodeSet subset(String type) {
086:                // search for matching nodes
087:                List subsetNodes = null;
088:                Iterator nodesIter = nodes.iterator();
089:                while (nodesIter.hasNext()) {
090:                    Node node = (Node) nodesIter.next();
091:                    if (node.getType().equals(type)) {
092:                        if (subsetNodes == null) {
093:                            subsetNodes = new ArrayList(nodes.size());
094:                        }
095:                        subsetNodes.add(node);
096:                    }
097:                }
098:
099:                // wrap matching nodes in new NodeSet
100:                if (subsetNodes != null)
101:                    return new NodeSetImpl(subsetNodes);
102:                return null;
103:            }
104:
105:            /**
106:             * inclusiveSubset - construct new NodeSet containing Node
107:             *                   proxies whose name or path matches
108:             *                   the specified regex pattern
109:             *
110:             * @param regex proxy Node name/path match pattern 
111:             * @return proxy NodeSet list
112:             */
113:            public NodeSet inclusiveSubset(String regex) {
114:                // search for matching nodes
115:                List subsetNodes = null;
116:                Pattern pattern = Pattern.compile(regex);
117:                Iterator nodesIter = nodes.iterator();
118:                while (nodesIter.hasNext()) {
119:                    Node node = (Node) nodesIter.next();
120:                    if (pattern.matcher(node.getName()).matches()
121:                            || pattern.matcher(node.getPath()).matches()) {
122:                        if (subsetNodes == null) {
123:                            subsetNodes = new ArrayList(nodes.size());
124:                        }
125:                        subsetNodes.add(node);
126:                    }
127:                }
128:
129:                // wrap matching nodes in new NodeSet
130:                if (subsetNodes != null)
131:                    return new NodeSetImpl(subsetNodes);
132:                return null;
133:            }
134:
135:            /**
136:             * exclusiveSubset - construct new NodeSet containing Node
137:             *                   proxies whose name or path does not match
138:             *                   the specified regex pattern
139:             *
140:             * @param regex proxy Node name/path match pattern 
141:             * @return proxy NodeSet list
142:             */
143:            public NodeSet exclusiveSubset(String regex) {
144:                // search for matching nodes
145:                List subsetNodes = null;
146:                Pattern pattern = Pattern.compile(regex);
147:                Iterator nodesIter = nodes.iterator();
148:                while (nodesIter.hasNext()) {
149:                    Node node = (Node) nodesIter.next();
150:                    if (!pattern.matcher(node.getName()).matches()
151:                            && !pattern.matcher(node.getPath()).matches()) {
152:                        if (subsetNodes == null) {
153:                            subsetNodes = new ArrayList(nodes.size());
154:                        }
155:                        subsetNodes.add(node);
156:                    }
157:                }
158:
159:                // wrap matching nodes in new NodeSet
160:                if (subsetNodes != null)
161:                    return new NodeSetImpl(subsetNodes);
162:                return null;
163:            }
164:
165:            /**
166:             * size - return size of NodeSet list
167:             *
168:             * @return size of list
169:             */
170:            public int size() {
171:                return nodes.size();
172:            }
173:
174:            /**
175:             * contains - test named Node proxy for existance in NodeSet list
176:             *
177:             * @param node proxy Node
178:             * @return Node proxy
179:             */
180:            public boolean contains(Node node) {
181:                return nodes.contains(node);
182:            }
183:
184:            /**
185:             * isEmpty - returns flag indicationg whether NodeSet list is
186:             *           empty or not
187:             *
188:             * @return empty flag
189:             */
190:            public boolean isEmpty() {
191:                return nodes.isEmpty();
192:            }
193:
194:            /**
195:             * add - adds specified proxyNode to the ordered NodeSet list
196:             *
197:             * @param node proxy Node
198:             */
199:            public void add(Node node) {
200:                // not implementd for immutable proxy lists
201:                throw new RuntimeException(
202:                        "NodeSet list is immutable from proxy.");
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.