📄 nodelistimpl.java
字号:
/**
* org/ozone-db/xml/dom/NodeListImpl.java
*
* The contents of this file are subject to the OpenXML Public
* License Version 1.0; you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.openxml.org/license.html
*
* THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
* OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
* AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
* RIGHTS AND LIMITATIONS UNDER THE LICENSE.
*
* The Initial Developer of this code under the License is Assaf Arkin.
* Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
* All Rights Reserved.
*/
/**
* Changes for Persistent DOM running with ozone are
* Copyright 1999 by SMB GmbH. All rights reserved.
*/
package org.ozoneDB.xml.dom;
import org.w3c.dom.*;
import java.io.*;
import java.util.Vector;
/**
* Used to traverse childs of a node. {@link org.w3c.dom.NodeList} is a live
* list, meaning that any change to the node is reflected in this list and vice
* versa.
* <P>
* The functionality of NodeList is implemented in {@link NodeImpl} itself
* using a double-linked list. This class is only provided to hide the
* interface of {@link NodeImpl}.
* <P>
* This class is not entirely thread-safe due to thread-safe limitations on
* {@link NodeImpl} itself.
*
*
* @version $Revision: 1.1 $ $Date: 2003/11/02 17:26:14 $
* @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
* @see NodeImpl
*/
public final class NodeListImpl implements NodeList, Serializable {
final static long serialVersionUID = 1;
/**
* Return the nth child in the node (zero based). If the child does not exist,
* returns null. No exception is thrown if index is negative.
* @param index Index of child to return (zero based)
* @return Child or null
* @see NodeImpl#getChild
*/
public Node item( int index ) {
return index >= 0 && index < _nodes.size() ? (Node)_nodes.elementAt( index ) : null;
}
/**
* Return the number of childs in this node.
* @return Number of childs
*/
public int getLength() {
return _nodes.size();
}
/**
* Constructor requires node.
* @param node Node to traverse
*/
public NodeListImpl( Node node ) {
if (node == null) {
throw new NullPointerException( "Argument 'node' is null." );
}
_rootNode = node;
_nodes = new Vector();
Node child = node.getFirstChild();
while (child != null) {
_nodes.addElement( child );
child = child.getNextSibling();
}
}
/**
* The node which this list traverses.
*/
protected Node _rootNode;
protected Vector _nodes;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -