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 | * Mailbox information Record - lists the address responsible for a mailing |
| 9 | * list/mailbox and the address to receive error messages relating to the |
| 10 | * mailing list/mailbox. |
| 11 | * |
| 12 | * @author Brian Wellington |
| 13 | */ |
| 14 | |
| 15 | public class MINFORecord extends Record { |
| 16 | |
| 17 | private static final long serialVersionUID = -3962147172340353796L; |
| 18 | |
| 19 | private Name responsibleAddress; |
| 20 | private Name errorAddress; |
| 21 | |
| 22 | MINFORecord() {} |
| 23 | |
| 24 | Record |
| 25 | getObject() { |
| 26 | return new MINFORecord(); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Creates an MINFO Record from the given data |
| 31 | * @param responsibleAddress The address responsible for the |
| 32 | * mailing list/mailbox. |
| 33 | * @param errorAddress The address to receive error messages relating to the |
| 34 | * mailing list/mailbox. |
| 35 | */ |
| 36 | public |
| 37 | MINFORecord(Name name, int dclass, long ttl, |
| 38 | Name responsibleAddress, Name errorAddress) |
| 39 | { |
| 40 | super(name, Type.MINFO, dclass, ttl); |
| 41 | |
| 42 | this.responsibleAddress = checkName("responsibleAddress", |
| 43 | responsibleAddress); |
| 44 | this.errorAddress = checkName("errorAddress", errorAddress); |
| 45 | } |
| 46 | |
| 47 | void |
| 48 | rrFromWire(DNSInput in) throws IOException { |
| 49 | responsibleAddress = new Name(in); |
| 50 | errorAddress = new Name(in); |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | rdataFromString(Tokenizer st, Name origin) throws IOException { |
| 55 | responsibleAddress = st.getName(origin); |
| 56 | errorAddress = st.getName(origin); |
| 57 | } |
| 58 | |
| 59 | /** Converts the MINFO Record to a String */ |
| 60 | String |
| 61 | rrToString() { |
| 62 | StringBuffer sb = new StringBuffer(); |
| 63 | sb.append(responsibleAddress); |
| 64 | sb.append(" "); |
| 65 | sb.append(errorAddress); |
| 66 | return sb.toString(); |
| 67 | } |
| 68 | |
| 69 | /** Gets the address responsible for the mailing list/mailbox. */ |
| 70 | public Name |
| 71 | getResponsibleAddress() { |
| 72 | return responsibleAddress; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Gets the address to receive error messages relating to the mailing |
| 77 | * list/mailbox. |
| 78 | */ |
| 79 | public Name |
| 80 | getErrorAddress() { |
| 81 | return errorAddress; |
| 82 | } |
| 83 | |
| 84 | void |
| 85 | rrToWire(DNSOutput out, Compression c, boolean canonical) { |
| 86 | responsibleAddress.toWire(out, null, canonical); |
| 87 | errorAddress.toWire(out, null, canonical); |
| 88 | } |
| 89 | |
| 90 | } |