home *** CD-ROM | disk | FTP | other *** search
- package org.xbill.DNS;
-
- class Compression {
- private static final int TABLE_SIZE = 17;
- private Entry[] table = new Entry[17];
- private boolean verbose = Options.check("verbosecompression");
-
- public Compression() {
- }
-
- public void add(int pos, Name name) {
- int row = (name.hashCode() & Integer.MAX_VALUE) % 17;
- Entry entry = new Entry();
- entry.name = name;
- entry.pos = pos;
- entry.next = this.table[row];
- this.table[row] = entry;
- if (this.verbose) {
- System.err.println("Adding " + name + " at " + pos);
- }
-
- }
-
- public int get(Name name) {
- int row = (name.hashCode() & Integer.MAX_VALUE) % 17;
- int pos = -1;
-
- for(Entry entry = this.table[row]; entry != null; entry = entry.next) {
- if (entry.name.equals(name)) {
- pos = entry.pos;
- }
- }
-
- if (this.verbose) {
- System.err.println("Looking for " + name + ", found " + pos);
- }
-
- return pos;
- }
- }
-