KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > xs > util > NSItemListImpl


1 /*
2  * Copyright 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.impl.xs.util;
18
19 import java.util.Vector JavaDoc;
20
21 import org.apache.xerces.xs.XSNamespaceItem;
22 import org.apache.xerces.xs.XSNamespaceItemList;
23 /**
24  * Containts a list of Object's.
25  *
26  * @xerces.internal
27  *
28  * @author Sandy Gao, IBM
29  *
30  * @version $Id: NSItemListImpl.java,v 1.5 2004/10/06 15:14:50 mrglavas Exp $
31  */

32 public class NSItemListImpl implements XSNamespaceItemList {
33
34     // The array to hold all data
35
private XSNamespaceItem[] fArray = null;
36     // Number of elements in this list
37
private int fLength = 0;
38
39     // REVISIT: this is temp solution. In general we need to use this class
40
// instead of the Vector.
41
private Vector JavaDoc fVector;
42
43     public NSItemListImpl(Vector JavaDoc v) {
44         fVector = v;
45         fLength = v.size();
46     }
47
48     /**
49      * Construct an XSNamespaceItemList implementation
50      *
51      * @param array the data array
52      * @param length the number of elements
53      */

54     public NSItemListImpl(XSNamespaceItem[] array, int length) {
55         fArray = array;
56         fLength = length;
57     }
58
59     /**
60      * The number of <code>Objects</code> in the list. The range of valid
61      * child node indices is 0 to <code>length-1</code> inclusive.
62      */

63     public int getLength() {
64         return fLength;
65     }
66
67     public XSNamespaceItem item(int index) {
68         if (index < 0 || index >= fLength)
69             return null;
70         if (fVector != null) {
71             return (XSNamespaceItem)fVector.elementAt(index);
72         }
73         return fArray[index];
74     }
75
76 } // class XSParticle
77
Popular Tags