Source Code Cross Referenced for DefaultContext.java in  » IDE-Netbeans » xml » org » netbeans » modules » xml » text » completion » 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 » IDE Netbeans » xml » org.netbeans.modules.xml.text.completion 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.xml.text.completion;
043:
044:        import org.w3c.dom.*;
045:
046:        import org.netbeans.modules.xml.api.model.*;
047:        import org.netbeans.modules.xml.spi.dom.*;
048:
049:        /**
050:         * Mutable delegator to passed <code>HintContext</code> delegee.
051:         * Can be reinitialized to avoid extra memory allocation by init
052:         * methods.
053:         *
054:         * @author  Petr Kuzel
055:         */
056:        class DefaultContext implements  HintContext, Attr, Element {
057:
058:            private Node peer;
059:            private String text;
060:
061:            // virtual context has links to surrounding world
062:            private Node parent, previous, next;
063:            private boolean virtual;
064:            private short type;
065:
066:            /** 
067:             * Creates new DefaultContext. 
068:             * User MUST call <code>init</code> prior any further operation.
069:             */
070:            public DefaultContext() {
071:            }
072:
073:            /**
074:             * Turn ordinary node into a virtual one returning from its hiearchy calls:
075:             * <ul>
076:             * <li>getParentNode() - parent
077:             * <li>getPreviousSibling() - previous node
078:             * <li>getNextSibling() - next node
079:             * </ul>
080:             */
081:            public void initVirtualElement(Node parent, Node previous, Node next) {
082:                this .parent = parent;
083:                this .previous = previous;
084:                this .next = next;
085:                this .type = Node.ELEMENT_NODE;
086:                virtual = true;
087:                this .peer = parent; // Not correct, but better than not setting it
088:            }
089:
090:            /**
091:             * Turn ordinary node into a virtual one returning from its hiearchy calls:
092:             * <ul>
093:             * <li>getOwnerElement() - parent
094:             * <li>getName(), getNodeName() - text
095:             * </ul>
096:             */
097:            public void initVirtualAttr(Element parent, String text) {
098:                this .parent = parent;
099:                this .next = null;
100:                this .previous = null;
101:                this .text = text;
102:                this .type = Node.ATTRIBUTE_NODE;
103:                virtual = true;
104:                this .peer = parent; // Not correct, but better than not setting it
105:            }
106:
107:            /**
108:             * Init ordinary node.
109:             * @param node DOM node, must not be <code>null</code>
110:             * @param preText hint known prefix
111:             */
112:            public void init(Node node, String preText) {
113:                peer = node;
114:                text = preText;
115:                virtual = false;
116:                //        System.err.println("DUMP:" + dump());
117:            }
118:
119:            public boolean isInitialized() {
120:                return peer != null;
121:            }
122:
123:            String dump() {
124:                Node parent = getParentNode();
125:                if (parent != null) {
126:
127:                    String name = parent.getNodeName();
128:
129:                    // index of place we are inserted to
130:
131:                    int index = 0;
132:
133:                    Node sibling = null;
134:
135:                    // find previous ELEMENT sibling
136:
137:                    sibling = this ;
138:                    do {
139:                        sibling = sibling.getPreviousSibling();
140:                        if (sibling == null)
141:                            break;
142:                        if (sibling.getNodeType() == Node.ELEMENT_NODE)
143:                            break;
144:                    } while (true);
145:
146:                    while (sibling != null) {
147:
148:                        index++;
149:
150:                        // find previous ELEMENT sibling
151:
152:                        do {
153:                            sibling = sibling.getPreviousSibling();
154:                            if (sibling == null)
155:                                break;
156:                            if (sibling.getNodeType() == Node.ELEMENT_NODE)
157:                                break;
158:                        } while (true);
159:
160:                    }
161:
162:                    // all children
163:
164:                    String names = "";
165:                    NodeList kids = parent.getChildNodes();
166:
167:                    if (kids == null) {
168:                        return "X missing kids";
169:                    }
170:                    for (int i = 0; i < kids.getLength(); i++) {
171:                        Node next = kids.item(i);
172:                        if (next.getNodeType() == Node.ELEMENT_NODE) {
173:                            names += next.getNodeName() + ", ";
174:                        }
175:                    }
176:
177:                    // this is context needed by Sandeep's Liasion
178:                    return "DefaultContext: parent: " + name + " p'kids: "
179:                            + names + " index: " + index;
180:
181:                } else {
182:                    return "X missing parent";
183:                }
184:
185:            }
186:
187:            /**
188:             * The name of this node, depending on its type; see the table above.
189:             */
190:            public String getNodeName() {
191:                return peer.getNodeName();
192:            }
193:
194:            /**
195:             * Tests whether the DOM implementation implements a specific feature and
196:             * that feature is supported by this node.
197:             * @param featureThe name of the feature to test. This is the same name
198:             *  which can be passed to the method <code>hasFeature</code> on
199:             *  <code>DOMImplementation</code>.
200:             * @param versionThis is the version number of the feature to test. In
201:             *  Level 2, version 1, this is the string "2.0". If the version is not
202:             *  specified, supporting any version of the feature will cause the
203:             *  method to return <code>true</code>.
204:             * @return Returns <code>true</code> if the specified feature is
205:             *  supported on this node, <code>false</code> otherwise.
206:             * @since DOM Level 2
207:             */
208:            public boolean isSupported(String feature, String version) {
209:                throw new UOException();
210:            }
211:
212:            public void setPrefix(String prefix) throws DOMException {
213:                throw new UOException();
214:            }
215:
216:            /**
217:             * The namespace prefix of this node, or <code>null</code> if it is
218:             * unspecified.
219:             * <br>Note that setting this attribute, when permitted, changes the
220:             * <code>nodeName</code> attribute, which holds the qualified name, as
221:             * well as the <code>tagName</code> and <code>name</code> attributes of
222:             * the <code>Element</code> and <code>Attr</code> interfaces, when
223:             * applicable.
224:             * <br>Note also that changing the prefix of an attribute that is known to
225:             * have a default value, does not make a new attribute with the default
226:             * value and the original prefix appear, since the
227:             * <code>namespaceURI</code> and <code>localName</code> do not change.
228:             * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
229:             * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
230:             * method, such as <code>createElement</code> from the
231:             * <code>Document</code> interface, this is always <code>null</code>.
232:             * @exception DOMException
233:             *  INVALID_CHARACTER_ERR: Raised if the specified prefix contains an
234:             *  illegal character.
235:             *  <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
236:             *  <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is
237:             *  malformed, if the <code>namespaceURI</code> of this node is
238:             *  <code>null</code>, if the specified prefix is "xml" and the
239:             *  <code>namespaceURI</code> of this node is different from "
240:             *  http://www.w3.org/XML/1998/namespace", if this node is an attribute
241:             *  and the specified prefix is "xmlns" and the
242:             *  <code>namespaceURI</code> of this node is different from "
243:             *  http://www.w3.org/2000/xmlns/", or if this node is an attribute and
244:             *  the <code>qualifiedName</code> of this node is "xmlns" .
245:             * @since DOM Level 2
246:             */
247:            public String getPrefix() {
248:                throw new UOException();
249:            }
250:
251:            /**
252:             * The node immediately preceding this node. If there is no such node,
253:             * this returns <code>null</code>.
254:             */
255:            public Node getPreviousSibling() {
256:                if (virtual) {
257:                    return previous;
258:                } else {
259:                    return peer.getPreviousSibling();
260:                }
261:            }
262:
263:            /**
264:             * A code representing the type of the underlying object, as defined above.
265:             */
266:            public short getNodeType() {
267:                if (virtual)
268:                    return type;
269:                return peer.getNodeType();
270:            }
271:
272:            /**
273:             * The <code>Document</code> object associated with this node. This is
274:             * also the <code>Document</code> object used to create new nodes. When
275:             * this node is a <code>Document</code> or a <code>DocumentType</code>
276:             * which is not used with any <code>Document</code> yet, this is
277:             * <code>null</code>.
278:             * @version DOM Level 2
279:             */
280:            public Document getOwnerDocument() {
281:                return peer.getOwnerDocument();
282:            }
283:
284:            /**
285:             * Replaces the child node <code>oldChild</code> with <code>newChild</code>
286:             * in the list of children, and returns the <code>oldChild</code> node.
287:             * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
288:             * <code>oldChild</code> is replaced by all of the
289:             * <code>DocumentFragment</code> children, which are inserted in the
290:             * same order. If the <code>newChild</code> is already in the tree, it
291:             * is first removed.
292:             * @param newChildThe new node to put in the child list.
293:             * @param oldChildThe node being replaced in the list.
294:             * @return The node replaced.
295:             * @exception DOMException
296:             *  HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
297:             *  allow children of the type of the <code>newChild</code> node, or if
298:             *  the node to put in is one of this node's ancestors.
299:             *  <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
300:             *  from a different document than the one that created this node.
301:             *  <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of
302:             *  the new node is readonly.
303:             *  <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
304:             *  this node.
305:             */
306:            public Node replaceChild(Node newChild, Node oldChild)
307:                    throws DOMException {
308:                return peer.replaceChild(newChild, oldChild);
309:            }
310:
311:            /**
312:             * @return String representing prefix as entered by user that can be used for refining results
313:             */
314:            public String getCurrentPrefix() {
315:                return text;
316:            }
317:
318:            /**
319:             * Returns a duplicate of this node, i.e., serves as a generic copy
320:             * constructor for nodes. The duplicate node has no parent; (
321:             * <code>parentNode</code> is <code>null</code>.).
322:             * <br>Cloning an <code>Element</code> copies all attributes and their
323:             * values, including those generated by the XML processor to represent
324:             * defaulted attributes, but this method does not copy any text it
325:             * contains unless it is a deep clone, since the text is contained in a
326:             * child <code>Text</code> node. Cloning an <code>Attribute</code>
327:             * directly, as opposed to be cloned as part of an <code>Element</code>
328:             * cloning operation, returns a specified attribute (
329:             * <code>specified</code> is <code>true</code>). Cloning any other type
330:             * of node simply returns a copy of this node.
331:             * <br>Note that cloning an immutable subtree results in a mutable copy,
332:             * but the children of an <code>EntityReference</code> clone are readonly
333:             * . In addition, clones of unspecified <code>Attr</code> nodes are
334:             * specified. And, cloning <code>Document</code>,
335:             * <code>DocumentType</code>, <code>Entity</code>, and
336:             * <code>Notation</code> nodes is implementation dependent.
337:             * @param deepIf <code>true</code>, recursively clone the subtree under
338:             *  the specified node; if <code>false</code>, clone only the node
339:             *  itself (and its attributes, if it is an <code>Element</code>).
340:             * @return The duplicate node.
341:             */
342:            public Node cloneNode(boolean deep) {
343:                return peer.cloneNode(deep);
344:            }
345:
346:            /**
347:             * The node immediately following this node. If there is no such node,
348:             * this returns <code>null</code>.
349:             */
350:            public Node getNextSibling() {
351:                if (virtual) {
352:                    return next;
353:                } else {
354:                    return peer.getNextSibling();
355:                }
356:            }
357:
358:            /**
359:             * Inserts the node <code>newChild</code> before the existing child node
360:             * <code>refChild</code>. If <code>refChild</code> is <code>null</code>,
361:             * insert <code>newChild</code> at the end of the list of children.
362:             * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
363:             * all of its children are inserted, in the same order, before
364:             * <code>refChild</code>. If the <code>newChild</code> is already in the
365:             * tree, it is first removed.
366:             * @param newChildThe node to insert.
367:             * @param refChildThe reference node, i.e., the node before which the new
368:             *  node must be inserted.
369:             * @return The node being inserted.
370:             * @exception DOMException
371:             *  HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
372:             *  allow children of the type of the <code>newChild</code> node, or if
373:             *  the node to insert is one of this node's ancestors.
374:             *  <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
375:             *  from a different document than the one that created this node.
376:             *  <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or
377:             *  if the parent of the node being inserted is readonly.
378:             *  <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of
379:             *  this node.
380:             */
381:            public Node insertBefore(Node newChild, Node refChild)
382:                    throws DOMException {
383:                return peer.insertBefore(newChild, refChild);
384:            }
385:
386:            /**
387:             * The namespace URI of this node, or <code>null</code> if it is
388:             * unspecified.
389:             * <br>This is not a computed value that is the result of a namespace
390:             * lookup based on an examination of the namespace declarations in
391:             * scope. It is merely the namespace URI given at creation time.
392:             * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
393:             * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
394:             * method, such as <code>createElement</code> from the
395:             * <code>Document</code> interface, this is always <code>null</code>.Per
396:             * the Namespaces in XML Specification  an attribute does not inherit
397:             * its namespace from the element it is attached to. If an attribute is
398:             * not explicitly given a namespace, it simply has no namespace.
399:             * @since DOM Level 2
400:             */
401:            public String getNamespaceURI() {
402:                throw new UOException();
403:            }
404:
405:            /**
406:             * A <code>NamedNodeMap</code> containing the attributes of this node (if
407:             * it is an <code>Element</code>) or <code>null</code> otherwise.
408:             */
409:            public NamedNodeMap getAttributes() {
410:                return peer.getAttributes();
411:            }
412:
413:            /**
414:             * A <code>NodeList</code> that contains all children of this node. If
415:             * there are no children, this is a <code>NodeList</code> containing no
416:             * nodes.
417:             */
418:            public NodeList getChildNodes() {
419:                return peer.getChildNodes();
420:            }
421:
422:            /**
423:             * The value of this node, depending on its type; see the table above.
424:             * When it is defined to be <code>null</code>, setting it has no effect.
425:             * @exception DOMException
426:             *  NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
427:             * @exception DOMException
428:             *  DOMSTRING_SIZE_ERR: Raised when it would return more characters than
429:             *  fit in a <code>DOMString</code> variable on the implementation
430:             *  platform.
431:             */
432:            public String getNodeValue() throws DOMException {
433:                return peer.getNodeValue();
434:            }
435:
436:            /**
437:             * Adds the node <code>newChild</code> to the end of the list of children
438:             * of this node. If the <code>newChild</code> is already in the tree, it
439:             * is first removed.
440:             * @param newChildThe node to add.If it is a <code>DocumentFragment</code>
441:             *   object, the entire contents of the document fragment are moved
442:             *  into the child list of this node
443:             * @return The node added.
444:             * @exception DOMException
445:             *  HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
446:             *  allow children of the type of the <code>newChild</code> node, or if
447:             *  the node to append is one of this node's ancestors.
448:             *  <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
449:             *  from a different document than the one that created this node.
450:             *  <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
451:             */
452:            public Node appendChild(Node newChild) throws DOMException {
453:                return peer.appendChild(newChild);
454:            }
455:
456:            /**
457:             * Returns the local part of the qualified name of this node.
458:             * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
459:             * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
460:             * method, such as <code>createElement</code> from the
461:             * <code>Document</code> interface, this is always <code>null</code>.
462:             * @since DOM Level 2
463:             */
464:            public String getLocalName() {
465:                throw new UOException();
466:            }
467:
468:            /**
469:             * The parent of this node. All nodes, except <code>Attr</code>,
470:             * <code>Document</code>, <code>DocumentFragment</code>,
471:             * <code>Entity</code>, and <code>Notation</code> may have a parent.
472:             * However, if a node has just been created and not yet added to the
473:             * tree, or if it has been removed from the tree, this is
474:             * <code>null</code>.
475:             */
476:            public Node getParentNode() {
477:                if (virtual) {
478:                    return parent;
479:                } else {
480:                    return peer.getParentNode();
481:                }
482:            }
483:
484:            public void setNodeValue(String nodeValue) throws DOMException {
485:                peer.setNodeValue(nodeValue);
486:            }
487:
488:            /**
489:             * The last child of this node. If there is no such node, this returns
490:             * <code>null</code>.
491:             */
492:            public Node getLastChild() {
493:                return peer.getLastChild();
494:            }
495:
496:            /**
497:             * Returns whether this node (if it is an element) has any attributes.
498:             * @return <code>true</code> if this node has any attributes,
499:             *  <code>false</code> otherwise.
500:             * @since DOM Level 2
501:             */
502:            public boolean hasAttributes() {
503:                throw new UOException();
504:            }
505:
506:            /**
507:             * Puts all <code>Text</code> nodes in the full depth of the sub-tree
508:             * underneath this <code>Node</code>, including attribute nodes, into a
509:             * "normal" form where only structure (e.g., elements, comments,
510:             * processing instructions, CDATA sections, and entity references)
511:             * separates <code>Text</code> nodes, i.e., there are neither adjacent
512:             * <code>Text</code> nodes nor empty <code>Text</code> nodes. This can
513:             * be used to ensure that the DOM view of a document is the same as if
514:             * it were saved and re-loaded, and is useful when operations (such as
515:             * XPointer  lookups) that depend on a particular document tree
516:             * structure are to be used.In cases where the document contains
517:             * <code>CDATASections</code>, the normalize operation alone may not be
518:             * sufficient, since XPointers do not differentiate between
519:             * <code>Text</code> nodes and <code>CDATASection</code> nodes.
520:             * @version DOM Level 2
521:             */
522:            public void normalize() {
523:                peer.normalize();
524:            }
525:
526:            /**
527:             * Removes the child node indicated by <code>oldChild</code> from the list
528:             * of children, and returns it.
529:             * @param oldChildThe node being removed.
530:             * @return The node removed.
531:             * @exception DOMException
532:             *  NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
533:             *  <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
534:             *  this node.
535:             */
536:            public Node removeChild(Node oldChild) throws DOMException {
537:                return peer.removeChild(oldChild);
538:            }
539:
540:            /**
541:             * Returns whether this node has any children.
542:             * @return  <code>true</code> if this node has any children,
543:             *  <code>false</code> otherwise.
544:             */
545:            public boolean hasChildNodes() {
546:                return peer.hasChildNodes();
547:            }
548:
549:            /**
550:             * The first child of this node. If there is no such node, this returns
551:             * <code>null</code>.
552:             */
553:            public Node getFirstChild() {
554:                return peer.getFirstChild();
555:            }
556:
557:            public String toString() {
558:                return "context node(" + getNodeName() + ", prefix("
559:                        + getCurrentPrefix() + "))";
560:            }
561:
562:            // Attr implementation  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
563:
564:            public boolean getSpecified() {
565:                if (peer instanceof  Attr) {
566:                    return ((Attr) peer).getSpecified();
567:                } else {
568:                    throw new NOA();
569:                }
570:            }
571:
572:            public String getName() {
573:                if (virtual)
574:                    return text;
575:                if (peer instanceof  Attr) {
576:                    return ((Attr) peer).getName();
577:                } else {
578:                    throw new NOA();
579:                }
580:            }
581:
582:            public Element getOwnerElement() {
583:                if (virtual)
584:                    return (Element) parent;
585:
586:                if (peer instanceof  Attr) {
587:                    return ((Attr) peer).getOwnerElement();
588:                } else {
589:                    throw new NOA();
590:                }
591:            }
592:
593:            public void setValue(String value) throws DOMException {
594:                if (peer instanceof  Attr) {
595:                    ((Attr) peer).setValue(value);
596:                } else {
597:                    throw new NOA();
598:                }
599:            }
600:
601:            public String getValue() {
602:                if (peer instanceof  Attr) {
603:                    return ((Attr) peer).getValue();
604:                } else {
605:                    throw new NOA();
606:                }
607:            }
608:
609:            public String getAttribute(String str) {
610:                if (peer instanceof  Element) {
611:                    return ((Element) peer).getAttribute(str);
612:                } else {
613:                    throw new NOE();
614:                }
615:            }
616:
617:            public String getAttributeNS(String str, String str1) {
618:                if (peer instanceof  Element) {
619:                    return ((Element) peer).getAttributeNS(str, str1);
620:                } else {
621:                    throw new NOE();
622:                }
623:            }
624:
625:            public org.w3c.dom.Attr getAttributeNode(String str) {
626:                if (peer instanceof  Element) {
627:                    return ((Element) peer).getAttributeNode(str);
628:                } else {
629:                    throw new NOE();
630:                }
631:            }
632:
633:            public org.w3c.dom.Attr getAttributeNodeNS(String str, String str1) {
634:                if (peer instanceof  Element) {
635:                    return ((Element) peer).getAttributeNodeNS(str, str1);
636:                } else {
637:                    throw new NOE();
638:                }
639:            }
640:
641:            public org.w3c.dom.NodeList getElementsByTagName(String str) {
642:                if (peer instanceof  Element) {
643:                    return ((Element) peer).getElementsByTagName(str);
644:                } else {
645:                    throw new NOE();
646:                }
647:            }
648:
649:            public org.w3c.dom.NodeList getElementsByTagNameNS(String str,
650:                    String str1) {
651:                if (peer instanceof  Element) {
652:                    return ((Element) peer).getElementsByTagNameNS(str, str1);
653:                } else {
654:                    throw new NOE();
655:                }
656:            }
657:
658:            public String getTagName() {
659:                if (peer instanceof  Element) {
660:                    return ((Element) peer).getTagName();
661:                } else {
662:                    throw new NOE();
663:                }
664:            }
665:
666:            public boolean hasAttribute(String str) {
667:                if (peer instanceof  Element) {
668:                    return ((Element) peer).hasAttribute(str);
669:                } else {
670:                    throw new NOE();
671:                }
672:            }
673:
674:            public boolean hasAttributeNS(String str, String str1) {
675:                if (peer instanceof  Element) {
676:                    return ((Element) peer).hasAttributeNS(str, str1);
677:                } else {
678:                    throw new NOE();
679:                }
680:            }
681:
682:            public void removeAttribute(String str)
683:                    throws org.w3c.dom.DOMException {
684:                if (peer instanceof  Element) {
685:                    ((Element) peer).removeAttribute(str);
686:                } else {
687:                    throw new NOE();
688:                }
689:            }
690:
691:            public void removeAttributeNS(String str, String str1)
692:                    throws org.w3c.dom.DOMException {
693:                if (peer instanceof  Element) {
694:                    ((Element) peer).removeAttributeNS(str, str1);
695:                } else {
696:                    throw new NOE();
697:                }
698:            }
699:
700:            public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr attr)
701:                    throws org.w3c.dom.DOMException {
702:                if (peer instanceof  Element) {
703:                    return ((Element) peer).removeAttributeNode(attr);
704:                } else {
705:                    throw new NOE();
706:                }
707:            }
708:
709:            public void setAttribute(String str, String str1)
710:                    throws org.w3c.dom.DOMException {
711:                if (peer instanceof  Element) {
712:                    ((Element) peer).setAttribute(str, str1);
713:                } else {
714:                    throw new NOE();
715:                }
716:            }
717:
718:            public void setAttributeNS(String str, String str1, String str2)
719:                    throws org.w3c.dom.DOMException {
720:                if (peer instanceof  Element) {
721:                    ((Element) peer).setAttributeNS(str, str1, str2);
722:                } else {
723:                    throw new NOE();
724:                }
725:            }
726:
727:            public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr attr)
728:                    throws org.w3c.dom.DOMException {
729:                if (peer instanceof  Element) {
730:                    return ((Element) peer).setAttributeNode(attr);
731:                } else {
732:                    throw new NOE();
733:                }
734:            }
735:
736:            public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr attr)
737:                    throws org.w3c.dom.DOMException {
738:                if (peer instanceof  Element) {
739:                    return ((Element) peer).setAttributeNodeNS(attr);
740:                } else {
741:                    throw new NOE();
742:                }
743:            }
744:
745:            //??? or could we throw class casts
746:            private class NOA extends DOMException {
747:
748:                private static final long serialVersionUID = 4600894053037825159L;
749:
750:                NOA() {
751:                    super (DOMException.NOT_SUPPORTED_ERR, "Peer " + peer
752:                            + " is not instance of Attr!");
753:                }
754:            }
755:
756:            private class NOE extends DOMException {
757:
758:                private static final long serialVersionUID = 4600894053037825159L;
759:
760:                NOE() {
761:                    super (DOMException.NOT_SUPPORTED_ERR, "Peer " + peer
762:                            + " is not instance of Element!");
763:                }
764:            }
765:
766:            //
767:            // Implementation of DOM Level 3 methods
768:            //
769:
770:            public short compareDocumentPosition(Node a) {
771:                throw new UOException();
772:            }
773:
774:            public String getBaseURI() {
775:                throw new UOException();
776:            }
777:
778:            public Object getFeature(String a, String b) {
779:                throw new UOException();
780:            }
781:
782:            public String getTextContent() {
783:                throw new UOException();
784:            }
785:
786:            public Object getUserData(String a) {
787:                throw new UOException();
788:            }
789:
790:            public boolean isDefaultNamespace(String a) {
791:                throw new UOException();
792:            }
793:
794:            public boolean isEqualNode(Node a) {
795:                throw new UOException();
796:            }
797:
798:            public boolean isSameNode(Node a) {
799:                throw new UOException();
800:            }
801:
802:            public String lookupNamespaceURI(String a) {
803:                throw new UOException();
804:            }
805:
806:            public String lookupPrefix(String a) {
807:                throw new UOException();
808:            }
809:
810:            public void setTextContent(String a) {
811:                throw new UOException();
812:            }
813:
814:            public Object setUserData(String a, Object b, UserDataHandler c) {
815:                throw new UOException();
816:            }
817:
818:            // Implementation of DOM Level 3 methods for Element
819:            public TypeInfo getSchemaTypeInfo() {
820:                throw new UOException();
821:            }
822:
823:            public void setIdAttribute(String a, boolean b) {
824:                throw new UOException();
825:            }
826:
827:            public void setIdAttributeNS(String a, String b, boolean c) {
828:                throw new UOException();
829:            }
830:
831:            public void setIdAttributeNode(Attr a, boolean b) {
832:                throw new UOException();
833:            }
834:
835:            // Implementation of DOM Level 3 methods for Attr 
836:
837:            public boolean isId() {
838:                throw new UOException();
839:            }
840:
841:            // Implementation of DOM Level 3 methods for Text
842:            public Text replaceWholeText(String a) {
843:                throw new UOException();
844:            }
845:
846:            public String getWholeText() {
847:                throw new UOException();
848:            }
849:
850:            public boolean isElementContentWhitespace() {
851:                throw new UOException();
852:            }
853:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.