KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > text > completion > DefaultContext


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.text.completion;
21
22 import org.w3c.dom.*;
23
24 import org.netbeans.modules.xml.api.model.*;
25 import org.netbeans.modules.xml.spi.dom.*;
26
27 /**
28  * Mutable delegator to passed <code>HintContext</code> delegee.
29  * Can be reinitialized to avoid extra memory allocation by init
30  * methods.
31  *
32  * @author Petr Kuzel
33  */

34 class DefaultContext implements HintContext, Attr, Element {
35
36     private Node peer;
37     private String JavaDoc text;
38
39     // virtual context has links to surrounding world
40
private Node parent, previous, next;
41     private boolean virtual;
42     private short type;
43     
44     /**
45      * Creates new DefaultContext.
46      * User MUST call <code>init</code> prior any further operation.
47      */

48     public DefaultContext() {
49     }
50
51     /**
52      * Turn ordinary node into a virtual one returning from its hiearchy calls:
53      * <ul>
54      * <li>getParentNode() - parent
55      * <li>getPreviousSibling() - previous node
56      * <li>getNextSibling() - next node
57      * </ul>
58      */

59     public void initVirtualElement(Node parent, Node previous, Node next) {
60         this.parent = parent;
61         this.previous = previous;
62         this.next = next;
63         this.type = Node.ELEMENT_NODE;
64         virtual = true;
65         this.peer = parent; // Not correct, but better than not setting it
66
}
67
68     /**
69      * Turn ordinary node into a virtual one returning from its hiearchy calls:
70      * <ul>
71      * <li>getOwnerElement() - parent
72      * <li>getName(), getNodeName() - text
73      * </ul>
74      */

75     public void initVirtualAttr(Element parent, String JavaDoc text) {
76         this.parent = parent;
77         this.next = null;
78         this.previous = null;
79         this.text = text;
80         this.type = Node.ATTRIBUTE_NODE;
81         virtual = true;
82         this.peer = parent; // Not correct, but better than not setting it
83
}
84     
85     /**
86      * Init ordinary node.
87      * @param node DOM node, must not be <code>null</code>
88      * @param preText hint known prefix
89      */

90     public void init(Node node, String JavaDoc preText) {
91         peer = node;
92         text = preText;
93         virtual = false;
94 // System.err.println("DUMP:" + dump());
95
}
96     
97     public boolean isInitialized() {
98         return peer != null;
99     }
100    
101     String JavaDoc dump() {
102         Node parent = getParentNode();
103         if (parent != null) {
104             
105             String JavaDoc name = parent.getNodeName();
106                         
107             // index of place we are inserted to
108

109             int index = 0;
110             
111             Node sibling = null;
112             
113             // find previous ELEMENT sibling
114

115             sibling = this;
116             do {
117                 sibling = sibling.getPreviousSibling();
118                 if (sibling == null) break;
119                 if (sibling.getNodeType() == Node.ELEMENT_NODE) break;
120             } while (true);
121                 
122             while (sibling != null) {
123
124                 index++;
125                 
126                 // find previous ELEMENT sibling
127

128                 do {
129                     sibling = sibling.getPreviousSibling();
130                     if (sibling == null) break;
131                     if (sibling.getNodeType() == Node.ELEMENT_NODE) break;
132                 } while (true);
133                 
134             }
135
136             // all children
137

138            String JavaDoc names = "";
139            NodeList kids = parent.getChildNodes();
140            
141            if (kids == null) {
142                return "X missing kids";
143            }
144            for (int i = 0; i < kids.getLength(); i++) {
145                Node next = kids.item(i);
146                if (next.getNodeType() == Node.ELEMENT_NODE) {
147                     names += next.getNodeName() + ", ";
148                }
149            }
150
151            // this is context needed by Sandeep's Liasion
152
return "DefaultContext: parent: " + name + " p'kids: " + names + " index: " + index;
153             
154         } else {
155             return "X missing parent";
156         }
157
158     }
159     
160     /**
161      * The name of this node, depending on its type; see the table above.
162      */

163     public String JavaDoc getNodeName() {
164         return peer.getNodeName();
165     }
166     
167     /**
168      * Tests whether the DOM implementation implements a specific feature and
169      * that feature is supported by this node.
170      * @param featureThe name of the feature to test. This is the same name
171      * which can be passed to the method <code>hasFeature</code> on
172      * <code>DOMImplementation</code>.
173      * @param versionThis is the version number of the feature to test. In
174      * Level 2, version 1, this is the string "2.0". If the version is not
175      * specified, supporting any version of the feature will cause the
176      * method to return <code>true</code>.
177      * @return Returns <code>true</code> if the specified feature is
178      * supported on this node, <code>false</code> otherwise.
179      * @since DOM Level 2
180      */

181     public boolean isSupported(String JavaDoc feature, String JavaDoc version) {
182         throw new UOException();
183     }
184     
185     public void setPrefix(String JavaDoc prefix) throws DOMException {
186         throw new UOException();
187     }
188     
189     /**
190      * The namespace prefix of this node, or <code>null</code> if it is
191      * unspecified.
192      * <br>Note that setting this attribute, when permitted, changes the
193      * <code>nodeName</code> attribute, which holds the qualified name, as
194      * well as the <code>tagName</code> and <code>name</code> attributes of
195      * the <code>Element</code> and <code>Attr</code> interfaces, when
196      * applicable.
197      * <br>Note also that changing the prefix of an attribute that is known to
198      * have a default value, does not make a new attribute with the default
199      * value and the original prefix appear, since the
200      * <code>namespaceURI</code> and <code>localName</code> do not change.
201      * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
202      * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
203      * method, such as <code>createElement</code> from the
204      * <code>Document</code> interface, this is always <code>null</code>.
205      * @exception DOMException
206      * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an
207      * illegal character.
208      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
209      * <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is
210      * malformed, if the <code>namespaceURI</code> of this node is
211      * <code>null</code>, if the specified prefix is "xml" and the
212      * <code>namespaceURI</code> of this node is different from "
213      * http://www.w3.org/XML/1998/namespace", if this node is an attribute
214      * and the specified prefix is "xmlns" and the
215      * <code>namespaceURI</code> of this node is different from "
216      * http://www.w3.org/2000/xmlns/", or if this node is an attribute and
217      * the <code>qualifiedName</code> of this node is "xmlns" .
218      * @since DOM Level 2
219      */

220     public String JavaDoc getPrefix() {
221         throw new UOException();
222     }
223     
224     /**
225      * The node immediately preceding this node. If there is no such node,
226      * this returns <code>null</code>.
227      */

228     public Node getPreviousSibling() {
229         if (virtual) {
230             return previous;
231         } else {
232             return peer.getPreviousSibling();
233         }
234     }
235     
236     /**
237      * A code representing the type of the underlying object, as defined above.
238      */

239     public short getNodeType() {
240         if (virtual) return type;
241         return peer.getNodeType();
242     }
243     
244     /**
245      * The <code>Document</code> object associated with this node. This is
246      * also the <code>Document</code> object used to create new nodes. When
247      * this node is a <code>Document</code> or a <code>DocumentType</code>
248      * which is not used with any <code>Document</code> yet, this is
249      * <code>null</code>.
250      * @version DOM Level 2
251      */

252     public Document getOwnerDocument() {
253         return peer.getOwnerDocument();
254     }
255     
256     /**
257      * Replaces the child node <code>oldChild</code> with <code>newChild</code>
258      * in the list of children, and returns the <code>oldChild</code> node.
259      * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
260      * <code>oldChild</code> is replaced by all of the
261      * <code>DocumentFragment</code> children, which are inserted in the
262      * same order. If the <code>newChild</code> is already in the tree, it
263      * is first removed.
264      * @param newChildThe new node to put in the child list.
265      * @param oldChildThe node being replaced in the list.
266      * @return The node replaced.
267      * @exception DOMException
268      * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
269      * allow children of the type of the <code>newChild</code> node, or if
270      * the node to put in is one of this node's ancestors.
271      * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
272      * from a different document than the one that created this node.
273      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of
274      * the new node is readonly.
275      * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
276      * this node.
277      */

278     public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
279         return peer.replaceChild(newChild, oldChild);
280     }
281     
282     /**
283      * @return String representing prefix as entered by user that can be used for refining results
284      */

