Source Code Cross Referenced for NamespaceNode.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » xpath » pattern » 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 » EJB Server resin 3.1.5 » resin » com.caucho.xpath.pattern 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *   Free SoftwareFoundation, Inc.
023:         *   59 Temple Place, Suite 330
024:         *   Boston, MA 02111-1307  USA
025:         *
026:         * @author Scott Ferguson
027:         */
028:
029:        package com.caucho.xpath.pattern;
030:
031:        import com.caucho.vfs.WriteStream;
032:        import com.caucho.xml.CauchoElement;
033:        import com.caucho.xml.CauchoNode;
034:        import com.caucho.xml.QAbstractNode;
035:        import com.caucho.xml.QAttr;
036:
037:        import org.w3c.dom.DOMException;
038:        import org.w3c.dom.Document;
039:        import org.w3c.dom.NamedNodeMap;
040:        import org.w3c.dom.Node;
041:        import org.w3c.dom.NodeList;
042:
043:        import java.io.IOException;
044:        import java.util.HashMap;
045:
046:        /**
047:         * A pseudo-node for handling the namespace:: axis.
048:         */
049:        public class NamespaceNode extends QAbstractNode implements  CauchoNode {
050:            Node _parent;
051:
052:            NamespaceNode _next;
053:            NamespaceNode _prev;
054:
055:            String _local;
056:            String _name;
057:            String _url;
058:
059:            /**
060:             * Creates a new namespace node.
061:             */
062:            public NamespaceNode(Node parent, NamespaceNode next,
063:                    String prefix, String url) {
064:                _parent = parent;
065:                _next = next;
066:                if (next != null)
067:                    next._prev = this ;
068:                _local = prefix;
069:                if (prefix == null || prefix.equals(""))
070:                    _name = "xmlns";
071:                else
072:                    _name = ("xmlns:" + prefix).intern();
073:                _url = url;
074:            }
075:
076:            /**
077:             * Creates a list of namespace nodes based on the current element.
078:             * The list is the list of namespaces active for that element.
079:             */
080:            static NamespaceNode create(Node node) {
081:                Node top = node;
082:                NamespaceNode nodes = null;
083:                HashMap<String, String> map = new HashMap<String, String>();
084:
085:                for (; node instanceof  CauchoElement; node = node
086:                        .getParentNode()) {
087:                    CauchoElement elt = (CauchoElement) node;
088:
089:                    String prefix = elt.getPrefix();
090:                    String url = elt.getNamespaceURI();
091:                    if (url == null)
092:                        url = "";
093:
094:                    if (map.get(prefix) == null) {
095:                        map.put(prefix, url);
096:                        if (!url.equals(""))
097:                            nodes = new NamespaceNode(top, nodes, prefix, url);
098:                    }
099:
100:                    QAttr attr = (QAttr) elt.getFirstAttribute();
101:                    for (; attr != null; attr = (QAttr) attr.getNextSibling()) {
102:                        String name = attr.getNodeName();
103:                        prefix = null;
104:                        url = "";
105:
106:                        if (name.startsWith("xmlns:")) {
107:                            prefix = name.substring(6);
108:                            url = attr.getNodeValue();
109:                        } else if (name.equals("xmlns")) {
110:                            prefix = "";
111:                            url = attr.getNodeValue();
112:                        } else {
113:                            prefix = attr.getPrefix();
114:                            url = attr.getNamespaceURI();
115:                        }
116:
117:                        if (url == null)
118:                            url = "";
119:
120:                        if (map.get(prefix) == null) {
121:                            map.put(prefix, url);
122:                            if (!url.equals(""))
123:                                nodes = new NamespaceNode(top, nodes, prefix,
124:                                        url);
125:                        }
126:                    }
127:                }
128:
129:                return nodes;
130:            }
131:
132:            public short getNodeType() {
133:                return ATTRIBUTE_NODE;
134:            }
135:
136:            public String getNodeName() {
137:                return _name;
138:            }
139:
140:            public String getPrefix() {
141:                return "xmlns";
142:            }
143:
144:            public void setPrefix(String prefix) {
145:            }
146:
147:            public boolean supports(String feature, String version) {
148:                return false;
149:            }
150:
151:            public String getCanonicalName() {
152:                return "";
153:            }
154:
155:            public String getLocalName() {
156:                return _local;
157:            }
158:
159:            public String getNamespaceURI() {
160:                return null;
161:            }
162:
163:            public String getNodeValue() {
164:                return _url;
165:            }
166:
167:            public Node getParentNode() {
168:                return _parent;
169:            }
170:
171:            public Node getPreviousSibling() {
172:                return _prev;
173:            }
174:
175:            public Node getNextSibling() {
176:                return _next;
177:            }
178:
179:            // The following are just stubs to conform to the api
180:
181:            public void setLocation(String filename, int line, int column) {
182:            }
183:
184:            public String getFilename() {
185:                return null;
186:            }
187:
188:            public int getLine() {
189:                return 0;
190:            }
191:
192:            public int getColumn() {
193:                return 0;
194:            }
195:
196:            public Document getOwnerDocument() {
197:                return null;
198:            }
199:
200:            public void setNodeValue(String value) {
201:            }
202:
203:            public NodeList getChildNodes() {
204:                return null;
205:            }
206:
207:            public Node getFirstChild() {
208:                return null;
209:            }
210:
211:            public Node getLastChild() {
212:                return null;
213:            }
214:
215:            public NamedNodeMap getAttributes() {
216:                return null;
217:            }
218:
219:            public Node insertBefore(Node newChild, Node refChild) {
220:                return null;
221:            }
222:
223:            public Node replaceChild(Node newChild, Node refChild) {
224:                return null;
225:            }
226:
227:            public Node removeChild(Node oldChild) throws DOMException {
228:                return null;
229:            }
230:
231:            public Node appendChild(Node newNode) throws DOMException {
232:                return null;
233:            }
234:
235:            public boolean hasChildNodes() {
236:                return false;
237:            }
238:
239:            public boolean equals(Node arg, boolean deep) {
240:                return this  == arg;
241:            }
242:
243:            public Node cloneNode(boolean deep) {
244:                return null;
245:            }
246:
247:            public void normalize() {
248:            }
249:
250:            public String getTextValue() {
251:                return getNodeValue();
252:            }
253:
254:            public boolean checkValid() {
255:                return false;
256:            }
257:
258:            public void print(WriteStream out) throws IOException {
259:            }
260:
261:            public void printPretty(WriteStream out) throws IOException {
262:            }
263:
264:            public void printHtml(WriteStream out) throws IOException {
265:            }
266:
267:            public boolean isSupported(String feature, String version) {
268:                return false;
269:            }
270:
271:            public boolean hasAttributes() {
272:                return false;
273:            }
274:
275:            public String toString() {
276:                return "NamespaceNode[" + _name + " " + _url + "]";
277:            }
278:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.