@@ -20,7 +20,6 @@ public abstract class Record implements Cloneable, Comparable {
2020protected Name name ;
2121protected int type , dclass ;
2222protected long ttl ;
23- private boolean empty ;
2423
2524private static final Record [] knownRecords = new Record [256 ];
2625private static final Record unknownRecord = new UNKRecord ();
@@ -82,9 +81,12 @@ public abstract class Record implements Cloneable, Comparable {
8281}
8382
8483private static final Record
85- getEmptyRecord (Name name , int type , int dclass , long ttl ) {
86- Record rec = getTypedObject (type );
87- rec = rec .getObject ();
84+ getEmptyRecord (Name name , int type , int dclass , long ttl , boolean hasData ) {
85+ Record rec ;
86+ if (hasData )
87+ rec = getTypedObject (type ).getObject ();
88+ else
89+ rec = new EmptyRecord ();
8890 rec .name = name ;
8991 rec .type = type ;
9092 rec .dclass = dclass ;
@@ -104,17 +106,14 @@ public abstract class Record implements Cloneable, Comparable {
104106{
105107 Record rec ;
106108 int recstart ;
107- rec = getEmptyRecord (name , type , dclass , ttl );
109+ rec = getEmptyRecord (name , type , dclass , ttl , in != null );
108110 if (in != null ) {
109111 if (in .remaining () < length )
110112 throw new WireParseException ("truncated record" );
111113 in .setActive (length );
112- } else
113- rec .empty = true ;
114114
115- rec .rrFromWire (in );
115+ rec .rrFromWire (in );
116116
117- if (in != null ) {
118117 if (in .remaining () > 0 )
119118 throw new WireParseException ("invalid record length" );
120119 in .clearActive ();
@@ -183,9 +182,7 @@ public abstract class Record implements Cloneable, Comparable {
183182 DClass .check (dclass );
184183 TTL .check (ttl );
185184
186- Record rec = getEmptyRecord (name , type , dclass , ttl );
187- rec .empty = true ;
188- return rec ;
185+ return getEmptyRecord (name , type , dclass , ttl , false );
189186}
190187
191188/**
@@ -249,8 +246,7 @@ public abstract class Record implements Cloneable, Comparable {
249246 out .writeU32 (ttl );
250247 int lengthPosition = out .current ();
251248 out .writeU16 (0 ); /* until we know better */
252- if (!empty )
253- rrToWire (out , c , false );
249+ rrToWire (out , c , false );
254250 int rrlength = out .current () - lengthPosition - 2 ;
255251 out .save ();
256252 out .jump (lengthPosition );
@@ -280,8 +276,7 @@ public abstract class Record implements Cloneable, Comparable {
280276 }
281277 int lengthPosition = out .current ();
282278 out .writeU16 (0 ); /* until we know better */
283- if (!empty )
284- rrToWire (out , null , true );
279+ rrToWire (out , null , true );
285280 int rrlength = out .current () - lengthPosition - 2 ;
286281 out .save ();
287282 out .jump (lengthPosition );
@@ -315,8 +310,6 @@ public abstract class Record implements Cloneable, Comparable {
315310 */
316311public byte []
317312rdataToWireCanonical () {
318- if (empty )
319- return new byte [0 ];
320313 DNSOutput out = new DNSOutput ();
321314 rrToWire (out , null , true );
322315 return out .toByteArray ();
@@ -332,8 +325,6 @@ public abstract class Record implements Cloneable, Comparable {
332325 */
333326public String
334327rdataToString () {
335- if (empty )
336- return "" ;
337328 return rrToString ();
338329}
339330
@@ -359,9 +350,10 @@ public abstract class Record implements Cloneable, Comparable {
359350 sb .append ("\t " );
360351 }
361352 sb .append (Type .string (type ));
362- if (!empty ) {
353+ String rdata = rrToString ();
354+ if (!rdata .equals ("" )) {
363355 sb .append ("\t " );
364- sb .append (rrToString () );
356+ sb .append (rdata );
365357 }
366358 return sb .toString ();
367359}
@@ -509,7 +501,7 @@ else if (array[i] == '\\') {
509501 return newRecord (name , type , dclass , ttl , length , in );
510502 }
511503 st .unget ();
512- rec = getEmptyRecord (name , type , dclass , ttl );
504+ rec = getEmptyRecord (name , type , dclass , ttl , true );
513505 rec .rdataFromString (st , origin );
514506 t = st .get ();
515507 if (t .type != Tokenizer .EOL && t .type != Tokenizer .EOF ) {
@@ -607,10 +599,6 @@ else if (array[i] == '\\') {
607599 Record r = (Record ) arg ;
608600 if (type != r .type || dclass != r .dclass || !name .equals (r .name ))
609601 return false ;
610- if (empty && r .empty )
611- return true ;
612- else if (empty || r .empty )
613- return false ;
614602 byte [] array1 = rdataToWireCanonical ();
615603 byte [] array2 = r .rdataToWireCanonical ();
616604 return Arrays .equals (array1 , array2 );
@@ -695,12 +683,6 @@ else if (empty || r.empty)
695683 n = type - arg .type ;
696684 if (n != 0 )
697685 return (n );
698- if (empty && arg .empty )
699- return 0 ;
700- else if (empty )
701- return -1 ;
702- else if (arg .empty )
703- return 1 ;
704686 byte [] rdata1 = rdataToWireCanonical ();
705687 byte [] rdata2 = arg .rdataToWireCanonical ();
706688 for (int i = 0 ; i < rdata1 .length && i < rdata2 .length ; i ++) {
0 commit comments