1 65 66 67 package org.hsqldb.util; 68 69 import java.io.FileInputStream ; 70 import java.io.FileOutputStream ; 71 import java.io.IOException ; 72 import java.io.ObjectInputStream ; 73 import java.io.ObjectOutputStream ; 74 import java.util.Vector ; 75 76 78 85 class TransferCommon { 86 87 static void savePrefs(String f, DataAccessPoint sourceDb, 88 DataAccessPoint targetDb, Traceable tracer, 89 Vector tTable) { 90 91 TransferTable t; 92 93 try { 94 FileOutputStream fos = new FileOutputStream (f); 95 ObjectOutputStream oos = new ObjectOutputStream (fos); 96 97 for (int i = 0; i < tTable.size(); i++) { 98 t = (TransferTable) tTable.elementAt(i); 99 t.sourceDb = null; 100 t.destDb = null; 101 t.tracer = null; 102 } 103 104 oos.writeObject(tTable); 105 106 for (int i = 0; i < tTable.size(); i++) { 107 t = (TransferTable) tTable.elementAt(i); 108 t.tracer = tracer; 109 t.sourceDb = (TransferDb) sourceDb; 110 t.destDb = targetDb; 111 } 112 } catch (IOException e) { 113 System.out.println("pb in SavePrefs : " + e.toString()); 114 e.printStackTrace(); 115 } 116 } 117 118 static Vector loadPrefs(String f, DataAccessPoint sourceDb, 119 DataAccessPoint targetDb, Traceable tracer) { 120 121 TransferTable t; 122 Vector tTable = null; 123 ObjectInputStream ois = null; 124 125 try { 126 FileInputStream fis = new FileInputStream (f); 127 128 ois = new ObjectInputStream (fis); 129 tTable = (Vector ) ois.readObject(); 130 131 for (int i = 0; i < tTable.size(); i++) { 132 t = (TransferTable) tTable.elementAt(i); 133 t.tracer = tracer; 134 t.sourceDb = (TransferDb) sourceDb; 135 t.destDb = targetDb; 136 } 137 } catch (ClassNotFoundException e) { 138 System.out.println("class not found pb in LoadPrefs : " 139 + e.toString()); 140 141 tTable = new Vector (); 142 } catch (IOException e) { 143 System.out.println("IO pb in LoadPrefs : actionPerformed" 144 + e.toString()); 145 146 tTable = new Vector (); 147 } finally { 148 if (ois != null) { 149 try { 150 ois.close(); 151 } catch (IOException ioe) {} 152 } 153 } 154 155 return (tTable); 156 } 157 158 private TransferCommon() {} 159 } 160 | Popular Tags |