1 57 58 package com.sun.org.apache.xerces.internal.impl.xs.util; 59 60 import com.sun.org.apache.xerces.internal.xs.StringList; 61 import java.util.Vector ; 62 69 public class StringListImpl implements StringList { 70 71 private String [] fArray = null; 73 private int fLength = 0; 75 76 private Vector fVector; 79 80 public StringListImpl(Vector v) { 81 fVector = v; 82 fLength = (v == null) ? 0 : v.size(); 83 } 84 85 91 public StringListImpl(String [] array, int length) { 92 fArray = array; 93 fLength = length; 94 } 95 96 100 public int getLength() { 101 return fLength; 102 } 103 104 112 public boolean contains(String item) { 113 if (fVector != null) 114 return fVector.contains(item); 115 116 if (item == null) { 117 for (int i = 0; i < fLength; i++) { 118 if (fArray[i] == null) 119 return true; 120 } 121 } 122 else { 123 for (int i = 0; i < fLength; i++) { 124 if (item.equals(fArray[i])) 125 return true; 126 } 127 } 128 return false; 129 } 130 131 public String item(int index) { 132 if (index < 0 || index >= fLength) 133 return null; 134 if (fVector != null) { 135 return (String )fVector.elementAt(index); 136 } 137 return fArray[index]; 138 } 139 140 } | Popular Tags |