1 16 19 package com.sun.org.apache.xml.internal.utils; 20 21 26 public class StringToStringTableVector 27 { 28 29 30 private int m_blocksize; 31 32 33 private StringToStringTable m_map[]; 34 35 36 private int m_firstFree = 0; 37 38 39 private int m_mapSize; 40 41 45 public StringToStringTableVector() 46 { 47 48 m_blocksize = 8; 49 m_mapSize = m_blocksize; 50 m_map = new StringToStringTable[m_blocksize]; 51 } 52 53 58 public StringToStringTableVector(int blocksize) 59 { 60 61 m_blocksize = blocksize; 62 m_mapSize = blocksize; 63 m_map = new StringToStringTable[blocksize]; 64 } 65 66 71 public final int getLength() 72 { 73 return m_firstFree; 74 } 75 76 81 public final int size() 82 { 83 return m_firstFree; 84 } 85 86 91 public final void addElement(StringToStringTable value) 92 { 93 94 if ((m_firstFree + 1) >= m_mapSize) 95 { 96 m_mapSize += m_blocksize; 97 98 StringToStringTable newMap[] = new StringToStringTable[m_mapSize]; 99 100 System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1); 101 102 m_map = newMap; 103 } 104 105 m_map[m_firstFree] = value; 106 107 m_firstFree++; 108 } 109 110 119 public final String get(String key) 120 { 121 122 for (int i = m_firstFree - 1; i >= 0; --i) 123 { 124 String nsuri = m_map[i].get(key); 125 126 if (nsuri != null) 127 return nsuri; 128 } 129 130 return null; 131 } 132 133 141 public final boolean containsKey(String key) 142 { 143 144 for (int i = m_firstFree - 1; i >= 0; --i) 145 { 146 if (m_map[i].get(key) != null) 147 return true; 148 } 149 150 return false; 151 } 152 153 156 public final void removeLastElem() 157 { 158 159 if (m_firstFree > 0) 160 { 161 m_map[m_firstFree] = null; 162 163 m_firstFree--; 164 } 165 } 166 167 174 public final StringToStringTable elementAt(int i) 175 { 176 return m_map[i]; 177 } 178 179 186 public final boolean contains(StringToStringTable s) 187 { 188 189 for (int i = 0; i < m_firstFree; i++) 190 { 191 if (m_map[i].equals(s)) 192 return true; 193 } 194 195 return false; 196 } 197 } 198 | Popular Tags |