1 16 17 package org.apache.xerces.impl.xs.util; 18 19 import org.apache.xerces.xs.XSObject; 20 import org.apache.xerces.xs.XSObjectList; 21 22 31 public class XSObjectListImpl implements XSObjectList { 32 33 36 public static final XSObjectList EMPTY_LIST = new XSObjectList () { 37 public int getLength() { 38 return 0; 39 } 40 public XSObject item(int index) { 41 return null; 42 } 43 }; 44 45 private static final int DEFAULT_SIZE = 4; 46 47 private XSObject[] fArray = null; 49 private int fLength = 0; 51 52 53 54 public XSObjectListImpl() { 55 fArray = new XSObject[DEFAULT_SIZE]; 56 fLength = 0; 57 } 58 59 65 public XSObjectListImpl(XSObject[] array, int length) { 66 fArray = array; 67 fLength = length; 68 } 69 70 74 public int getLength() { 75 return fLength; 76 } 77 78 87 public XSObject item(int index) { 88 if (index < 0 || index >= fLength) 89 return null; 90 return fArray[index]; 91 } 92 93 public void clear() { 95 for (int i=0; i<fLength; i++) { 96 fArray[i] = null; 97 } 98 fArray = null; 99 fLength = 0; 100 } 101 102 public void add (XSObject object){ 103 if (fLength == fArray.length){ 104 XSObject[] temp = new XSObject[fLength + 4]; 105 System.arraycopy(fArray, 0, temp, 0, fLength); 106 fArray = temp; 107 } 108 fArray[fLength++]=object; 109 } 110 public void add (int index, XSObject object){ 111 fArray [index] = object; 112 } 113 114 } | Popular Tags |