org.xbill.DNS
Class Serial

java.lang.Object
  extended by org.xbill.DNS.Serial

public final class Serial
extends Object

Helper functions for doing serial arithmetic. These should be used when setting/checking SOA serial numbers. SOA serial number arithmetic is defined in RFC 1982.

Author:
Brian Wellington

Method Summary
static int compare(long serial1, long serial2)
          Compares two numbers using serial arithmetic.
static long increment(long serial)
          Increments a serial number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

compare

public static int compare(long serial1,
                          long serial2)
Compares two numbers using serial arithmetic. The numbers are assumed to be 32 bit unsigned integers stored in longs.

Parameters:
serial1 - The first integer
serial2 - The second integer
Returns:
0 if the 2 numbers are equal, a positive number if serial1 is greater than serial2, and a negative number if serial2 is greater than serial1.
Throws:
IllegalArgumentException - serial1 or serial2 is out of range

increment

public static long increment(long serial)
Increments a serial number. The number is assumed to be a 32 bit unsigned integer stored in a long. This basically adds 1 and resets the value to 0 if it is 2^32.

Parameters:
serial - The serial number
Returns:
The incremented serial number
Throws:
IllegalArgumentException - serial is out of range