1 // Copyright (c) 2004 Brian Wellington (bwelling (at) xbill.org) 2 3 package org.xbill.DNS; 4 5 import 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 14 public class NULLRecord extends Record { 15 16 private static final long serialVersionUID = -5796493183235216538L; 17 18 private byte [] data; 19 20 NULLRecord() {} 21 22 Record 23 getObject() { 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 */ 31 public 32 NULLRecord(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 41 void 42 rrFromWire(DNSInput in) throws IOException { 43 data = in.readByteArray(); 44 } 45 46 void 47 rdataFromString(Tokenizer st, Name origin) throws IOException { 48 throw st.exception("no defined text format for NULL records"); 49 } 50 51 String 52 rrToString() { 53 return unknownToString(data); 54 } 55 56 /** Returns the contents of this record. */ 57 public byte [] 58 getData() { 59 return data; 60 } 61 62 void 63 rrToWire(DNSOutput out, Compression c, boolean canonical) { 64 out.writeByteArray(data); 65 } 66 67 } 68