Source Code Cross Referenced for DocumentNavigator.java in  » Code-Analyzer » pmd-4.2rc1 » net » sourceforge » pmd » jaxen » 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 » Code Analyzer » pmd 4.2rc1 » net.sourceforge.pmd.jaxen 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
003:         */package net.sourceforge.pmd.jaxen;
004:
005:        import net.sourceforge.pmd.ast.CompilationUnit;
006:        import net.sourceforge.pmd.ast.Node;
007:        import org.jaxen.DefaultNavigator;
008:        import org.jaxen.XPath;
009:        import org.jaxen.util.SingleObjectIterator;
010:
011:        import java.util.ArrayList;
012:        import java.util.Iterator;
013:
014:        /**
015:         * @author daniels
016:         */
017:        public class DocumentNavigator extends DefaultNavigator {
018:
019:            private final static Iterator EMPTY_ITERATOR = new ArrayList()
020:                    .iterator();
021:
022:            public String getAttributeName(Object arg0) {
023:                return ((Attribute) arg0).getName();
024:            }
025:
026:            public String getAttributeNamespaceUri(Object arg0) {
027:                return "";
028:            }
029:
030:            public String getAttributeQName(Object arg0) {
031:                return ((Attribute) arg0).getName();
032:            }
033:
034:            public String getAttributeStringValue(Object arg0) {
035:                return ((Attribute) arg0).getValue();
036:            }
037:
038:            public String getCommentStringValue(Object arg0) {
039:                return "";
040:            }
041:
042:            public String getElementName(Object node) {
043:                return node.toString();
044:            }
045:
046:            public String getElementNamespaceUri(Object arg0) {
047:                return "";
048:            }
049:
050:            public String getElementQName(Object arg0) {
051:                return getElementName(arg0);
052:            }
053:
054:            public String getElementStringValue(Object arg0) {
055:                return "";
056:            }
057:
058:            public String getNamespacePrefix(Object arg0) {
059:                return "";
060:            }
061:
062:            public String getNamespaceStringValue(Object arg0) {
063:                return "";
064:            }
065:
066:            public String getTextStringValue(Object arg0) {
067:                return "";
068:            }
069:
070:            public boolean isAttribute(Object arg0) {
071:                return arg0 instanceof  Attribute;
072:            }
073:
074:            public boolean isComment(Object arg0) {
075:                return false;
076:            }
077:
078:            public boolean isDocument(Object arg0) {
079:                return arg0 instanceof  CompilationUnit;
080:            }
081:
082:            public boolean isElement(Object arg0) {
083:                return arg0 instanceof  Node;
084:            }
085:
086:            public boolean isNamespace(Object arg0) {
087:                return false;
088:            }
089:
090:            public boolean isProcessingInstruction(Object arg0) {
091:                return false;
092:            }
093:
094:            public boolean isText(Object arg0) {
095:                return false;
096:            }
097:
098:            public XPath parseXPath(String arg0) {
099:                return null;
100:            }
101:
102:            public Object getParentNode(Object arg0) {
103:                if (arg0 instanceof  Node) {
104:                    return ((Node) arg0).jjtGetParent();
105:                }
106:                return ((Attribute) arg0).getParent();
107:            }
108:
109:            public Iterator<Attribute> getAttributeAxisIterator(Object arg0) {
110:                return new AttributeAxisIterator((Node) arg0);
111:            }
112:
113:            /**
114:             * Get an iterator over all of this node's children.
115:             *
116:             * @param contextNode The context node for the child axis.
117:             * @return A possibly-empty iterator (not null).
118:             */
119:            public Iterator<Node> getChildAxisIterator(Object contextNode) {
120:                return new NodeIterator((Node) contextNode) {
121:                    protected Node getFirstNode(Node node) {
122:                        return getFirstChild(node);
123:                    }
124:
125:                    protected Node getNextNode(Node node) {
126:                        return getNextSibling(node);
127:                    }
128:                };
129:            }
130:
131:            /**
132:             * Get a (single-member) iterator over this node's parent.
133:             *
134:             * @param contextNode the context node for the parent axis.
135:             * @return A possibly-empty iterator (not null).
136:             */
137:            public Iterator getParentAxisIterator(Object contextNode) {
138:                if (isAttribute(contextNode)) {
139:                    return new SingleObjectIterator(((Attribute) contextNode)
140:                            .getParent());
141:                }
142:                Node parent = ((Node) contextNode).jjtGetParent();
143:                if (parent != null) {
144:                    return new SingleObjectIterator(parent);
145:                } else {
146:                    return EMPTY_ITERATOR;
147:                }
148:            }
149:
150:            /**
151:             * Get an iterator over all following siblings.
152:             *
153:             * @param contextNode the context node for the sibling iterator.
154:             * @return A possibly-empty iterator (not null).
155:             */
156:            public Iterator<Node> getFollowingSiblingAxisIterator(
157:                    Object contextNode) {
158:                return new NodeIterator((Node) contextNode) {
159:                    protected Node getFirstNode(Node node) {
160:                        return getNextNode(node);
161:                    }
162:
163:                    protected Node getNextNode(Node node) {
164:                        return getNextSibling(node);
165:                    }
166:                };
167:            }
168:
169:            /**
170:             * Get an iterator over all preceding siblings.
171:             *
172:             * @param contextNode The context node for the preceding sibling axis.
173:             * @return A possibly-empty iterator (not null).
174:             */
175:            public Iterator<Node> getPrecedingSiblingAxisIterator(
176:                    Object contextNode) {
177:                return new NodeIterator((Node) contextNode) {
178:                    protected Node getFirstNode(Node node) {
179:                        return getNextNode(node);
180:                    }
181:
182:                    protected Node getNextNode(Node node) {
183:                        return getPreviousSibling(node);
184:                    }
185:                };
186:            }
187:
188:            /**
189:             * Get an iterator over all following nodes, depth-first.
190:             *
191:             * @param contextNode The context node for the following axis.
192:             * @return A possibly-empty iterator (not null).
193:             */
194:            public Iterator<Node> getFollowingAxisIterator(Object contextNode) {
195:                return new NodeIterator((Node) contextNode) {
196:                    protected Node getFirstNode(Node node) {
197:                        if (node == null)
198:                            return null;
199:                        else {
200:                            Node sibling = getNextSibling(node);
201:                            if (sibling == null)
202:                                return getFirstNode(node.jjtGetParent());
203:                            else
204:                                return sibling;
205:                        }
206:                    }
207:
208:                    protected Node getNextNode(Node node) {
209:                        if (node == null)
210:                            return null;
211:                        else {
212:                            Node n = getFirstChild(node);
213:                            if (n == null)
214:                                n = getNextSibling(node);
215:                            if (n == null)
216:                                return getFirstNode(node.jjtGetParent());
217:                            else
218:                                return n;
219:                        }
220:                    }
221:                };
222:            }
223:
224:            /**
225:             * Get an iterator over all preceding nodes, depth-first.
226:             *
227:             * @param contextNode The context node for the preceding axis.
228:             * @return A possibly-empty iterator (not null).
229:             */
230:            public Iterator<Node> getPrecedingAxisIterator(Object contextNode) {
231:                return new NodeIterator((Node) contextNode) {
232:                    protected Node getFirstNode(Node node) {
233:                        if (node == null)
234:                            return null;
235:                        else {
236:                            Node sibling = getPreviousSibling(node);
237:                            if (sibling == null)
238:                                return getFirstNode(node.jjtGetParent());
239:                            else
240:                                return sibling;
241:                        }
242:                    }
243:
244:                    protected Node getNextNode(Node node) {
245:                        if (node == null)
246:                            return null;
247:                        else {
248:                            Node n = getLastChild(node);
249:                            if (n == null)
250:                                n = getPreviousSibling(node);
251:                            if (n == null)
252:                                return getFirstNode(node.jjtGetParent());
253:                            else
254:                                return n;
255:                        }
256:                    }
257:                };
258:            }
259:
260:            public Object getDocumentNode(Object contextNode) {
261:                if (isDocument(contextNode)) {
262:                    return contextNode;
263:                }
264:                return getDocumentNode(getParentNode(contextNode));
265:            }
266:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.