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