01: // Copyright (c) 2004 Brian Wellington (bwelling@xbill.org)
02:
03: package org.xbill.DNS;
04:
05: import java.io.*;
06:
07: /**
08: * Implements common functionality for the many record types whose format
09: * is an unsigned 16 bit integer followed by a name.
10: *
11: * @author Brian Wellington
12: */
13:
14: abstract class U16NameBase extends Record {
15:
16: protected int u16Field;
17: protected Name nameField;
18:
19: protected U16NameBase() {
20: }
21:
22: protected U16NameBase(Name name, int type, int dclass, long ttl) {
23: super (name, type, dclass, ttl);
24: }
25:
26: protected U16NameBase(Name name, int type, int dclass, long ttl,
27: int u16Field, String u16Description, Name nameField,
28: String nameDescription) {
29: super (name, type, dclass, ttl);
30: this .u16Field = checkU16(u16Description, u16Field);
31: this .nameField = checkName(nameDescription, nameField);
32: }
33:
34: void rrFromWire(DNSInput in) throws IOException {
35: u16Field = in.readU16();
36: nameField = new Name(in);
37: }
38:
39: void rdataFromString(Tokenizer st, Name origin) throws IOException {
40: u16Field = st.getUInt16();
41: nameField = st.getName(origin);
42: }
43:
44: String rrToString() {
45: StringBuffer sb = new StringBuffer();
46: sb.append(u16Field);
47: sb.append(" ");
48: sb.append(nameField);
49: return sb.toString();
50: }
51:
52: protected int getU16Field() {
53: return u16Field;
54: }
55:
56: protected Name getNameField() {
57: return nameField;
58: }
59:
60: void rrToWire(DNSOutput out, Compression c, boolean canonical) {
61: out.writeU16(u16Field);
62: nameField.toWire(out, null, canonical);
63: }
64:
65: }
|