01: // Copyright (c) 2004 Brian Wellington (bwelling@xbill.org)
02:
03: package org.xbill.DNS;
04:
05: import java.io.*;
06:
07: /**
08: * X.400 mail mapping record.
09: *
10: * @author Brian Wellington
11: */
12:
13: public class PXRecord extends Record {
14:
15: private int preference;
16: private Name map822;
17: private Name mapX400;
18:
19: PXRecord() {
20: }
21:
22: Record getObject() {
23: return new PXRecord();
24: }
25:
26: /**
27: * Creates an PX Record from the given data
28: * @param preference The preference of this mail address.
29: * @param map822 The RFC 822 component of the mail address.
30: * @param mapX400 The X.400 component of the mail address.
31: */
32: public PXRecord(Name name, int dclass, long ttl, int preference,
33: Name map822, Name mapX400) {
34: super (name, Type.PX, dclass, ttl);
35:
36: this .preference = checkU16("preference", preference);
37: this .map822 = checkName("map822", map822);
38: this .mapX400 = checkName("mapX400", mapX400);
39: }
40:
41: void rrFromWire(DNSInput in) throws IOException {
42: preference = in.readU16();
43: map822 = new Name(in);
44: mapX400 = new Name(in);
45: }
46:
47: void rdataFromString(Tokenizer st, Name origin) throws IOException {
48: preference = st.getUInt16();
49: map822 = st.getName(origin);
50: mapX400 = st.getName(origin);
51: }
52:
53: /** Converts the PX Record to a String */
54: String rrToString() {
55: StringBuffer sb = new StringBuffer();
56: sb.append(preference);
57: sb.append(" ");
58: sb.append(map822);
59: sb.append(" ");
60: sb.append(mapX400);
61: return sb.toString();
62: }
63:
64: void rrToWire(DNSOutput out, Compression c, boolean canonical) {
65: out.writeU16(preference);
66: map822.toWire(out, null, canonical);
67: mapX400.toWire(out, null, canonical);
68: }
69:
70: /** Gets the preference of the route. */
71: public int getPreference() {
72: return preference;
73: }
74:
75: /** Gets the RFC 822 component of the mail address. */
76: public Name getMap822() {
77: return map822;
78: }
79:
80: /** Gets the X.400 component of the mail address. */
81: public Name getMapX400() {
82: return mapX400;
83: }
84:
85: }
|