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