예제 #1
0
  /** Returns one record */
  @Override
  public DBRecord get(String dbname, Integer key) throws DBNotFoundException, KeyNotFoundException {
    DB db = null;
    db = this.dbExists(dbname);
    if (db == null)
      throw new DBNotFoundException("<< ERROR - Database " + dbname + " does not exists.");
    // here db exists
    DBRecord dbr = db.findDbRec(key);
    if (dbr == null) {
      throw new KeyNotFoundException(
          "<< ERROR - Key: " + key + " wasn't found in the database.", key);
    }

    return dbr;
  }
예제 #2
0
  @Override
  public DBRecord[] getA(String dbname, Integer[] key)
      throws DBNotFoundException, KeyNotFoundException {
    DB db = null;
    db = this.dbExists(dbname);
    if (db == null)
      throw new DBNotFoundException("<< ERROR - Database " + dbname + " does not exists.");
    // ////////////////////////////
    // here exists database
    int size = key.length;
    DBRecord[] dbRecords = new DBRecord[size];
    for (int i = 0; i < size; i++) {
      int keyNum = key[i];
      DBRecord tmpRec = db.findDbRec(keyNum);
      if (tmpRec == null) {
        throw new KeyNotFoundException(
            "<< ERROR - Key:" + keyNum + " wasn't found in the database.", keyNum);
      }
      dbRecords[i] = tmpRec;
    }

    return dbRecords;
  }