285     public String JavaDoc getCurrentPrefix() {
286         return text;
287     }
288     
289     /**
290      * Returns a duplicate of this node, i.e., serves as a generic copy
291      * constructor for nodes. The duplicate node has no parent; (
292      * <code>parentNode</code> is <code>null</code>.).
293      * <br>Cloning an <code>Element</code> copies all attributes and their
294      * values, including those generated by the XML processor to represent
295      * defaulted attributes, but this method does not copy any text it
296      * contains unless it is a deep clone, since the text is contained in a
297      * child <code>Text</code> node. Cloning an <code>Attribute</code>
298      * directly, as opposed to be cloned as part of an <code>Element</code>
299      * cloning operation, returns a specified attribute (
300      * <code>specified</code> is <code>true</code>). Cloning any other type
301      * of node simply returns a copy of this node.
302      * <br>Note that cloning an immutable subtree results in a mutable copy,
303      * but the children of an <code>EntityReference</code> clone are readonly
304      * . In addition, clones of unspecified <code>Attr</code> nodes are
305      * specified. And, cloning <code>Document</code>,
306      * <code>DocumentType</code>, <code>Entity</code>, and
307      * <code>Notation</code> nodes is implementation dependent.
308      * @param deepIf <code>true</code>, recursively clone the subtree under
309      * the specified node; if <code>false</code>, clone only the node
310      * itself (and its attributes, if it is an <code>Element</code>).
311      * @return The duplicate node.
312      */

