1 57 58 package com.sun.org.apache.xerces.internal.impl.xs.util; 59 60 import com.sun.org.apache.xerces.internal.xs.XSObject; 61 import com.sun.org.apache.xerces.internal.xs.XSObjectList; 62 63 70 public class XSObjectListImpl implements XSObjectList { 71 72 private final int DEFAULT_SIZE = 4; 73 74 private XSObject[] fArray = null; 76 private int fLength = 0; 78 79 80 81 public XSObjectListImpl(){ 82 fArray = new XSObject[DEFAULT_SIZE]; 83 fLength = 0; 84 } 85 86 92 public XSObjectListImpl(XSObject[] array, int length) { 93 fArray = array; 94 fLength = length; 95 } 96 97 101 public int getLength() { 102 return fLength; 103 } 104 105 114 public XSObject item(int index) { 115 if (index < 0 || index >= fLength) 116 return null; 117 return fArray[index]; 118 } 119 120 public void clear() { 122 for (int i=0; i<fLength; i++) { 123 fArray[i] = null; 124 } 125 fArray = null; 126 fLength = 0; 127 } 128 129 public void add (XSObject object){ 130 if (fLength == fArray.length){ 131 XSObject[] temp = new XSObject[fLength + 4]; 132 System.arraycopy(fArray, 0, temp, 0, fLength); 133 fArray = temp; 134 } 135 fArray[fLength++]=object; 136 } 137 public void add (int index, XSObject object){ 138 fArray [index] = object; 139 } 140 141 } | Popular Tags |