Exemplo n.º 1
0
 /** Creates a Cache which initially contains all records in the specified file. */
 public Cache(String file) throws IOException {
   super(true);
   cleaner = new CacheCleaner();
   Master m = new Master(file);
   Record record;
   while ((record = m.nextRecord()) != null) addRecord(record, Credibility.HINT, m);
 }
Exemplo n.º 2
0
  /**
   * Creates a Zone from the records in the specified master file. All records that do not belong in
   * the Zone are added to the specified Cache.
   *
   * @see Cache
   * @see Master
   */
  public Zone(String file, Cache cache, Name initialOrigin) throws IOException {
    super(false);
    Master m = new Master(file, initialOrigin);
    Record record;

    origin = initialOrigin;
    while ((record = m.nextRecord()) != null) maybeAddRecord(record, cache, file);
    validate();
  }
Exemplo n.º 3
0
 /*
  * Main method.
  */
 public static void main(String[] args) {
   try {
     Master m = new Master();
     m.run();
   } catch (IOException e) {
     overwriteFile("Required files not found!!", "log_error.txt");
     return;
   }
 }
Exemplo n.º 4
0
  /**
   * Creates a Zone from the records in the specified master file.
   *
   * @param zone The name of the zone.
   * @param file The master file to read from.
   * @see Master
   */
  public Zone(Name zone, String file) throws IOException {
    data = new HashMap();
    type = PRIMARY;

    if (zone == null) throw new IllegalArgumentException("no zone name specified");
    Master m = new Master(file, zone);
    Record record;

    origin = zone;
    while ((record = m.nextRecord()) != null) maybeAddRecord(record);
    validate();
  }
Exemplo n.º 5
0
 public void checkFor14DaysItems(Master m) {
   for (int i = 0; i < currentItems.size(); ) {
     if (((Item) currentItems.get(i)).daysSinceArraival == 13) {
       if (((Item) currentItems.get(i)).type.equals("letter") == true
           && ((Item) currentItems.get(i)).returnRecipent.equals("") == false) {
         m.commandLETTER(
             new String(((Item) currentItems.get(i)).toOffice),
             new String(((Item) currentItems.get(i)).returnRecipent),
             new String(((Item) currentItems.get(i)).fromOffice),
             "",
             ((Item) currentItems.get(i)).dayGotInSystem);
         currentItems.remove(i);
         i = 0;
       } else if (((Item) currentItems.get(i)).type.equals("package") == true
           || (((Item) currentItems.get(i)).type.equals("letter") == true
               && ((Item) currentItems.get(i)).returnRecipent.equals("") == true)) {
         if (((Item) currentItems.get(i)).type.equals("letter")) {
           destroyedLetterEntry("log_" + name + ".txt", name);
           destroyedLetterEntry("log_master.txt", name);
         } else {
           destroyedPackageEntry("log_" + name + ".txt", name);
           destroyedPackageEntry("log_master.txt", name);
         }
         currentItems.remove(i);
         i = 0;
       }
     } else {
       ++i;
     }
   }
 }
Exemplo n.º 6
0
  /** Returns the next record in the master file */
  public Record nextRecord() throws IOException {
    String line;
    MyStringTokenizer st;

    if (included != null) {
      Record rec = included.nextRecord();
      if (rec != null) return rec;
      included = null;
    }
    while (true) {
      line = readExtendedLine(br);
      if (line == null) return null;
      if (line.length() == 0 || line.startsWith(";")) continue;

      boolean space = line.startsWith(" ") || line.startsWith("\t");
      st = new MyStringTokenizer(line);

      String s = st.nextToken();
      if (s.equals("$ORIGIN")) {
        origin = parseOrigin(st);
        continue;
      }
      if (s.equals("$TTL")) {
        defaultTTL = parseTTL(st);
        continue;
      }
      if (s.equals("$INCLUDE")) {
        parseInclude(st);
        /*
         * If we continued, we wouldn't be looking in
         * the new file.  Recursing works better.
         */
        return nextRecord();
      } else if (s.charAt(0) == '$') throw new IOException("Invalid directive: " + s);
      st.putBackToken(s);
      return (last = parseRR(st, space, last, origin));
    }
  }
Exemplo n.º 7
0
 public static void main(String[] args) {
   Execution.run(args, "SerializedDumperMain", new SerializedDumper(), Master.getOptionsParser());
 }