313     public Node cloneNode(boolean deep) {
314         return peer.cloneNode(deep);
315     }
316     
317     /**
318      * The node immediately following this node. If there is no such node,
319      * this returns <code>null</code>.
320      */

321     public Node getNextSibling() {
322         if (virtual) {
323             return next;
324         } else {
325             return peer.getNextSibling();
326         }
327     }
328     
329     /**
330      * Inserts the node <code>newChild</code> before the existing child node
331      * <code>refChild</code>. If <code>refChild</code> is <code>null</code>,
332      * insert <code>newChild</code> at the end of the list of children.
333      * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
334      * all of its children are inserted, in the same order, before
335      * <code>refChild</code>. If the <code>newChild</code> is already in the
336      * tree, it is first removed.
337      * @param newChildThe node to insert.
338      * @param refChildThe reference node, i.e., the node before which the new
339      * node must be inserted.
340      * @return The node being inserted.
341      * @exception DOMException
342      * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
343      * allow children of the type of the <code>newChild</code> node, or if
344      * the node to insert is one of this node's ancestors.
345      * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
346      * from a different document than the one that created this node.
347      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or
348      * if the parent of the node being inserted is readonly.
349      * <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of
350      * this node.
351      */

352     public Node insertBefore(Node newChild, Node refChild) throws DOMException {
353         return peer.insertBefore(newChild, refChild);
354     }
355     
356     /**
357      * The namespace URI of this node, or <code>null</code> if it is
358      * unspecified.
359      * <br>This is not a computed value that is the result of a namespace
360      * lookup based on an examination of the namespace declarations in
361      * scope. It is merely the namespace URI given at creation time.
362      * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
363      * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
364      * method, such as <code>createElement</code> from the
365      * <code>Document</code> interface, this is always <code>null</code>.Per
366      * the Namespaces in XML Specification an attribute does not inherit
367      * its namespace from the element it is attached to. If an attribute is
368      * not explicitly given a namespace, it simply has no namespace.
369      * @since DOM Level 2
370      */

371     public String JavaDoc getNamespaceURI() {
372         throw new UOException();
373     }
374     
375     /**
376      * A <code>NamedNodeMap</code> containing the attributes of this node (if
377      * it is an <code>Element</code>) or <code>null</code> otherwise.
378      */

379     public NamedNodeMap getAttributes() {
380         return peer.getAttributes();
381     }
382     
383     /**
384      * A <code>NodeList</code> that contains all children of this node. If
385      * there are no children, this is a <code>NodeList</code> containing no
386      * nodes.
387      */

388     public NodeList getChildNodes() {
389         return peer.getChildNodes();
390     }
391     
392     /**
393      * The value of this node, depending on its type; see the table above.
394      * When it is defined to be <code>null</code>, setting it has no effect.
395      * @exception DOMException
396      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
397      * @exception DOMException
398      * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
399      * fit in a <code>DOMString</code> variable on the implementation
400      * platform.
401      */

