Java Code Examples for org.xbill.DNS.Record#fromString()

The following examples show how to use org.xbill.DNS.Record#fromString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: update.java    From dnsjava with BSD 2-Clause "Simplified" License 6 votes vote down vote up
Record parseRR(Tokenizer st, int classValue, long TTLValue) throws IOException {
  Name name = st.getName(zone);
  long ttl;
  int type;

  String s = st.getString();

  try {
    ttl = TTL.parseTTL(s);
    s = st.getString();
  } catch (NumberFormatException e) {
    ttl = TTLValue;
  }

  if (DClass.value(s) >= 0) {
    classValue = DClass.value(s);
    s = st.getString();
  }

  if ((type = Type.value(s)) < 0) {
    throw new IOException("Invalid type: " + s);
  }

  return Record.fromString(name, type, classValue, ttl, st, zone);
}
 
Example 2
Source File: update.java    From dnsjava with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void doRequire(Tokenizer st) throws IOException {
  Tokenizer.Token token;
  Name name;
  Record record;
  int type;

  name = st.getName(zone);
  token = st.get();
  if (token.isString()) {
    if ((type = Type.value(token.value)) < 0) {
      throw new IOException("Invalid type: " + token.value);
    }
    token = st.get();
    boolean iseol = token.isEOL();
    st.unget();
    if (!iseol) {
      record = Record.fromString(name, type, defaultClass, 0, st, zone);
    } else {
      record = Record.newRecord(name, type, DClass.ANY, 0);
    }
  } else {
    record = Record.newRecord(name, Type.ANY, DClass.ANY, 0);
  }

  query.addRecord(record, Section.PREREQ);
  print(record);
}
 
Example 3
Source File: update.java    From dnsjava with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void doDelete(Tokenizer st) throws IOException {
  Tokenizer.Token token;
  String s;
  Name name;
  Record record;
  int type;

  name = st.getName(zone);
  token = st.get();
  if (token.isString()) {
    s = token.value;
    if (DClass.value(s) >= 0) {
      s = st.getString();
    }
    if ((type = Type.value(s)) < 0) {
      throw new IOException("Invalid type: " + s);
    }
    token = st.get();
    boolean iseol = token.isEOL();
    st.unget();
    if (!iseol) {
      record = Record.fromString(name, type, DClass.NONE, 0, st, zone);
    } else {
      record = Record.newRecord(name, type, DClass.ANY, 0);
    }
  } else {
    record = Record.newRecord(name, Type.ANY, DClass.ANY, 0);
  }

  query.addRecord(record, Section.UPDATE);
  print(record);
}