aboutsummaryrefslogtreecommitdiff
path: root/src/org/xbill/DNS/U16NameBase.java
blob: df3c836457ae4f9e42ec9a220f41a949204b8865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) 2004 Brian Wellington (bwelling@xbill.org)

package org.xbill.DNS;

import java.io.*;

/**
 * Implements common functionality for the many record types whose format
 * is an unsigned 16 bit integer followed by a name.
 *
 * @author Brian Wellington
 */

abstract class U16NameBase extends Record {

private static final long serialVersionUID = -8315884183112502995L;

protected int u16Field;
protected Name nameField;

protected
U16NameBase() {}

protected
U16NameBase(Name name, int type, int dclass, long ttl) {
	super(name, type, dclass, ttl);
}

protected
U16NameBase(Name name, int type, int dclass, long ttl, int u16Field,
	    String u16Description, Name nameField, String nameDescription)
{
	super(name, type, dclass, ttl);
	this.u16Field = checkU16(u16Description, u16Field);
	this.nameField = checkName(nameDescription, nameField);
}

void
rrFromWire(DNSInput in) throws IOException {
	u16Field = in.readU16();
	nameField = new Name(in);
}

void
rdataFromString(Tokenizer st, Name origin) throws IOException {
	u16Field = st.getUInt16();
	nameField = st.getName(origin);
}

String
rrToString() {
	StringBuffer sb = new StringBuffer();
	sb.append(u16Field);
	sb.append(" ");
	sb.append(nameField);
	return sb.toString();
}

protected int
getU16Field() {
	return u16Field;
}

protected Name
getNameField() {
	return nameField;
}

void
rrToWire(DNSOutput out, Compression c, boolean canonical) {
	out.writeU16(u16Field);
	nameField.toWire(out, null, canonical);
}

}