/** 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); }
/** * 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(); }
/** * 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(); }
/** 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)); } }