Esempio n. 1
0
 /**
  * Retrieves the hashTable from the file specified by <i>source</i>.
  *
  * @param source the name of the file from which the hashTable is to be retrieved.
  * @pre <i>None</i>
  * @post If there is any error &rArr; LocalObjectId.nextId = LocalObjectId.INITIAL_ID and
  *     |hashTable| = 0 Else the hashTable in the specified file is retrieved and stored in
  *     hashTable AND LocalObjectId.nextId = |hashTable|
  */
 public void restore(String source) {
   String fileLocation = DEFAULT_FILE_LOCATION;
   if (FILE_LOCATION != null) {
     fileLocation = FILE_LOCATION;
   }
   if (source != null) {
     fileLocation = source;
   }
   try {
     ObjectInputStream ois =
         new ObjectInputStream(new BufferedInputStream(new FileInputStream(fileLocation)));
     int nextId = ois.read();
     LocalObjectId.setNextId(nextId);
     hashTable = (Hashtable<LocalObjectId, Object>) ois.readObject();
     ois.close();
   } catch (Exception e) {
     LocalObjectId.setNextId(LocalObjectId.INITIAL_ID);
     hashTable = new Hashtable<LocalObjectId, Object>();
   }
 }
Esempio n. 2
0
 /**
  * Empties the ObjectDB and sets the next LocalObjectID to the initial LocalObjectId.
  *
  * @pre <i>None</i>
  * @post |hashTable| = 0 AND LocalObjectId.nextId = LocalObjectId.INITIAL_ID
  */
 public void clear() {
   hashTable.clear();
   LocalObjectId.setNextId(LocalObjectId.INITIAL_ID);
 }