001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements. See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership. The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License. You may obtain a copy of the License at
009     *
010     * http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied. See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    package javax.xml.soap;
020    
021    /**
022     * A representation of a node (element) in a DOM representation of an XML document that provides
023     * some tree manipulation methods. This interface provides methods for getting the value of a node,
024     * for getting and setting the parent of a node, and for removing a node.
025     */
026    public interface Node extends org.w3c.dom.Node {
027    
028        /**
029         * Returns the the value of the immediate child of this <code>Node</code> object if a child
030         * exists and its value is text.
031         *
032         * @return a <code>String</code> with the text of the immediate child of this <code>Node</code>
033         *         object if (1) there is a child and (2) the child is a <code>Text</code> object;
034         *         <code>null</code> otherwise
035         */
036        public abstract String getValue();
037    
038        /**
039         * Sets the parent of this <code>Node</code> object to the given <code>SOAPElement</code>
040         * object.
041         *
042         * @param parent the <code>SOAPElement</code> object to be set as the parent of this
043         *               <code>Node</code> object
044         * @throws SOAPException if there is a problem in setting the parent to the given element
045         * @see #getParentElement() getParentElement()
046         */
047        public abstract void setParentElement(SOAPElement parent)
048                throws SOAPException;
049    
050        /**
051         * Returns the parent element of this <code>Node</code> object. This method can throw an
052         * <code>UnsupportedOperationException</code> if the tree is not kept in memory.
053         *
054         * @return the <code>SOAPElement</code> object that is the parent of this <code>Node</code>
055         *         object or <code>null</code> if this <code>Node</code> object is root
056         * @throws UnsupportedOperationException
057         *          if the whole tree is not kept in memory
058         * @see #setParentElement(SOAPElement) setParentElement(javax.xml.soap.SOAPElement)
059         */
060        public abstract SOAPElement getParentElement();
061    
062        /**
063         * Removes this <code>Node</code> object from the tree. Once removed, this node can be garbage
064         * collected if there are no application references to it.
065         */
066        public abstract void detachNode();
067    
068        /**
069         * Notifies the implementation that this <code>Node</code> object is no longer being used by the
070         * application and that the implementation is free to reuse this object for nodes that may be
071         * created later.
072         * <p/>
073         * Calling the method <code>recycleNode</code> implies that the method <code>detachNode</code>
074         * has been called previously.
075         */
076        public abstract void recycleNode();
077    
078        /**
079         * If this is a Text node then this method will set its value, otherwise it sets the value of
080         * the immediate (Text) child of this node. The value of the immediate child of this node can be
081         * set only if, there is one child node and that node is a Text node, or if there are no
082         * children in which case a child Text node will be created.
083         *
084         * @param value the text to set
085         * @throws IllegalStateException if the node is not a Text  node and either has more than one
086         *                               child node or has a child node that is not a Text node
087         */
088    
089        public abstract void setValue(String value);
090    }