1 16 17 package org.apache.xerces.impl.xs.util; 18 19 import org.apache.xerces.xs.ShortList; 20 import org.apache.xerces.xs.XSException; 21 22 31 public class ShortListImpl implements ShortList { 32 33 private short[] fArray = null; 35 private int fLength = 0; 37 38 44 public ShortListImpl(short[] array, int length) { 45 fArray = array; 46 fLength = length; 47 } 48 49 53 public int getLength() { 54 return fLength; 55 } 56 57 65 public boolean contains(short item) { 66 for (int i = 0; i < fLength; i++) { 67 if (fArray[i] == item) 68 return true; 69 } 70 return false; 71 } 72 73 public short item(int index) throws XSException { 74 if (index < 0 || index >= fLength) 75 throw new XSException(XSException.INDEX_SIZE_ERR, null); 76 return fArray[index]; 77 } 78 79 public boolean equals(Object obj) { 80 if (obj == null || !(obj instanceof ShortList)) { 81 return false; 82 } 83 ShortList rhs = (ShortList)obj; 84 85 if (fLength != rhs.getLength()) { 86 return false; 87 } 88 89 for (int i = 0;i < fLength; ++i) { 90 if (fArray[i] != rhs.item(i)) { 91 return false; 92 } 93 } 94 return true; 95 } 96 97 } | Popular Tags |