src/org/objectweb/cjdbc/controller/cache/result/schema/CacheDatabaseSchema.java

説明を見る。
00001 00025 package org.objectweb.cjdbc.controller.cache.result.schema; 00026 00027 import java.io.Serializable; 00028 import java.sql.SQLException; 00029 import java.util.ArrayList; 00030 00031 import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema; 00032 import org.objectweb.cjdbc.common.sql.schema.DatabaseTable; 00033 00041 public class CacheDatabaseSchema implements Serializable 00042 { 00044 private ArrayList tables; 00045 00052 public CacheDatabaseSchema(DatabaseSchema dbs) 00053 { 00054 if (dbs == null) 00055 { 00056 tables = new ArrayList(); 00057 return; 00058 } 00059 00060 // Clone the tables 00061 ArrayList origTables = dbs.getTables(); 00062 int size = origTables.size(); 00063 tables = new ArrayList(size); 00064 for (int i = 0; i < size; i++) 00065 tables.add(new CacheDatabaseTable((DatabaseTable) origTables.get(i))); 00066 } 00067 00074 public void addTable(CacheDatabaseTable table) 00075 { 00076 tables.add(table); 00077 } 00078 00085 public void removeTable(CacheDatabaseTable table) 00086 { 00087 tables.remove(table); 00088 } 00089 00098 public void mergeSchema(CacheDatabaseSchema databaseSchema) 00099 throws SQLException 00100 { 00101 if (databaseSchema == null) 00102 return; 00103 00104 ArrayList otherTables = databaseSchema.getTables(); 00105 if (otherTables == null) 00106 return; 00107 00108 int size = otherTables.size(); 00109 for (int i = 0; i < size; i++) 00110 { 00111 CacheDatabaseTable t = (CacheDatabaseTable) otherTables.get(i); 00112 CacheDatabaseTable original = getTable(t.getName()); 00113 if (original == null) 00114 addTable(t); 00115 else 00116 original.mergeColumns(t); 00117 } 00118 } 00119 00126 public ArrayList getTables() 00127 { 00128 return tables; 00129 } 00130 00138 public CacheDatabaseTable getTable(String tableName) 00139 { 00140 int size = tables.size(); 00141 for (int i = 0; i < size; i++) 00142 { 00143 CacheDatabaseTable t = (CacheDatabaseTable) tables.get(i); 00144 if (t.getName().compareTo(tableName) == 0) 00145 return t; 00146 } 00147 return null; 00148 } 00149 00157 public boolean hasTable(String tableName) 00158 { 00159 int size = tables.size(); 00160 for (int i = 0; i < size; i++) 00161 { 00162 CacheDatabaseTable t = (CacheDatabaseTable) tables.get(i); 00163 if (tableName.equals(t.getName())) 00164 return true; 00165 } 00166 return false; 00167 } 00168 00176 public boolean equals(Object other) 00177 { 00178 if (!(other instanceof CacheDatabaseSchema)) 00179 return false; 00180 00181 if (tables == null) 00182 return ((CacheDatabaseSchema) other).getTables() == null; 00183 else 00184 return tables.equals(((CacheDatabaseSchema) other).getTables()); 00185 } 00186 00194 public String getInformation(boolean longFormat) 00195 { 00196 String result = ""; 00197 int size = tables.size(); 00198 for (int i = 0; i < size; i++) 00199 { 00200 CacheDatabaseTable t = (CacheDatabaseTable) tables.get(i); 00201 result += t.getInformation(longFormat) + "\n"; 00202 } 00203 return result; 00204 } 00205 00206 }

CJDBCversion1.0.4に対してTue Oct 12 15:16:00 2004に生成されました。 doxygen 1.3.8