402     public String JavaDoc getNodeValue() throws DOMException {
403         return peer.getNodeValue();
404     }
405     
406     /**
407      * Adds the node <code>newChild</code> to the end of the list of children
408      * of this node. If the <code>newChild</code> is already in the tree, it
409      * is first removed.
410      * @param newChildThe node to add.If it is a <code>DocumentFragment</code>
411      * object, the entire contents of the document fragment are moved
412      * into the child list of this node
413      * @return The node added.
414      * @exception DOMException
415      * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
416      * allow children of the type of the <code>newChild</code> node, or if
417      * the node to append is one of this node's ancestors.
418      * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
419      * from a different document than the one that created this node.
420      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
421      */

422     public Node appendChild(Node newChild) throws DOMException {
423         return peer.appendChild(newChild);
424     }
425     
426     /**
427      * Returns the local part of the qualified name of this node.
428      * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
429      * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
430      * method, such as <code>createElement</code> from the
431      * <code>Document</code> interface, this is always <code>null</code>.
432      * @since DOM Level 2
433      */

434     public String JavaDoc getLocalName() {
435         throw new UOException();
436     }
437     
438     /**
439      * The parent of this node. All nodes, except <code>Attr</code>,
440      * <code>Document</code>, <code>DocumentFragment</code>,
441      * <code>Entity</code>, and <code>Notation</code> may have a parent.
442      * However, if a node has just been created and not yet added to the
443      * tree, or if it has been removed from the tree, this is
444      * <code>null</code>.
445      */

446     public Node getParentNode() {
447         if (virtual) {
448             return parent;
449         } else {
450             return peer.getParentNode();
451         }
452     }
453     
454     public void setNodeValue(String JavaDoc nodeValue) throws DOMException {
455         peer.setNodeValue(nodeValue);
456     }
457     
458     /**
459      * The last child of this node. If there is no such node, this returns
460      * <code>null</code>.
461      */

462     public Node getLastChild() {
463         return peer.getLastChild();
464     }
465     
466     /**
467      * Returns whether this node (if it is an element) has any attributes.
468      * @return <code>true</code> if this node has any attributes,
469      * <code>false</code> otherwise.
470      * @since DOM Level 2
471      */

472     public boolean hasAttributes() {
473         throw new UOException();
474     }
475     
476     /**
477      * Puts all <code>Text</code> nodes in the full depth of the sub-tree
478      * underneath this <code>Node</code>, including attribute nodes, into a
479      * "normal" form where only structure (e.g., elements, comments,
480      * processing instructions, CDATA sections, and entity references)
481      * separates <code>Text</code> nodes, i.e., there are neither adjacent
482      * <code>Text</code> nodes nor empty <code>Text</code> nodes. This can
483      * be used to ensure that the DOM view of a document is the same as if
484      * it were saved and re-loaded, and is useful when operations (such as
485      * XPointer lookups) that depend on a particular document tree
486      * structure are to be used.In cases where the document contains
487      * <code>CDATASections</code>, the normalize operation alone may not be
488      * sufficient, since XPointers do not differentiate between
489      * <code>Text</code> nodes and <code>CDATASection</code> nodes.
490      * @version DOM Level 2
491      */

492     public void normalize() {
493         peer.normalize();
494     }
495     
496     /**
497      * Removes the child node indicated by <code>oldChild</code> from the list
498      * of children, and returns it.
499      * @param oldChildThe node being removed.
500      * @return The node removed.
501      * @exception DOMException
502      * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
503      * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
504      * this node.
505      */

506     public Node removeChild(Node oldChild) throws DOMException {
507         return peer.removeChild(oldChild);
508     }
509     
510     /**
511      * Returns whether this node has any children.
512      * @return <code>true</code> if this node has any children,
513      * <code>false</code> otherwise.
514      */

515     public boolean hasChildNodes() {
516         return peer.hasChildNodes();
517     }
518     
519     /**
520      * The first child of this node. If there is no such node, this returns
521      * <code>null</code>.
522      */

523     public Node getFirstChild() {
524         return peer.getFirstChild();
525     }
526
527     
528     public String JavaDoc toString() {
529         return "context node(" + getNodeName() + ", prefix("+ getCurrentPrefix() + "))";
530     }
531     
532     // Attr implementation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
533

