1 /* 2 * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.xml.soap; 27 28 /** 29 * A representation of a node (element) in an XML document. 30 * This interface extnends the standard DOM Node interface with methods for 31 * getting and setting the value of a node, for 32 * getting and setting the parent of a node, and for removing a node. 33 */ 34 public interface Node extends org.w3c.dom.Node { 35 /** 36 * Returns the value of this node if this is a <code>Text</code> node or the 37 * value of the immediate child of this node otherwise. 38 * If there is an immediate child of this <code>Node</code> that it is a 39 * <code>Text</code> node then it's value will be returned. If there is 40 * more than one <code>Text</code> node then the value of the first 41 * <code>Text</code> Node will be returned. 42 * Otherwise <code>null</code> is returned. 43 * 44 * @return a <code>String</code> with the text of this node if this is a 45 * <code>Text</code> node or the text contained by the first 46 * immediate child of this <code>Node</code> object that is a 47 * <code>Text</code> object if such a child exists; 48 * <code>null</code> otherwise. 49 */ 50 public String getValue(); 51 52 /** 53 * If this is a Text node then this method will set its value, 54 * otherwise it sets the value of the immediate (Text) child of this node. 55 * The value of the immediate child of this node can be set only if, there is 56 * one child node and that node is a <code>Text</code> node, or if 57 * there are no children in which case a child <code>Text</code> node will be 58 * created. 59 * 60 * @exception IllegalStateException if the node is not a <code>Text</code> 61 * node and either has more than one child node or has a child 62 * node that is not a <code>Text</code> node. 63 * 64 * @since SAAJ 1.2 65 */ 66 public void setValue(String value); 67 68 /** 69 * Sets the parent of this <code>Node</code> object to the given 70 * <code>SOAPElement</code> object. 71 * 72 * @param parent the <code>SOAPElement</code> object to be set as 73 * the parent of this <code>Node</code> object 74 * 75 * @exception SOAPException if there is a problem in setting the 76 * parent to the given element 77 * @see #getParentElement 78 */ 79 public void setParentElement(SOAPElement parent) throws SOAPException; 80 81 /** 82 * Returns the parent element of this <code>Node</code> object. 83 * This method can throw an <code>UnsupportedOperationException</code> 84 * if the tree is not kept in memory. 85 * 86 * @return the <code>SOAPElement</code> object that is the parent of 87 * this <code>Node</code> object or <code>null</code> if this 88 * <code>Node</code> object is root 89 * 90 * @exception UnsupportedOperationException if the whole tree is not 91 * kept in memory 92 * @see #setParentElement 93 */ 94 public SOAPElement getParentElement(); 95 96 /** 97 * Removes this <code>Node</code> object from the tree. 98 */ 99 public void detachNode(); 100 101 /** 102 * Notifies the implementation that this <code>Node</code> 103 * object is no longer being used by the application and that the 104 * implementation is free to reuse this object for nodes that may 105 * be created later. 106 * <P> 107 * Calling the method <code>recycleNode</code> implies that the method 108 * <code>detachNode</code> has been called previously. 109 */ 110 public void recycleNode(); 111 112 }