Builds a new Record from its textual representation @param name The owner name of the record. @param type The record's type. @param dclass The record's class. @param ttl The record's time to live. @param st A tokenizer containing the textual representation of the rdata. @param origin The default ori
(Name name, int type, int dclass, long ttl, Tokenizer st, Name origin)
| 443 | * @throws IOException The text format was invalid. |
| 444 | */ |
| 445 | public static Record |
| 446 | fromString(Name name, int type, int dclass, long ttl, Tokenizer st, Name origin) |
| 447 | throws IOException |
| 448 | { |
| 449 | Record rec; |
| 450 | |
| 451 | if (!name.isAbsolute()) |
| 452 | throw new RelativeNameException(name); |
| 453 | Type.check(type); |
| 454 | DClass.check(dclass); |
| 455 | TTL.check(ttl); |
| 456 | |
| 457 | Tokenizer.Token t = st.get(); |
| 458 | if (t.type == Tokenizer.IDENTIFIER && t.value.equals("\\#")) { |
| 459 | int length = st.getUInt16(); |
| 460 | byte [] data = st.getHex(); |
| 461 | if (data == null) { |
| 462 | data = new byte[0]; |
| 463 | } |
| 464 | if (length != data.length) |
| 465 | throw st.exception("invalid unknown RR encoding: " + |
| 466 | "length mismatch"); |
| 467 | DNSInput in = new DNSInput(data); |
| 468 | return newRecord(name, type, dclass, ttl, length, in); |
| 469 | } |
| 470 | st.unget(); |
| 471 | rec = getEmptyRecord(name, type, dclass, ttl, true); |
| 472 | rec.rdataFromString(st, origin); |
| 473 | t = st.get(); |
| 474 | if (t.type != Tokenizer.EOL && t.type != Tokenizer.EOF) { |
| 475 | throw st.exception("unexpected tokens at end of record"); |
| 476 | } |
| 477 | return rec; |
| 478 | } |
| 479 | |
| 480 | /** |
| 481 | * Builds a new Record from its textual representation |
no test coverage detected