Update of /cvsroot/dnsjava/dnsjava/org/xbill/DNS
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14013
Modified Files:
AFSDBRecord.java KXRecord.java MXRecord.java RTRecord.java
Added Files:
U16NameBase.java
Removed Files:
MX_KXRecord.java
Log Message:
Replace MX_KXRecord with U16NameBase; make AFSDB and RT records use it.
--- NEW FILE ---
// Copyright (c) 2004 Brian Wellington (bwelling@...)
package org.xbill.DNS;
import java.io.*;
import org.xbill.DNS.utils.*;
/**
* Implements common functionality for the many record types whose format
* is an unsigned 16 bit integer followed by a name.
*
* @author Brian Wellington
*/
abstract class U16NameBase extends Record {
protected int u16Field;
protected Name nameField;
protected
U16NameBase() {}
protected
U16NameBase(Name name, int type, int dclass, long ttl) {
super(name, type, dclass, ttl);
}
protected
U16NameBase(Name name, int type, int dclass, long ttl, int u16Field,
String u16Description, Name nameField, String nameDescription)
{
super(name, type, dclass, ttl);
this.u16Field = checkU16(u16Description, u16Field);
this.nameField = checkName(nameDescription, nameField);
}
void
rrFromWire(DNSInput in) throws IOException {
u16Field = in.readU16();
nameField = new Name(in);
}
void
rdataFromString(Tokenizer st, Name origin) throws IOException {
u16Field = st.getUInt16();
nameField = st.getName(origin);
}
String
rrToString() {
StringBuffer sb = new StringBuffer();
sb.append(u16Field);
sb.append(" ");
sb.append(nameField);
return sb.toString();
}
protected int
getU16Field() {
return u16Field;
}
protected Name
getNameField() {
return nameField;
}
void
rrToWire(DNSOutput out, Compression c, boolean canonical) {
out.writeU16(u16Field);
nameField.toWire(out, null, canonical);
}
}
Index: AFSDBRecord.java
===================================================================
RCS file: /cvsroot/dnsjava/dnsjava/org/xbill/DNS/AFSDBRecord.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AFSDBRecord.java 4 Mar 2004 23:47:21 -0000 1.4
+++ AFSDBRecord.java 13 Mar 2004 02:21:17 -0000 1.5
@@ -13,10 +13,7 @@
* @author Brian Wellington
*/
-public class AFSDBRecord extends Record {
-
-private int subtype;
-private Name host;
+public class AFSDBRecord extends U16NameBase {
AFSDBRecord() {}
@@ -32,49 +29,19 @@
*/
public
AFSDBRecord(Name name, int dclass, long ttl, int subtype, Name host) {
- super(name, Type.AFSDB, dclass, ttl);
-
- this.subtype = checkU16("subtype", subtype);
- this.host = checkName("host", host);
-}
-
-void
-rrFromWire(DNSInput in) throws IOException {
- subtype = in.readU16();
- host = new Name(in);
-}
-
-void
-rdataFromString(Tokenizer st, Name origin) throws IOException {
- subtype = st.getUInt16();
- host = st.getName(origin);
-}
-
-String
-rrToString() {
- StringBuffer sb = new StringBuffer();
- sb.append(subtype);
- sb.append(" ");
- sb.append(host);
- return sb.toString();
+ super(name, Type.AFSDB, dclass, ttl, subtype, "subtype", host, "host");
}
/** Gets the subtype indicating the service provided by the host. */
public int
getSubtype() {
- return subtype;
+ return getU16Field();
}
/** Gets the host providing service for the domain. */
public Name
getHost() {
- return host;
-}
-
-void
-rrToWire(DNSOutput out, Compression c, boolean canonical) {
- out.writeU16(subtype);
- host.toWire(out, null, canonical);
+ return getNameField();
}
}
Index: KXRecord.java
===================================================================
RCS file: /cvsroot/dnsjava/dnsjava/org/xbill/DNS/KXRecord.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- KXRecord.java 3 Mar 2004 21:07:17 -0000 1.12
+++ KXRecord.java 13 Mar 2004 02:21:17 -0000 1.13
@@ -11,7 +11,7 @@
* @author Brian Wellington
*/
-public class KXRecord extends MX_KXRecord {
+public class KXRecord extends U16NameBase {
KXRecord() {}
@@ -28,7 +28,25 @@
*/
public
KXRecord(Name name, int dclass, long ttl, int preference, Name target) {
- super(name, Type.KX, dclass, ttl, preference, target);
+ super(name, Type.KX, dclass, ttl, preference, "preference",
+ target, "target");
+}
+
+/** Returns the target of the KX record */
+public Name
+getTarget() {
+ return getNameField();
+}
+
+/** Returns the preference of this KX record */
+public int
+getPreference() {
+ return getU16Field();
+}
+
+public Name
+getAdditionalName() {
+ return getNameField();
}
}
Index: MXRecord.java
===================================================================
RCS file: /cvsroot/dnsjava/dnsjava/org/xbill/DNS/MXRecord.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- MXRecord.java 3 Mar 2004 21:07:17 -0000 1.33
+++ MXRecord.java 13 Mar 2004 02:21:17 -0000 1.34
@@ -11,7 +11,7 @@
* @author Brian Wellington
*/
-public class MXRecord extends MX_KXRecord {
+public class MXRecord extends U16NameBase {
MXRecord() {}
@@ -27,9 +27,32 @@
* @param target The host that mail is sent to
*/
public
-MXRecord(Name name, int dclass, long ttl, int priority, Name target)
-{
- super(name, Type.MX, dclass, ttl, priority, target);
+MXRecord(Name name, int dclass, long ttl, int priority, Name target) {
+ super(name, Type.MX, dclass, ttl, priority, "priority",
+ target, "target");
+}
+
+/** Returns the target of the MX record */
+public Name
+getTarget() {
+ return getNameField();
+}
+
+/** Returns the priority of this MX record */
+public int
+getPriority() {
+ return getU16Field();
+}
+
+void
+rrToWire(DNSOutput out, Compression c, boolean canonical) {
+ out.writeU16(u16Field);
+ nameField.toWire(out, c, canonical);
+}
+
+public Name
+getAdditionalName() {
+ return getNameField();
}
}
Index: RTRecord.java
===================================================================
RCS file: /cvsroot/dnsjava/dnsjava/org/xbill/DNS/RTRecord.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RTRecord.java 4 Mar 2004 23:47:21 -0000 1.4
+++ RTRecord.java 13 Mar 2004 02:21:17 -0000 1.5
@@ -11,10 +11,7 @@
* @author Brian Wellington
*/
-public class RTRecord extends Record {
-
-private int preference;
-private Name intermediateHost;
+public class RTRecord extends U16NameBase {
RTRecord() {}
@@ -33,50 +30,20 @@
RTRecord(Name name, int dclass, long ttl, int preference,
Name intermediateHost)
{
- super(name, Type.RT, dclass, ttl);
-
- this.preference = checkU16("preference", preference);
- this.intermediateHost = checkName("intermediateHost", intermediateHost);
-}
-
-void
-rrFromWire(DNSInput in) throws IOException {
- preference = in.readU16();
- intermediateHost = new Name(in);
-}
-
-void
-rdataFromString(Tokenizer st, Name origin) throws IOException {
- preference = st.getUInt16();
- intermediateHost = st.getName(origin);
-}
-
-/** Converts the RT Record to a String */
-String
-rrToString() {
- StringBuffer sb = new StringBuffer();
- sb.append(preference);
- sb.append(" ");
- sb.append(intermediateHost);
- return sb.toString();
+ super(name, Type.RT, dclass, ttl, preference, "preference",
+ intermediateHost, "intermediateHost");
}
/** Gets the preference of the route. */
public int
getPreference() {
- return preference;
+ return getU16Field();
}
/** Gets the host to use as a router. */
public Name
getIntermediateHost() {
- return intermediateHost;
-}
-
-void
-rrToWire(DNSOutput out, Compression c, boolean canonical) {
- out.writeU16(preference);
- intermediateHost.toWire(out, null, canonical);
+ return getNameField();
}
}
--- MX_KXRecord.java DELETED ---
|