com.sun.multicast.allocation
Class IPv4Address

java.lang.Object
  |
  +--com.sun.multicast.allocation.IPv4Address
All Implemented Interfaces:
Address

public class IPv4Address
extends java.lang.Object
implements Address

An IPv4 network address.

Objects of this class and all values returned by their methods are immutable. That is, their values cannot change after they are constructed.


Constructor Summary
IPv4Address(java.net.InetAddress inetAddr)
          Creates an AddressRange with the specified addresses.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this Address with the specified object for order.
 long difference(Address otherAddress)
          Returns the difference between this Address and another one.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 AddressType getAddressType()
          Gets the AddressType of this Address.
 byte[] getBytes()
          Gets a byte array representing this Address.
 int hashCode()
          Returns a hash code value for this object.
 IPv4Address nextAddress()
          Returns the next IPv4Address.
 IPv4Address previousAddress()
          Returns the previous IPv4Address.
 java.net.InetAddress toInetAddress()
          Returns an InetAddress value for the address.
 int toInt()
          Returns an int value for the address.
 long toLong()
          Returns a long value for the address.
 java.lang.String toString()
          Returns a string representation of this IPv4Address.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IPv4Address

public IPv4Address(java.net.InetAddress inetAddr)
Creates an AddressRange with the specified addresses.
Parameters:
startAddress - the first address in the range
endAddress - the last address in the range
Method Detail

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this Address with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

If this address is less than the other one, an integer less than zero is returned. If this address is greater than the other one, an integer greater than zero is returned. If the two addresses are equal, zero is returned. If the two addresses cannot be compared (usually because they are of different AddressTypes), a ClassCastException is thrown.

This method imposes a total ordering on addresses of the same AddressType.

Specified by:
compareTo in interface Address
Parameters:
o - the Object to compare against
Returns:
an integer reflecting the outcome of the comparison
Throws:
java.lang.ClassCastException - if the objects cannot be compared

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one. Two IPv4Addresses are equal if and only if they represent the same address.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object with which to compare
Returns:
true if this object is the same as the reference object, false otherwise.

hashCode

public int hashCode()
Returns a hash code value for this object. The hash code values for two IPv4Addresses are equal if and only if they are equal.
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this IPv4Address

toInt

public int toInt()
Returns an int value for the address.
Returns:
an int value for this IPv4Address

toLong

public long toLong()
Returns a long value for the address.
Returns:
a long value for this IPv4Address

toInetAddress

public java.net.InetAddress toInetAddress()
Returns an InetAddress value for the address.
Returns:
an InetAddress value for this IPv4Address

previousAddress

public IPv4Address previousAddress()
Returns the previous IPv4Address.
Returns:
the previous IPv4Address

nextAddress

public IPv4Address nextAddress()
Returns the next IPv4Address.
Returns:
the next IPv4Address

difference

public long difference(Address otherAddress)
Returns the difference between this Address and another one. If this address is less than the other one, a value greater than zero is returned. If this address is greater than the other one, a value less than zero is returned. If the two addresses are equal, zero is returned.
Parameters:
otherAddress - the Address to do a difference with
Returns:
the difference between this Address and the other one

getBytes

public byte[] getBytes()
Gets a byte array representing this Address.
Specified by:
getBytes in interface Address
Returns:
a byte array representing this Address

getAddressType

public AddressType getAddressType()
Gets the AddressType of this Address.
Specified by:
getAddressType in interface Address
Returns:
the AddressType of this Address

toString

public java.lang.String toString()
Returns a string representation of this IPv4Address.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this IPv4Address


JavaTM Reliable MulticastTM Service version 1.1
Copyright (c) 2001, Sun Microsystems Laboratories, All rights reserved.