KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > util > ModifiableNodeList


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: ModifiableNodeList.java,v 1.1 2001/01/19 17:47:50 conny Exp $
8

9 package org.ozoneDB.xml.util;
10
11 import java.util.Vector JavaDoc;
12
13 import java.io.Serializable JavaDoc;
14
15 import org.w3c.dom.Node JavaDoc;
16 import org.w3c.dom.NodeList JavaDoc;
17
18 public final class ModifiableNodeList implements NodeList JavaDoc, Serializable JavaDoc {
19
20     private Vector JavaDoc nodes = null;
21     
22     public ModifiableNodeList() {
23         this.nodes = new Vector JavaDoc();
24     }
25     
26
27     public ModifiableNodeList(int initialCapacity) {
28         this.nodes = new Vector JavaDoc(initialCapacity);
29     }
30     
31     
32     public void addNode(Node JavaDoc node) {
33         this.nodes.add(node);
34     }
35
36
37     public void removeNode(int index) {
38         this.nodes.remove(index);
39     }
40     
41     
42     //
43
// org.w3c.dom.NodeList implementation
44
//
45

46     public Node JavaDoc item(int index) {
47         return ((index >= 0) && (index < this.nodes.size()))
48                 ? (Node JavaDoc)this.nodes.elementAt(index) : null;
49         }
50     
51     
52     public int getLength(){
53         return this.nodes.size();
54     }
55     
56 }
57
Popular Tags