ChildNode.java revision 286
0N/A/*
3909N/A * reserved comment block
0N/A * DO NOT REMOVE OR ALTER!
0N/A */
0N/A/*
0N/A * Copyright 2000-2002,2004 The Apache Software Foundation.
2362N/A *
0N/A * Licensed under the Apache License, Version 2.0 (the "License");
2362N/A * you may not use this file except in compliance with the License.
0N/A * You may obtain a copy of the License at
0N/A *
0N/A * http://www.apache.org/licenses/LICENSE-2.0
0N/A *
0N/A * Unless required by applicable law or agreed to in writing, software
0N/A * distributed under the License is distributed on an "AS IS" BASIS,
0N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0N/A * See the License for the specific language governing permissions and
0N/A * limitations under the License.
0N/A */
0N/A
2362N/Apackage com.sun.org.apache.xerces.internal.dom;
2362N/A
2362N/Aimport org.w3c.dom.Node;
0N/A
0N/A/**
0N/A * ChildNode inherits from NodeImpl and adds the capability of being a child by
0N/A * having references to its previous and next siblings.
0N/A *
0N/A * @xerces.internal
0N/A *
0N/A */
0N/Apublic abstract class ChildNode
0N/A extends NodeImpl {
460N/A
460N/A //
460N/A // Constants
0N/A //
0N/A
0N/A /** Serialization version. */
0N/A static final long serialVersionUID = -6112455738802414002L;
0N/A
0N/A transient StringBuffer fBufferStr = null;
0N/A
0N/A //
0N/A // Data
0N/A //
0N/A
0N/A /** Previous sibling. */
0N/A protected ChildNode previousSibling;
886N/A
0N/A /** Next sibling. */
0N/A protected ChildNode nextSibling;
0N/A
0N/A //
0N/A // Constructors
0N/A //
0N/A
0N/A /**
0N/A * No public constructor; only subclasses of Node should be
0N/A * instantiated, and those normally via a Document's factory methods
0N/A * <p>
0N/A * Every Node knows what Document it belongs to.
0N/A */
0N/A protected ChildNode(CoreDocumentImpl ownerDocument) {
0N/A super(ownerDocument);
0N/A } // <init>(CoreDocumentImpl)
0N/A
0N/A /** Constructor for serialization. */
0N/A public ChildNode() {}
0N/A
0N/A //
0N/A // Node methods
0N/A //
0N/A
0N/A /**
0N/A * Returns a duplicate of a given node. You can consider this a
0N/A * generic "copy constructor" for nodes. The newly returned object should
0N/A * be completely independent of the source object's subtree, so changes
0N/A * in one after the clone has been made will not affect the other.
0N/A * <P>
0N/A * Note: since we never have any children deep is meaningless here,
0N/A * ParentNode overrides this behavior.
0N/A * @see ParentNode
0N/A *
0N/A * <p>
0N/A * Example: Cloning a Text node will copy both the node and the text it
0N/A * contains.
0N/A * <p>
0N/A * Example: Cloning something that has children -- Element or Attr, for
0N/A * example -- will _not_ clone those children unless a "deep clone"
0N/A * has been requested. A shallow clone of an Attr node will yield an
0N/A * empty Attr of the same name.
0N/A * <p>
0N/A * NOTE: Clones will always be read/write, even if the node being cloned
0N/A * is read-only, to permit applications using only the DOM API to obtain
0N/A * editable copies of locked portions of the tree.
0N/A */
0N/A public Node cloneNode(boolean deep) {
0N/A
0N/A ChildNode newnode = (ChildNode) super.cloneNode(deep);
0N/A
0N/A // Need to break the association w/ original kids
0N/A newnode.previousSibling = null;
0N/A newnode.nextSibling = null;
0N/A newnode.isFirstChild(false);
0N/A
0N/A return newnode;
0N/A
0N/A } // cloneNode(boolean):Node
0N/A
0N/A /**
0N/A * Returns the parent node of this node
0N/A */
0N/A public Node getParentNode() {
0N/A // if we have an owner, ownerNode is our parent, otherwise it's
0N/A // our ownerDocument and we don't have a parent
0N/A return isOwned() ? ownerNode : null;
0N/A }
0N/A
0N/A /*
0N/A * same as above but returns internal type
0N/A */
0N/A final NodeImpl parentNode() {
0N/A // if we have an owner, ownerNode is our parent, otherwise it's
0N/A // our ownerDocument and we don't have a parent
0N/A return isOwned() ? ownerNode : null;
0N/A }
0N/A
0N/A /** The next child of this node's parent, or null if none */
0N/A public Node getNextSibling() {
0N/A return nextSibling;
0N/A }
0N/A
0N/A /** The previous child of this node's parent, or null if none */
0N/A public Node getPreviousSibling() {
0N/A // if we are the firstChild, previousSibling actually refers to our
0N/A // parent's lastChild, but we hide that
0N/A return isFirstChild() ? null : previousSibling;
0N/A }
0N/A
0N/A /*
0N/A * same as above but returns internal type
0N/A */
0N/A final ChildNode previousSibling() {
0N/A // if we are the firstChild, previousSibling actually refers to our
0N/A // parent's lastChild, but we hide that
0N/A return isFirstChild() ? null : previousSibling;
0N/A }
0N/A
0N/A} // class ChildNode
0N/A