1 16 17 package org.apache.xerces.impl.xs.util; 18 19 import org.apache.xerces.xs.StringList; 20 import java.util.Vector ; 21 30 public class StringListImpl implements StringList { 31 32 35 public static final StringList EMPTY_LIST = new StringList () { 36 public int getLength() { 37 return 0; 38 } 39 public boolean contains(String item) { 40 return false; 41 } 42 public String item(int index) { 43 return null; 44 } 45 }; 46 47 private String [] fArray = null; 49 private int fLength = 0; 51 52 private Vector fVector; 55 56 public StringListImpl(Vector v) { 57 fVector = v; 58 fLength = (v == null) ? 0 : v.size(); 59 } 60 61 67 public StringListImpl(String [] array, int length) { 68 fArray = array; 69 fLength = length; 70 } 71 72 76 public int getLength() { 77 return fLength; 78 } 79 80 88 public boolean contains(String item) { 89 if (fVector != null) 90 return fVector.contains(item); 91 92 if (item == null) { 93 for (int i = 0; i < fLength; i++) { 94 if (fArray[i] == null) 95 return true; 96 } 97 } 98 else { 99 for (int i = 0; i < fLength; i++) { 100 if (item.equals(fArray[i])) 101 return true; 102 } 103 } 104 return false; 105 } 106 107 public String item(int index) { 108 if (index < 0 || index >= fLength) 109 return null; 110 if (fVector != null) { 111 return (String )fVector.elementAt(index); 112 } 113 return fArray[index]; 114 } 115 116 } | Popular Tags |