Shuyi Chen | d7955ce | 2013-05-22 14:51:55 -0700 | [diff] [blame] | 1 | // Copyright (c) 2004 Brian Wellington (bwelling@xbill.org) |
| 2 | |
| 3 | package org.xbill.DNS; |
| 4 | |
| 5 | import java.io.*; |
| 6 | |
| 7 | /** |
| 8 | * Implements common functionality for the many record types whose format |
| 9 | * is a single name. |
| 10 | * |
| 11 | * @author Brian Wellington |
| 12 | */ |
| 13 | |
| 14 | abstract class SingleNameBase extends Record { |
| 15 | |
| 16 | private static final long serialVersionUID = -18595042501413L; |
| 17 | |
| 18 | protected Name singleName; |
| 19 | |
| 20 | protected |
| 21 | SingleNameBase() {} |
| 22 | |
| 23 | protected |
| 24 | SingleNameBase(Name name, int type, int dclass, long ttl) { |
| 25 | super(name, type, dclass, ttl); |
| 26 | } |
| 27 | |
| 28 | protected |
| 29 | SingleNameBase(Name name, int type, int dclass, long ttl, Name singleName, |
| 30 | String description) |
| 31 | { |
| 32 | super(name, type, dclass, ttl); |
| 33 | this.singleName = checkName(description, singleName); |
| 34 | } |
| 35 | |
| 36 | void |
| 37 | rrFromWire(DNSInput in) throws IOException { |
| 38 | singleName = new Name(in); |
| 39 | } |
| 40 | |
| 41 | void |
| 42 | rdataFromString(Tokenizer st, Name origin) throws IOException { |
| 43 | singleName = st.getName(origin); |
| 44 | } |
| 45 | |
| 46 | String |
| 47 | rrToString() { |
| 48 | return singleName.toString(); |
| 49 | } |
| 50 | |
| 51 | protected Name |
| 52 | getSingleName() { |
| 53 | return singleName; |
| 54 | } |
| 55 | |
| 56 | void |
| 57 | rrToWire(DNSOutput out, Compression c, boolean canonical) { |
| 58 | singleName.toWire(out, null, canonical); |
| 59 | } |
| 60 | |
| 61 | } |