MXRecord.java revision d7955ce24d294fb2014c59d11fca184471056f44
1// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
2
3package org.xbill.DNS;
4
5/**
6 * Mail Exchange - specifies where mail to a domain is sent
7 *
8 * @author Brian Wellington
9 */
10
11public class MXRecord extends U16NameBase {
12
13private static final long serialVersionUID = 2914841027584208546L;
14
15MXRecord() {}
16
17Record
18getObject() {
19	return new MXRecord();
20}
21
22/**
23 * Creates an MX Record from the given data
24 * @param priority The priority of this MX.  Records with lower priority
25 * are preferred.
26 * @param target The host that mail is sent to
27 */
28public
29MXRecord(Name name, int dclass, long ttl, int priority, Name target) {
30	super(name, Type.MX, dclass, ttl, priority, "priority",
31	      target, "target");
32}
33
34/** Returns the target of the MX record */
35public Name
36getTarget() {
37	return getNameField();
38}
39
40/** Returns the priority of this MX record */
41public int
42getPriority() {
43	return getU16Field();
44}
45
46void
47rrToWire(DNSOutput out, Compression c, boolean canonical) {
48	out.writeU16(u16Field);
49	nameField.toWire(out, c, canonical);
50}
51
52public Name
53getAdditionalName() {
54	return getNameField();
55}
56
57}
58