534     public boolean getSpecified() {
535         if (peer instanceof Attr) {
536             return ((Attr)peer).getSpecified();
537         } else {
538             throw new NOA();
539         }
540     }
541     
542     public String JavaDoc getName() {
543         if (virtual) return text;
544         if (peer instanceof Attr) {
545             return ((Attr)peer).getName();
546         } else {
547             throw new NOA();
548         }
549     }
550     
551     public Element getOwnerElement() {
552         if (virtual) return (Element) parent;
553         
554         if (peer instanceof Attr) {
555             return ((Attr)peer).getOwnerElement();
556         } else {
557             throw new NOA();
558         }
559     }
560     
561     public void setValue(String JavaDoc value) throws DOMException {
562         if (peer instanceof Attr) {
563             ((Attr)peer).setValue(value);
564         } else {
565             throw new NOA();
566         }
567     }
568     
569     public String JavaDoc getValue() {
570         if (peer instanceof Attr) {
571             return ((Attr)peer).getValue();
572         } else {
573             throw new NOA();
574         }
575     }
576     
577     public String JavaDoc getAttribute(String JavaDoc str) {
578         if (peer instanceof Element) {
579             return ((Element)peer).getAttribute(str);
580         } else {
581             throw new NOE();
582         }
583     }
584     
585     public String JavaDoc getAttributeNS(String JavaDoc str, String JavaDoc str1) {
586         if (peer instanceof Element) {
587             return ((Element)peer).getAttributeNS(str, str1);
588         } else {
589             throw new NOE();
590         }
591     }
592     
593     public org.w3c.dom.Attr JavaDoc getAttributeNode(String JavaDoc str) {
594         if (peer instanceof Element) {
595             return ((Element)peer).getAttributeNode(str);
596         } else {
597             throw new NOE();
598         }
599     }
600     
601     public org.w3c.dom.Attr JavaDoc getAttributeNodeNS(String JavaDoc str, String JavaDoc str1) {
602         if (peer instanceof Element) {
603             return ((Element)peer).getAttributeNodeNS(str, str1);
604         } else {
605             throw new NOE();
606         }
607     }
608     
609     public org.w3c.dom.NodeList JavaDoc getElementsByTagName(String JavaDoc str) {
610         if (peer instanceof Element) {
611             return ((Element)peer).getElementsByTagName(str);
612         } else {
613             throw new NOE();
614         }
615     }
616     
617     public org.w3c.dom.NodeList JavaDoc getElementsByTagNameNS(String JavaDoc str, String JavaDoc str1) {
618         if (peer instanceof Element) {
619             return ((Element)peer).getElementsByTagNameNS(str, str1);
620         } else {
621             throw new NOE();
622         }
623     }
624     
625     public String JavaDoc getTagName() {
626         if (peer instanceof Element) {
627             return ((Element)peer).getTagName();
628         } else {
629             throw new NOE();
630         }
631     }
632     
633     public boolean hasAttribute(String JavaDoc str) {
634         if (peer instanceof Element) {
635             return ((Element)peer).hasAttribute(str);
636         } else {
637             throw new NOE();
638         }
639     }
640     
641     public boolean hasAttributeNS(String JavaDoc str, String JavaDoc str1) {
642         if (peer instanceof Element) {
643             return ((Element)peer).hasAttributeNS(str, str1);
644         } else {
645             throw new NOE();
646         }
647     }
648     
649     public void removeAttribute(String JavaDoc str) throws org.w3c.dom.DOMException JavaDoc {
650         if (peer instanceof Element) {
651             ((Element)peer).removeAttribute(str);
652         } else {
653             throw new NOE();
654         }
655     }
656     
657     public void removeAttributeNS(String JavaDoc str, String JavaDoc str1) throws org.w3c.dom.DOMException JavaDoc {
658         if (peer instanceof Element) {
659             ((Element)peer).removeAttributeNS(str, str1);
660         } else {
661             throw new NOE();
662         }
663     }
664     
665     public org.w3c.dom.Attr JavaDoc removeAttributeNode(org.w3c.dom.Attr JavaDoc attr) throws org.w3c.dom.DOMException JavaDoc {
666         if (peer instanceof Element) {
667             return ((Element)peer).removeAttributeNode(attr);
668         } else {
669             throw new NOE();
670         }
671     }
672     
673     public void setAttribute(String JavaDoc str, String JavaDoc str1) throws org.w3c.dom.DOMException JavaDoc {
674         if (peer instanceof Element) {
675             ((Element)peer).setAttribute(str, str1);
676         } else {
677             throw new NOE();
678         }
679     }
680     
681     public void setAttributeNS(String JavaDoc str, String JavaDoc str1, String JavaDoc str2) throws org.w3c.dom.DOMException JavaDoc {
682         if (peer instanceof Element) {
683             ((Element)peer).setAttributeNS(str, str1, str2);
684         } else {
685             throw new NOE();
686         }
687     }
688     
689     public org.w3c.dom.Attr JavaDoc setAttributeNode(org.w3c.dom.Attr JavaDoc attr) throws org.w3c.dom.DOMException JavaDoc {
690         if (peer instanceof Element) {
691             return ((Element)peer).setAttributeNode(attr);
692         } else {
693             throw new NOE();
694         }
695     }
696     
697     public org.w3c.dom.Attr JavaDoc setAttributeNodeNS(org.w3c.dom.Attr JavaDoc attr) throws org.w3c.dom.DOMException JavaDoc {
698         if (peer instanceof Element) {
699             return ((Element)peer).setAttributeNodeNS(attr);
700         } else {
701             throw new NOE();
702         }
703     }
704     
705     //??? or could we throw class casts
706
private class NOA extends DOMException {
707         
708         private static final long serialVersionUID = 4600894053037825159L;
709         
710         NOA() {
711             super(DOMException.NOT_SUPPORTED_ERR, "Peer " + peer + " is not instance of Attr!");
712         }
713     }
714     
715     private class NOE extends DOMException {
716         
717         private static final long serialVersionUID = 4600894053037825159L;
718         
719         NOE() {
720             super(DOMException.NOT_SUPPORTED_ERR, "Peer " + peer + " is not instance of Element!");
721         }
722     }
723
724     //
725
// Implementation of DOM Level 3 methods
726
//
727

