Source Code Cross Referenced for DOM2DTMdefaultNamespaceDeclarationNode.java in  » XML » xalan » org » apache » xml » dtm » ref » dom2dtm » 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 » xalan » org.apache.xml.dtm.ref.dom2dtm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        /*
017:         * $Id: DOM2DTMdefaultNamespaceDeclarationNode.java,v 1.6 2005/05/17 17:22:14 mkwan Exp $
018:         */
019:
020:        package org.apache.xml.dtm.ref.dom2dtm;
021:
022:        import org.apache.xml.dtm.DTMException;
023:
024:        import org.w3c.dom.Attr;
025:        import org.w3c.dom.Document;
026:        import org.w3c.dom.Element;
027:        import org.w3c.dom.NamedNodeMap;
028:        import org.w3c.dom.Node;
029:        import org.w3c.dom.NodeList;
030:        import org.w3c.dom.TypeInfo;
031:        import org.w3c.dom.UserDataHandler;
032:        import org.w3c.dom.DOMException;
033:
034:        /** This is a kluge to let us shove a declaration for xml: into the
035:         * DOM2DTM model.  Basically, it creates a proxy node in DOM space to
036:         * carry the additional information. This is _NOT_ a full DOM
037:         * implementation, and shouldn't be one since it sits alongside the
038:         * DOM rather than becoming part of the DOM model.
039:         * 
040:         * (This used to be an internal class within DOM2DTM. Moved out because
041:         * I need to perform an instanceof operation on it to support a temporary
042:         * workaround in DTMManagerDefault.)
043:         * 
044:         * %REVIEW% What if the DOM2DTM was built around a DocumentFragment and
045:         * there isn't a single root element? I think this fails that case...
046:         * 
047:         * %REVIEW% An alternative solution would be to create the node _only_
048:         * in DTM space, but given how DOM2DTM is currently written I think
049:         * this is simplest.
050:         * */
051:        public class DOM2DTMdefaultNamespaceDeclarationNode implements  Attr,
052:                TypeInfo {
053:            final String NOT_SUPPORTED_ERR = "Unsupported operation on pseudonode";
054:
055:            Element pseudoparent;
056:            String prefix, uri, nodename;
057:            int handle;
058:
059:            DOM2DTMdefaultNamespaceDeclarationNode(Element pseudoparent,
060:                    String prefix, String uri, int handle) {
061:                this .pseudoparent = pseudoparent;
062:                this .prefix = prefix;
063:                this .uri = uri;
064:                this .handle = handle;
065:                this .nodename = "xmlns:" + prefix;
066:            }
067:
068:            public String getNodeName() {
069:                return nodename;
070:            }
071:
072:            public String getName() {
073:                return nodename;
074:            }
075:
076:            public String getNamespaceURI() {
077:                return "http://www.w3.org/2000/xmlns/";
078:            }
079:
080:            public String getPrefix() {
081:                return prefix;
082:            }
083:
084:            public String getLocalName() {
085:                return prefix;
086:            }
087:
088:            public String getNodeValue() {
089:                return uri;
090:            }
091:
092:            public String getValue() {
093:                return uri;
094:            }
095:
096:            public Element getOwnerElement() {
097:                return pseudoparent;
098:            }
099:
100:            public boolean isSupported(String feature, String version) {
101:                return false;
102:            }
103:
104:            public boolean hasChildNodes() {
105:                return false;
106:            }
107:
108:            public boolean hasAttributes() {
109:                return false;
110:            }
111:
112:            public Node getParentNode() {
113:                return null;
114:            }
115:
116:            public Node getFirstChild() {
117:                return null;
118:            }
119:
120:            public Node getLastChild() {
121:                return null;
122:            }
123:
124:            public Node getPreviousSibling() {
125:                return null;
126:            }
127:
128:            public Node getNextSibling() {
129:                return null;
130:            }
131:
132:            public boolean getSpecified() {
133:                return false;
134:            }
135:
136:            public void normalize() {
137:                return;
138:            }
139:
140:            public NodeList getChildNodes() {
141:                return null;
142:            }
143:
144:            public NamedNodeMap getAttributes() {
145:                return null;
146:            }
147:
148:            public short getNodeType() {
149:                return Node.ATTRIBUTE_NODE;
150:            }
151:
152:            public void setNodeValue(String value) {
153:                throw new DTMException(NOT_SUPPORTED_ERR);
154:            }
155:
156:            public void setValue(String value) {
157:                throw new DTMException(NOT_SUPPORTED_ERR);
158:            }
159:
160:            public void setPrefix(String value) {
161:                throw new DTMException(NOT_SUPPORTED_ERR);
162:            }
163:
164:            public Node insertBefore(Node a, Node b) {
165:                throw new DTMException(NOT_SUPPORTED_ERR);
166:            }
167:
168:            public Node replaceChild(Node a, Node b) {
169:                throw new DTMException(NOT_SUPPORTED_ERR);
170:            }
171:
172:            public Node appendChild(Node a) {
173:                throw new DTMException(NOT_SUPPORTED_ERR);
174:            }
175:
176:            public Node removeChild(Node a) {
177:                throw new DTMException(NOT_SUPPORTED_ERR);
178:            }
179:
180:            public Document getOwnerDocument() {
181:                return pseudoparent.getOwnerDocument();
182:            }
183:
184:            public Node cloneNode(boolean deep) {
185:                throw new DTMException(NOT_SUPPORTED_ERR);
186:            }
187:
188:            /** Non-DOM method, part of the temporary kluge
189:             * %REVIEW% This would be a pruning problem, but since it will always be
190:             * added to the root element and we prune on elements, we shouldn't have 
191:             * to worry.
192:             */
193:            public int getHandleOfNode() {
194:                return handle;
195:            }
196:
197:            //RAMESH: PENDING=> Add proper implementation for the below DOM L3 additions
198:
199:            /**
200:             * @see org.w3c.dom.TypeInfo#getTypeName()
201:             */
202:            public String getTypeName() {
203:                return null;
204:            }
205:
206:            /**
207:             * @see org.w3c.dom.TypeInfo#getTypeNamespace()
208:             */
209:            public String getTypeNamespace() {
210:                return null;
211:            }
212:
213:            /**
214:             * @see or.gw3c.dom.TypeInfo#isDerivedFrom(String,String,int)
215:             */
216:            public boolean isDerivedFrom(String ns, String localName,
217:                    int derivationMethod) {
218:                return false;
219:            }
220:
221:            public TypeInfo getSchemaTypeInfo() {
222:                return this ;
223:            }
224:
225:            public boolean isId() {
226:                return false;
227:            }
228:
229:            /**
230:             * Associate an object to a key on this node. The object can later be
231:             * retrieved from this node by calling <code>getUserData</code> with the
232:             * same key.
233:             * @param key The key to associate the object to.
234:             * @param data The object to associate to the given key, or
235:             *   <code>null</code> to remove any existing association to that key.
236:             * @param handler The handler to associate to that key, or
237:             *   <code>null</code>.
238:             * @return Returns the <code>DOMObject</code> previously associated to
239:             *   the given key on this node, or <code>null</code> if there was none.
240:             * @since DOM Level 3
241:             */
242:            public Object setUserData(String key, Object data,
243:                    UserDataHandler handler) {
244:                return getOwnerDocument().setUserData(key, data, handler);
245:            }
246:
247:            /**
248:             * Retrieves the object associated to a key on a this node. The object
249:             * must first have been set to this node by calling
250:             * <code>setUserData</code> with the same key.
251:             * @param key The key the object is associated to.
252:             * @return Returns the <code>DOMObject</code> associated to the given key
253:             *   on this node, or <code>null</code> if there was none.
254:             * @since DOM Level 3
255:             */
256:            public Object getUserData(String key) {
257:                return getOwnerDocument().getUserData(key);
258:            }
259:
260:            /**
261:             *  This method returns a specialized object which implements the
262:             * specialized APIs of the specified feature and version. The
263:             * specialized object may also be obtained by using binding-specific
264:             * casting methods but is not necessarily expected to, as discussed in Mixed DOM implementations.
265:             * @param feature The name of the feature requested (case-insensitive).
266:             * @param version  This is the version number of the feature to test. If
267:             *   the version is <code>null</code> or the empty string, supporting
268:             *   any version of the feature will cause the method to return an
269:             *   object that supports at least one version of the feature.
270:             * @return  Returns an object which implements the specialized APIs of
271:             *   the specified feature and version, if any, or <code>null</code> if
272:             *   there is no object which implements interfaces associated with that
273:             *   feature. If the <code>DOMObject</code> returned by this method
274:             *   implements the <code>Node</code> interface, it must delegate to the
275:             *   primary core <code>Node</code> and not return results inconsistent
276:             *   with the primary core <code>Node</code> such as attributes,
277:             *   childNodes, etc.
278:             * @since DOM Level 3
279:             */
280:            public Object getFeature(String feature, String version) {
281:                // we don't have any alternate node, either this node does the job
282:                // or we don't have anything that does
283:                return isSupported(feature, version) ? this  : null;
284:            }
285:
286:            /**
287:             * Tests whether two nodes are equal.
288:             * <br>This method tests for equality of nodes, not sameness (i.e.,
289:             * whether the two nodes are references to the same object) which can be
290:             * tested with <code>Node.isSameNode</code>. All nodes that are the same
291:             * will also be equal, though the reverse may not be true.
292:             * <br>Two nodes are equal if and only if the following conditions are
293:             * satisfied: The two nodes are of the same type.The following string
294:             * attributes are equal: <code>nodeName</code>, <code>localName</code>,
295:             * <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code>
296:             * , <code>baseURI</code>. This is: they are both <code>null</code>, or
297:             * they have the same length and are character for character identical.
298:             * The <code>attributes</code> <code>NamedNodeMaps</code> are equal.
299:             * This is: they are both <code>null</code>, or they have the same
300:             * length and for each node that exists in one map there is a node that
301:             * exists in the other map and is equal, although not necessarily at the
302:             * same index.The <code>childNodes</code> <code>NodeLists</code> are
303:             * equal. This is: they are both <code>null</code>, or they have the
304:             * same length and contain equal nodes at the same index. This is true
305:             * for <code>Attr</code> nodes as for any other type of node. Note that
306:             * normalization can affect equality; to avoid this, nodes should be
307:             * normalized before being compared.
308:             * <br>For two <code>DocumentType</code> nodes to be equal, the following
309:             * conditions must also be satisfied: The following string attributes
310:             * are equal: <code>publicId</code>, <code>systemId</code>,
311:             * <code>internalSubset</code>.The <code>entities</code>
312:             * <code>NamedNodeMaps</code> are equal.The <code>notations</code>
313:             * <code>NamedNodeMaps</code> are equal.
314:             * <br>On the other hand, the following do not affect equality: the
315:             * <code>ownerDocument</code> attribute, the <code>specified</code>
316:             * attribute for <code>Attr</code> nodes, the
317:             * <code>isWhitespaceInElementContent</code> attribute for
318:             * <code>Text</code> nodes, as well as any user data or event listeners
319:             * registered on the nodes.
320:             * @param arg The node to compare equality with.
321:             * @param deep If <code>true</code>, recursively compare the subtrees; if
322:             *   <code>false</code>, compare only the nodes themselves (and its
323:             *   attributes, if it is an <code>Element</code>).
324:             * @return If the nodes, and possibly subtrees are equal,
325:             *   <code>true</code> otherwise <code>false</code>.
326:             * @since DOM Level 3
327:             */
328:            public boolean isEqualNode(Node arg) {
329:                if (arg == this ) {
330:                    return true;
331:                }
332:                if (arg.getNodeType() != getNodeType()) {
333:                    return false;
334:                }
335:                // in theory nodeName can't be null but better be careful
336:                // who knows what other implementations may be doing?...
337:                if (getNodeName() == null) {
338:                    if (arg.getNodeName() != null) {
339:                        return false;
340:                    }
341:                } else if (!getNodeName().equals(arg.getNodeName())) {
342:                    return false;
343:                }
344:
345:                if (getLocalName() == null) {
346:                    if (arg.getLocalName() != null) {
347:                        return false;
348:                    }
349:                } else if (!getLocalName().equals(arg.getLocalName())) {
350:                    return false;
351:                }
352:
353:                if (getNamespaceURI() == null) {
354:                    if (arg.getNamespaceURI() != null) {
355:                        return false;
356:                    }
357:                } else if (!getNamespaceURI().equals(arg.getNamespaceURI())) {
358:                    return false;
359:                }
360:
361:                if (getPrefix() == null) {
362:                    if (arg.getPrefix() != null) {
363:                        return false;
364:                    }
365:                } else if (!getPrefix().equals(arg.getPrefix())) {
366:                    return false;
367:                }
368:
369:                if (getNodeValue() == null) {
370:                    if (arg.getNodeValue() != null) {
371:                        return false;
372:                    }
373:                } else if (!getNodeValue().equals(arg.getNodeValue())) {
374:                    return false;
375:                }
376:                /*
377:                    if (getBaseURI() == null) {
378:                        if (((NodeImpl) arg).getBaseURI() != null) {
379:                            return false;
380:                        }
381:                    }
382:                    else if (!getBaseURI().equals(((NodeImpl) arg).getBaseURI())) {
383:                        return false;
384:                    }
385:                 */
386:
387:                return true;
388:            }
389:
390:            /**
391:             * DOM Level 3 - Experimental:
392:             * Look up the namespace URI associated to the given prefix, starting from this node.
393:             * Use lookupNamespaceURI(null) to lookup the default namespace
394:             *
395:             * @param namespaceURI
396:             * @return th URI for the namespace
397:             * @since DOM Level 3
398:             */
399:            public String lookupNamespaceURI(String specifiedPrefix) {
400:                short type = this .getNodeType();
401:                switch (type) {
402:                case Node.ELEMENT_NODE: {
403:
404:                    String namespace = this .getNamespaceURI();
405:                    String prefix = this .getPrefix();
406:                    if (namespace != null) {
407:                        // REVISIT: is it possible that prefix is empty string?
408:                        if (specifiedPrefix == null
409:                                && prefix == specifiedPrefix) {
410:                            // looking for default namespace
411:                            return namespace;
412:                        } else if (prefix != null
413:                                && prefix.equals(specifiedPrefix)) {
414:                            // non default namespace
415:                            return namespace;
416:                        }
417:                    }
418:                    if (this .hasAttributes()) {
419:                        NamedNodeMap map = this .getAttributes();
420:                        int length = map.getLength();
421:                        for (int i = 0; i < length; i++) {
422:                            Node attr = map.item(i);
423:                            String attrPrefix = attr.getPrefix();
424:                            String value = attr.getNodeValue();
425:                            namespace = attr.getNamespaceURI();
426:                            if (namespace != null
427:                                    && namespace
428:                                            .equals("http://www.w3.org/2000/xmlns/")) {
429:                                // at this point we are dealing with DOM Level 2 nodes only
430:                                if (specifiedPrefix == null
431:                                        && attr.getNodeName().equals("xmlns")) {
432:                                    // default namespace
433:                                    return value;
434:                                } else if (attrPrefix != null
435:                                        && attrPrefix.equals("xmlns")
436:                                        && attr.getLocalName().equals(
437:                                                specifiedPrefix)) {
438:                                    // non default namespace
439:                                    return value;
440:                                }
441:                            }
442:                        }
443:                    }
444:                    /*
445:                            NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
446:                            if (ancestor != null) {
447:                                return ancestor.lookupNamespaceURI(specifiedPrefix);
448:                            }
449:                     */
450:
451:                    return null;
452:
453:                }
454:                    /*
455:                     case Node.DOCUMENT_NODE : {
456:                     return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ;
457:                     }
458:                     */
459:                case Node.ENTITY_NODE:
460:                case Node.NOTATION_NODE:
461:                case Node.DOCUMENT_FRAGMENT_NODE:
462:                case Node.DOCUMENT_TYPE_NODE:
463:                    // type is unknown
464:                    return null;
465:                case Node.ATTRIBUTE_NODE: {
466:                    if (this .getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
467:                        return getOwnerElement().lookupNamespaceURI(
468:                                specifiedPrefix);
469:
470:                    }
471:                    return null;
472:                }
473:                default: {
474:                    /*
475:                             NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
476:                             if (ancestor != null) {
477:                                 return ancestor.lookupNamespaceURI(specifiedPrefix);
478:                             }
479:                     */
480:                    return null;
481:                }
482:
483:                }
484:            }
485:
486:            /**
487:             *  DOM Level 3: Experimental
488:             *  This method checks if the specified <code>namespaceURI</code> is the
489:             *  default namespace or not.
490:             *  @param namespaceURI The namespace URI to look for.
491:             *  @return  <code>true</code> if the specified <code>namespaceURI</code>
492:             *   is the default namespace, <code>false</code> otherwise.
493:             * @since DOM Level 3
494:             */
495:            public boolean isDefaultNamespace(String namespaceURI) {
496:                /*
497:                 // REVISIT: remove casts when DOM L3 becomes REC.
498:                 short type = this.getNodeType();
499:                 switch (type) {
500:                 case Node.ELEMENT_NODE: {
501:                     String namespace = this.getNamespaceURI();
502:                     String prefix = this.getPrefix();
503:
504:                     // REVISIT: is it possible that prefix is empty string?
505:                     if (prefix == null || prefix.length() == 0) {
506:                         if (namespaceURI == null) {
507:                             return (namespace == namespaceURI);
508:                         }
509:                         return namespaceURI.equals(namespace);
510:                     }
511:                     if (this.hasAttributes()) {
512:                         ElementImpl elem = (ElementImpl)this;
513:                         NodeImpl attr = (NodeImpl)elem.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns");
514:                         if (attr != null) {
515:                             String value = attr.getNodeValue();
516:                             if (namespaceURI == null) {
517:                                 return (namespace == value);
518:                             }
519:                             return namespaceURI.equals(value);
520:                         }
521:                     }
522:
523:                     NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
524:                     if (ancestor != null) {
525:                         return ancestor.isDefaultNamespace(namespaceURI);
526:                     }
527:                     return false;
528:                 }
529:                 case Node.DOCUMENT_NODE:{
530:                         return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI);
531:                     }
532:
533:                 case Node.ENTITY_NODE :
534:                   case Node.NOTATION_NODE:
535:                 case Node.DOCUMENT_FRAGMENT_NODE:
536:                 case Node.DOCUMENT_TYPE_NODE:
537:                     // type is unknown
538:                     return false;
539:                 case Node.ATTRIBUTE_NODE:{
540:                         if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) {
541:                             return ownerNode.isDefaultNamespace(namespaceURI);
542:
543:                         }
544:                         return false;
545:                     }
546:                 default:{  
547:                         NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
548:                         if (ancestor != null) {
549:                             return ancestor.isDefaultNamespace(namespaceURI);
550:                         }
551:                         return false;
552:                     }
553:
554:                 }
555:                 */
556:                return false;
557:
558:            }
559:
560:            /**
561:             *
562:             * DOM Level 3 - Experimental:
563:             * Look up the prefix associated to the given namespace URI, starting from this node.
564:             *
565:             * @param namespaceURI
566:             * @return the prefix for the namespace
567:             */
568:            public String lookupPrefix(String namespaceURI) {
569:
570:                // REVISIT: When Namespaces 1.1 comes out this may not be true
571:                // Prefix can't be bound to null namespace
572:                if (namespaceURI == null) {
573:                    return null;
574:                }
575:
576:                short type = this .getNodeType();
577:
578:                switch (type) {
579:                /*
580:                 case Node.ELEMENT_NODE: {
581:
582:                 String namespace = this.getNamespaceURI(); // to flip out children
583:                 return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
584:                 }
585:
586:                 case Node.DOCUMENT_NODE:{
587:                 return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
588:                 }
589:                 */
590:                case Node.ENTITY_NODE:
591:                case Node.NOTATION_NODE:
592:                case Node.DOCUMENT_FRAGMENT_NODE:
593:                case Node.DOCUMENT_TYPE_NODE:
594:                    // type is unknown
595:                    return null;
596:                case Node.ATTRIBUTE_NODE: {
597:                    if (this .getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
598:                        return getOwnerElement().lookupPrefix(namespaceURI);
599:
600:                    }
601:                    return null;
602:                }
603:                default: {
604:                    /*
605:                     NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
606:                     if (ancestor != null) {
607:                     return ancestor.lookupPrefix(namespaceURI);
608:                     }
609:                     */
610:                    return null;
611:                }
612:                }
613:            }
614:
615:            /**
616:             * Returns whether this node is the same node as the given one.
617:             * <br>This method provides a way to determine whether two
618:             * <code>Node</code> references returned by the implementation reference
619:             * the same object. When two <code>Node</code> references are references
620:             * to the same object, even if through a proxy, the references may be
621:             * used completely interchangably, such that all attributes have the
622:             * same values and calling the same DOM method on either reference
623:             * always has exactly the same effect.
624:             * @param other The node to test against.
625:             * @return Returns <code>true</code> if the nodes are the same,
626:             *   <code>false</code> otherwise.
627:             * @since DOM Level 3
628:             */
629:            public boolean isSameNode(Node other) {
630:                // we do not use any wrapper so the answer is obvious
631:                return this  == other;
632:            }
633:
634:            /**
635:             * This attribute returns the text content of this node and its
636:             * descendants. When it is defined to be null, setting it has no effect.
637:             * When set, any possible children this node may have are removed and
638:             * replaced by a single <code>Text</code> node containing the string
639:             * this attribute is set to. On getting, no serialization is performed,
640:             * the returned string does not contain any markup. No whitespace
641:             * normalization is performed, the returned string does not contain the
642:             * element content whitespaces . Similarly, on setting, no parsing is
643:             * performed either, the input string is taken as pure textual content.
644:             * <br>The string returned is made of the text content of this node
645:             * depending on its type, as defined below:
646:             * <table border='1'>
647:             * <tr>
648:             * <th>Node type</th>
649:             * <th>Content</th>
650:             * </tr>
651:             * <tr>
652:             * <td valign='top' rowspan='1' colspan='1'>
653:             * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
654:             * DOCUMENT_FRAGMENT_NODE</td>
655:             * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
656:             * attribute value of every child node, excluding COMMENT_NODE and
657:             * PROCESSING_INSTRUCTION_NODE nodes</td>
658:             * </tr>
659:             * <tr>
660:             * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
661:             * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
662:             * <td valign='top' rowspan='1' colspan='1'>
663:             * <code>nodeValue</code></td>
664:             * </tr>
665:             * <tr>
666:             * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
667:             * <td valign='top' rowspan='1' colspan='1'>
668:             * null</td>
669:             * </tr>
670:             * </table>
671:             * @exception DOMException
672:             *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
673:             * @exception DOMException
674:             *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than
675:             *   fit in a <code>DOMString</code> variable on the implementation
676:             *   platform.
677:             * @since DOM Level 3
678:             */
679:            public void setTextContent(String textContent) throws DOMException {
680:                setNodeValue(textContent);
681:            }
682:
683:            /**
684:             * This attribute returns the text content of this node and its
685:             * descendants. When it is defined to be null, setting it has no effect.
686:             * When set, any possible children this node may have are removed and
687:             * replaced by a single <code>Text</code> node containing the string
688:             * this attribute is set to. On getting, no serialization is performed,
689:             * the returned string does not contain any markup. No whitespace
690:             * normalization is performed, the returned string does not contain the
691:             * element content whitespaces . Similarly, on setting, no parsing is
692:             * performed either, the input string is taken as pure textual content.
693:             * <br>The string returned is made of the text content of this node
694:             * depending on its type, as defined below:
695:             * <table border='1'>
696:             * <tr>
697:             * <th>Node type</th>
698:             * <th>Content</th>
699:             * </tr>
700:             * <tr>
701:             * <td valign='top' rowspan='1' colspan='1'>
702:             * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
703:             * DOCUMENT_FRAGMENT_NODE</td>
704:             * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
705:             * attribute value of every child node, excluding COMMENT_NODE and
706:             * PROCESSING_INSTRUCTION_NODE nodes</td>
707:             * </tr>
708:             * <tr>
709:             * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
710:             * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
711:             * <td valign='top' rowspan='1' colspan='1'>
712:             * <code>nodeValue</code></td>
713:             * </tr>
714:             * <tr>
715:             * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
716:             * <td valign='top' rowspan='1' colspan='1'>
717:             * null</td>
718:             * </tr>
719:             * </table>
720:             * @exception DOMException
721:             *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
722:             * @exception DOMException
723:             *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than
724:             *   fit in a <code>DOMString</code> variable on the implementation
725:             *   platform.
726:             * @since DOM Level 3
727:             */
728:            public String getTextContent() throws DOMException {
729:                return getNodeValue(); // overriden in some subclasses
730:            }
731:
732:            /**
733:             * Compares a node with this node with regard to their position in the
734:             * document.
735:             * @param other The node to compare against this node.
736:             * @return Returns how the given node is positioned relatively to this
737:             *   node.
738:             * @since DOM Level 3
739:             */
740:            public short compareDocumentPosition(Node other)
741:                    throws DOMException {
742:                return 0;
743:            }
744:
745:            /**
746:             * The absolute base URI of this node or <code>null</code> if undefined.
747:             * This value is computed according to . However, when the
748:             * <code>Document</code> supports the feature "HTML" , the base URI is
749:             * computed using first the value of the href attribute of the HTML BASE
750:             * element if any, and the value of the <code>documentURI</code>
751:             * attribute from the <code>Document</code> interface otherwise.
752:             * <br> When the node is an <code>Element</code>, a <code>Document</code>
753:             * or a a <code>ProcessingInstruction</code>, this attribute represents
754:             * the properties [base URI] defined in . When the node is a
755:             * <code>Notation</code>, an <code>Entity</code>, or an
756:             * <code>EntityReference</code>, this attribute represents the
757:             * properties [declaration base URI] in the . How will this be affected
758:             * by resolution of relative namespace URIs issue?It's not.Should this
759:             * only be on Document, Element, ProcessingInstruction, Entity, and
760:             * Notation nodes, according to the infoset? If not, what is it equal to
761:             * on other nodes? Null? An empty string? I think it should be the
762:             * parent's.No.Should this be read-only and computed or and actual
763:             * read-write attribute?Read-only and computed (F2F 19 Jun 2000 and
764:             * teleconference 30 May 2001).If the base HTML element is not yet
765:             * attached to a document, does the insert change the Document.baseURI?
766:             * Yes. (F2F 26 Sep 2001)
767:             * @since DOM Level 3
768:             */
769:            public String getBaseURI() {
770:                return null;
771:            }
772:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.