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