1 21 22 package org.apache.derby.iapi.sql.dictionary; 23 24 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor; 25 import org.apache.derby.iapi.error.StandardException; 26 import org.apache.derby.iapi.services.sanity.SanityManager; 27 28 import org.apache.derby.iapi.services.monitor.Monitor; 29 30 import org.apache.derby.catalog.UUID; 31 32 import java.util.Iterator ; 33 import java.util.ArrayList ; 34 35 public class ConglomerateDescriptorList extends ArrayList 36 { 37 38 46 public ConglomerateDescriptor getConglomerateDescriptor(long conglomerateNumber) 47 { 48 ConglomerateDescriptor conglomerateDescriptor; 49 ConglomerateDescriptor returnValue = null; 50 51 int size = size(); 52 for (int index = 0; index < size; index++) 53 { 54 conglomerateDescriptor = (ConglomerateDescriptor) get(index); 55 if (conglomerateNumber == conglomerateDescriptor.getConglomerateNumber()) 56 { 57 returnValue = conglomerateDescriptor; 58 break; 59 } 60 } 61 62 return returnValue; 63 } 64 65 75 public ConglomerateDescriptor[] getConglomerateDescriptors(long conglomerateNumber) 76 { 77 ConglomerateDescriptor conglomerateDescriptor; 78 79 int size = size(), j = 0; 80 ConglomerateDescriptor[] draft = new ConglomerateDescriptor[size]; 81 82 for (int index = 0; index < size; index++) 83 { 84 conglomerateDescriptor = (ConglomerateDescriptor) get(index); 85 if (conglomerateNumber == conglomerateDescriptor.getConglomerateNumber()) 86 draft[j++] = conglomerateDescriptor; 87 } 88 89 if (j == size) 90 return draft; 91 ConglomerateDescriptor[] returnValue = new ConglomerateDescriptor[j]; 92 for (int i = 0; i < j; i++) 93 returnValue[i] = draft[i]; 94 95 return returnValue; 96 } 97 98 99 107 108 public ConglomerateDescriptor getConglomerateDescriptor(String conglomerateName) 109 { 110 ConglomerateDescriptor conglomerateDescriptor; 111 ConglomerateDescriptor returnValue = null; 112 113 int size = size(); 114 for (int index = 0; index < size; index++) 115 { 116 conglomerateDescriptor = (ConglomerateDescriptor) get(index); 117 if (conglomerateName.equals(conglomerateDescriptor.getConglomerateName())) 118 { 119 returnValue = conglomerateDescriptor; 120 break; 121 } 122 } 123 124 return returnValue; 125 } 126 127 136 137 public ConglomerateDescriptor getConglomerateDescriptor(UUID uuid) 138 throws StandardException 139 { 140 ConglomerateDescriptor conglomerateDescriptor; 141 ConglomerateDescriptor returnValue = null; 142 143 int size = size(); 144 for (int index = 0; index < size; index++) 145 { 146 conglomerateDescriptor = (ConglomerateDescriptor) get(index); 147 148 if (uuid.equals(conglomerateDescriptor.getUUID())) 149 { 150 returnValue = conglomerateDescriptor; 151 break; 152 } 153 } 154 155 return returnValue; 156 } 157 158 167 public ConglomerateDescriptor[] getConglomerateDescriptors(UUID uuid) 168 { 169 ConglomerateDescriptor conglomerateDescriptor; 170 171 int size = size(), j = 0; 172 ConglomerateDescriptor[] draft = new ConglomerateDescriptor[size]; 173 174 for (int index = 0; index < size; index++) 175 { 176 conglomerateDescriptor = (ConglomerateDescriptor) get(index); 177 if (uuid.equals(conglomerateDescriptor.getUUID())) 178 draft[j++] = conglomerateDescriptor; 179 } 180 181 if (j == size) 182 return draft; 183 ConglomerateDescriptor[] returnValue = new ConglomerateDescriptor[j]; 184 for (int i = 0; i < j; i++) 185 returnValue[i] = draft[i]; 186 187 return returnValue; 188 } 189 190 200 public void dropConglomerateDescriptor(UUID tableID, ConglomerateDescriptor cgDesc) 201 throws StandardException 202 { 203 for (Iterator iterator = iterator(); iterator.hasNext(); ) 204 { 205 ConglomerateDescriptor localCgDesc = (ConglomerateDescriptor) iterator.next(); 206 if (localCgDesc.getConglomerateNumber() == cgDesc.getConglomerateNumber() && 207 localCgDesc.getConglomerateName().equals(cgDesc.getConglomerateName()) && 208 localCgDesc.getSchemaID().equals(cgDesc.getSchemaID())) 209 { 210 iterator.remove(); 211 break; 212 } 213 } 214 } 215 216 225 public void dropConglomerateDescriptorByUUID(UUID conglomerateID) 226 throws StandardException 227 { 228 for (Iterator iterator = iterator(); iterator.hasNext(); ) 229 { 230 ConglomerateDescriptor localCgDesc = (ConglomerateDescriptor) iterator.next(); 231 if ( conglomerateID.equals( localCgDesc.getUUID() ) ) 232 { 233 iterator.remove(); 234 break; 235 } 236 } 237 } 238 } 239 | Popular Tags |