src/org/objectweb/cjdbc/controller/scheduler/schema/SchedulerDatabaseSchema.java

説明を見る。
00001 00025 package org.objectweb.cjdbc.controller.scheduler.schema; 00026 00027 import java.io.Serializable; 00028 import java.util.ArrayList; 00029 00030 import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema; 00031 import org.objectweb.cjdbc.common.sql.schema.DatabaseTable; 00032 00040 public class SchedulerDatabaseSchema implements Serializable 00041 { 00043 private ArrayList tables; 00044 00045 private TransactionExclusiveLock lock = new TransactionExclusiveLock(); 00046 00053 public SchedulerDatabaseSchema(DatabaseSchema schema) 00054 { 00055 if (schema == null) 00056 { 00057 tables = new ArrayList(); 00058 return; 00059 } 00060 00061 // Clone the tables 00062 ArrayList origTables = schema.getTables(); 00063 int size = origTables.size(); 00064 tables = new ArrayList(size); 00065 for (int i = 0; i < size; i++) 00066 tables.add(new SchedulerDatabaseTable((DatabaseTable) origTables.get(i))); 00067 } 00068 00075 public void addTable(SchedulerDatabaseTable table) 00076 { 00077 tables.add(table); 00078 } 00079 00086 public void removeTable(SchedulerDatabaseTable table) 00087 { 00088 tables.remove(table); 00089 } 00090 00098 public void mergeSchema(SchedulerDatabaseSchema databaseSchema) 00099 { 00100 if (databaseSchema == null) 00101 return; 00102 00103 ArrayList otherTables = databaseSchema.getTables(); 00104 if (otherTables == null) 00105 return; 00106 00107 int size = otherTables.size(); 00108 for (int i = 0; i < size; i++) 00109 { 00110 SchedulerDatabaseTable t = (SchedulerDatabaseTable) otherTables.get(i); 00111 SchedulerDatabaseTable original = getTable(t.getName()); 00112 if (original == null) 00113 addTable(t); 00114 } 00115 } 00116 00123 public ArrayList getTables() 00124 { 00125 return tables; 00126 } 00127 00135 public SchedulerDatabaseTable getTable(String tableName) 00136 { 00137 SchedulerDatabaseTable t; 00138 int size = tables.size(); 00139 for (int i = 0; i < size; i++) 00140 { 00141 t = (SchedulerDatabaseTable) tables.get(i); 00142 if (tableName.equalsIgnoreCase(t.getName())) 00143 return t; 00144 } 00145 return null; 00146 } 00147 00155 public boolean hasTable(String tableName) 00156 { 00157 int size = tables.size(); 00158 for (int i = 0; i < size; i++) 00159 { 00160 SchedulerDatabaseTable t = (SchedulerDatabaseTable) tables.get(i); 00161 if (tableName.equals(t.getName())) 00162 return true; 00163 } 00164 return false; 00165 } 00166 00173 public TransactionExclusiveLock getLock() 00174 { 00175 return lock; 00176 } 00177 00185 public boolean equals(Object other) 00186 { 00187 if (!(other instanceof SchedulerDatabaseSchema)) 00188 return false; 00189 00190 if (tables == null) 00191 return ((SchedulerDatabaseSchema) other).getTables() == null; 00192 else 00193 return tables.equals(((SchedulerDatabaseSchema) other).getTables()); 00194 } 00195 00203 public String getInformation(boolean longFormat) 00204 { 00205 StringBuffer result = new StringBuffer(); 00206 SchedulerDatabaseTable t; 00207 int size = tables.size(); 00208 for (int i = 0; i < size; i++) 00209 { 00210 t = (SchedulerDatabaseTable) tables.get(i); 00211 result.append(t.getInformation(longFormat)); 00212 result.append(System.getProperty("line.separator")); 00213 } 00214 return result.toString(); 00215 } 00216 }

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