01: // Copyright (c) 2004 Brian Wellington (bwelling@xbill.org)
02:
03: package org.xbill.DNS;
04:
05: import java.io.*;
06:
07: /**
08: * The NULL Record. This has no defined purpose, but can be used to
09: * hold arbitrary data.
10: *
11: * @author Brian Wellington
12: */
13:
14: public class NULLRecord extends Record {
15:
16: private byte[] data;
17:
18: NULLRecord() {
19: }
20:
21: Record getObject() {
22: return new NULLRecord();
23: }
24:
25: /**
26: * Creates a NULL record from the given data.
27: * @param data The contents of the record.
28: */
29: public NULLRecord(Name name, int dclass, long ttl, byte[] data) {
30: super (name, Type.NULL, dclass, ttl);
31:
32: if (data.length > 0xFFFF) {
33: throw new IllegalArgumentException(
34: "data must be <65536 bytes");
35: }
36: this .data = data;
37: }
38:
39: void rrFromWire(DNSInput in) throws IOException {
40: data = in.readByteArray();
41: }
42:
43: void rdataFromString(Tokenizer st, Name origin) throws IOException {
44: throw st.exception("no defined text format for NULL records");
45: }
46:
47: String rrToString() {
48: return unknownToString(data);
49: }
50:
51: /** Returns the contents of this record. */
52: public byte[] getData() {
53: return data;
54: }
55:
56: void rrToWire(DNSOutput out, Compression c, boolean canonical) {
57: out.writeByteArray(data);
58: }
59:
60: }
|