728     public short compareDocumentPosition (Node a) {
729         throw new UOException();
730     }
731     
732     public String JavaDoc getBaseURI() {
733         throw new UOException();
734     }
735     public Object JavaDoc getFeature(String JavaDoc a, String JavaDoc b) {
736         throw new UOException();
737     }
738     public String JavaDoc getTextContent () {
739         throw new UOException();
740     }
741     public Object JavaDoc getUserData(String JavaDoc a) {
742         throw new UOException();
743     }
744     public boolean isDefaultNamespace (String JavaDoc a) {
745         throw new UOException();
746     }
747     public boolean isEqualNode(Node a) {
748         throw new UOException();
749     }
750     public boolean isSameNode(Node a) {
751         throw new UOException();
752     }
753     public String JavaDoc lookupNamespaceURI(String JavaDoc a) {
754         throw new UOException();
755     }
756     public String JavaDoc lookupPrefix(String JavaDoc a) {
757         throw new UOException();
758     }
759     public void setTextContent(String JavaDoc a) {
760         throw new UOException();
761     }
762     public Object JavaDoc setUserData(String JavaDoc a, Object JavaDoc b, UserDataHandler c) {
763         throw new UOException();
764     }
765     // Implementation of DOM Level 3 methods for Element
766
public TypeInfo getSchemaTypeInfo() {
767         throw new UOException ();
768     }
769     public void setIdAttribute(String JavaDoc a, boolean b) {
770         throw new UOException ();
771     }
772     public void setIdAttributeNS(String JavaDoc a, String JavaDoc b, boolean c) {
773         throw new UOException ();
774     }
775     public void setIdAttributeNode(Attr a, boolean b) {
776         throw new UOException ();
777     }
778     // Implementation of DOM Level 3 methods for Attr
779

780     public boolean isId () {
781         throw new UOException ();
782     }
783     // Implementation of DOM Level 3 methods for Text
784
public Text replaceWholeText (String JavaDoc a) {
785         throw new UOException ();
786     }
787     public String JavaDoc getWholeText() {
788         throw new UOException ();
789     }
790     public boolean isElementContentWhitespace() {
791         throw new UOException ();
792     }
793 }
794
Popular Tags