예제 #1
0
 public TypeBitmap(Tokenizer st) throws IOException {
   this();
   while (true) {
     Tokenizer.Token t = st.get();
     if (!t.isString()) break;
     int typecode = Type.value(t.value);
     if (typecode < 0) {
       throw st.exception("Invalid type: " + t.value);
     }
     types.add(Mnemonic.toInteger(typecode));
   }
   st.unget();
 }
예제 #2
0
 public TypeBitmap(DNSInput in) throws WireParseException {
   this();
   int lastbase = -1;
   while (in.remaining() > 0) {
     if (in.remaining() < 2) throw new WireParseException("invalid bitmap descriptor");
     int mapbase = in.readU8();
     if (mapbase < lastbase) throw new WireParseException("invalid ordering");
     int maplength = in.readU8();
     if (maplength > in.remaining()) throw new WireParseException("invalid bitmap");
     for (int i = 0; i < maplength; i++) {
       int current = in.readU8();
       if (current == 0) continue;
       for (int j = 0; j < 8; j++) {
         if ((current & (1 << (7 - j))) == 0) continue;
         int typecode = mapbase * 256 + +i * 8 + j;
         types.add(Mnemonic.toInteger(typecode));
       }
     }
   }
 }
예제 #3
0
 public boolean contains(int typecode) {
   return types.contains(Mnemonic.toInteger(typecode));
 }