|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opennms.bb.dp.discovery.components.IPAddressRange
The IPAddressRange object is used to encapsulate the starting and ending points of a continguous IPv4 Address range. The class can then generate either an Enumeration or Iterator that can be used to cycle through the range of addresses by the object's user.
Inner Class Summary | |
private class |
IPAddressRange.IPAddressRangeGenerator
This class is used to enumerate or iterate through one contiguous set of IP addresses. |
Field Summary | |
private long |
m_begin
The starting address for the object. |
private long |
m_end
The ending address for the object. |
Constructor Summary | |
IPAddressRange(InetAddress start,
InetAddress end)
Creates a new IPAddressRange object that can be used to encapsulate a contiguous range of IP Addresses. |
|
IPAddressRange(String fromIP,
String toIP)
Creates a new IPAddressRange object that can be used to encapsulate a contiguous range of IP Addresses. |
Method Summary | |
private static long |
byteToLong(byte b)
Converts an 8-bit byte to a 64-bit long integer. |
private static long |
convertToLong(byte[] addr)
The convertToLong method takes an array of bytes and shifts them into a long value. |
Enumeration |
elements()
Returns an Enumeration object that can be used to list out all the address contained in the encapsulated range. |
Iterator |
iterator()
Returns an Iterator object that can be used to step through all the address encapsulated in the object. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private long m_begin
private long m_end
Constructor Detail |
public IPAddressRange(String fromIP, String toIP) throws UnknownHostException
Creates a new IPAddressRange object that can be used to encapsulate a contiguous range of IP Addresses. Once created the object can be used to get either an Iterator or Enumeration object to cycle through the list of address encapsulated by this object.
It is important to note that if the address for toIP is greater than fromIP, the values will be swapped so that the iteration is always from the lowest address to the highest address as defined by a 32-bit unsigned quantity.
fromIP
- The starting address, resolved by InetAddress.toIP
- The ending address, resolved by InetAddress.UnknownHostException
- Thrown by the InetAddress
class if the hostname cannot be resolved.InetAddress.getByName(java.lang.String)
public IPAddressRange(InetAddress start, InetAddress end)
Creates a new IPAddressRange object that can be used to encapsulate a contiguous range of IP Addresses. Once created the object can be used to get either an Iterator or Enumeration object to cycle through the list of address encapsulated by this object.
It is important to note that if the address for start is greater than end, the values will be swapped so that the iteration is always from the lowest address to the highest address as defined by a 32-bit unsigned quantity.
start
- The starting address.end
- The ending address.Method Detail |
private static long byteToLong(byte b)
Converts an 8-bit byte to a 64-bit long integer. If the quantity is a sign extended negative number then the value of 256 is added to wrap the conversion into the range of [0..255].
b
- The byte to convertprivate static long convertToLong(byte[] addr)
The convertToLong method takes an array of bytes and shifts them into a long value. The bytes at the front of the array are shifted into the MSB of the long as each new byte is added to the LSB of the long. if the array is of sufficent size the first bytes of the array may be shifted out of the returned long.
addr
- The array to convert to a long.IllegalArgumentException
- Thrown if the addr
parameter is null.public Iterator iterator()
Returns an Iterator object that can be used to step through all the address encapsulated in the object.
public Enumeration elements()
Returns an Enumeration object that can be used to list out all the address contained in the encapsulated range.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |