|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.netmgt.discovery.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.
Nested Class Summary | |
(package private) static 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 | |
(package private) |
IPAddressRange(java.net.InetAddress start,
java.net.InetAddress end)
Creates a new IPAddressRange object that can be used to encapsulate a contiguous range of IP Addresses. |
(package private) |
IPAddressRange(java.lang.String fromIP,
java.lang.String toIP)
Creates a new IPAddressRange object that can be used to encapsulate a contiguous range of IP Addresses. |
Method Summary | |
(package private) static long |
byteToLong(byte b)
Deprecated. Use org.opennms.netmgt.utils.IPSorter.byteToLong() instead. |
(package private) boolean |
contains(java.net.InetAddress ipAddr)
This method may be used to determine if the specified IP address is contained within the IP address range. |
(package private) boolean |
contains(long ipAddr)
This method may be used to determine if the specified IP address is contained within the IP address range. |
(package private) boolean |
contains(java.lang.String ipAddr)
This method may be used to determine if the specified IP address is contained within the IP address range. |
static long |
convertToLong(byte[] addr)
Deprecated. Use org.opennms.netmgt.utils.IPSorter.convertToLong() instead. |
(package private) java.util.Enumeration |
elements()
Returns an Enumeration object that can be used to list out all the address contained in the encapsulated range. |
(package private) long |
getBeginAddrAsLong()
Returns the begin address of the IP address range as a long value. |
(package private) java.lang.String |
getBeginAddrAsString()
Returns the begin address of the IP address range as a String value. |
(package private) long |
getEndAddrAsLong()
Returns the end address of the IP address range as a long value. |
(package private) java.lang.String |
getEndAddrAsString()
Returns the end address of the IP address range as a String value. |
(package private) static java.lang.String |
IPv4String(int address)
Converts a 32-bit unsigned quantity to a IPv4 dotted decimal string address. |
(package private) static java.lang.String |
IPv4String(long address)
Converts a 64-bit unsigned quantity to a IPv4 dotted decimal string address. |
(package private) java.util.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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private long m_begin
private long m_end
Constructor Detail |
IPAddressRange(java.lang.String fromIP, java.lang.String toIP) throws java.net.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.
java.net.UnknownHostException
- Thrown by the InetAddress class if the hostname cannot be
resolved.InetAddress.getByName(java.lang.String)
IPAddressRange(java.net.InetAddress start, java.net.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 |
java.lang.String getBeginAddrAsString()
java.lang.String getEndAddrAsString()
long getBeginAddrAsLong()
long getEndAddrAsLong()
boolean contains(long ipAddr)
ipAddr
- IP address (long) to compare
boolean contains(java.net.InetAddress ipAddr)
ipAddr
- IP address (InetAddress) to compare
boolean contains(java.lang.String ipAddr) throws java.net.UnknownHostException
ipAddr
- IP address (String) to compare
java.net.UnknownHostException
java.util.Iterator iterator()
Returns an Iterator object that can be used to step through all the address encapsulated in the object.
The iterator returns objects of type
InetAddress
or null
if the
address is unknown.
InetAddress
java.util.Enumeration elements()
Returns an Enumeration object that can be used to list out all the address contained in the encapsulated range.
The iterator returns objects of type
InetAddress
or null
if the
address is unknown.
InetAddress
static java.lang.String IPv4String(long address)
Converts a 64-bit unsigned quantity to a IPv4 dotted decimal string address.
address
- The 64-bit quantity to convert.
static java.lang.String IPv4String(int address)
Converts a 32-bit unsigned quantity to a IPv4 dotted decimal string address.
address
- The 32-bit quantity to convert.
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 convert
public 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.
java.lang.IllegalArgumentException
- Thrown if the addr parameter is null.
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |