org.opennms.bb.common.filter.util
Class BBIPAddress

java.lang.Object
  |
  +--org.opennms.bb.common.filter.util.BBIPAddress

public class BBIPAddress
extends Object

This class is responsible for parsing out an ip octet string into ranges and comma lists.

Version:
$Revision: 1.3 $
Author:
Jason Johns, OpenNMS

Field Summary
private  BBIPOctet[] octets
          Array to of BBIPOctet objects to hold the octet data.
 
Constructor Summary
BBIPAddress(String ipLikeString)
          Constructor to build a BBIPAddress from an octet string mask from an IPLIKE operation.
 
Method Summary
static int getIpAsInteger(String octetString)
          This method returns the octet string as an integer.
static String getIpAsOctetString(int ipAddr)
          This method returns an integer ip address as an octet string.
static String getIpAsOctetString(Integer ipAddr)
          This method returns an integer ip address as an octet string.
 Range getOctetRange(int octetIndex, int rangeIndex)
          This method returns a particular range in a particular octet.
 int numOctetElements(int octetIndex)
          This method calls a method from BBIPOctet to get the number of ranges that occured in the octet.
 int numOctets()
          This method returns the number of octets parse from the original string.
static String[] parseOctets(String octetString)
          This method parses the octetString into distinct octet pieces.
 String toString()
          This method returns the original octet string.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

octets

private BBIPOctet[] octets
Array to of BBIPOctet objects to hold the octet data.
Constructor Detail

BBIPAddress

public BBIPAddress(String ipLikeString)
Constructor to build a BBIPAddress from an octet string mask from an IPLIKE operation.
Parameters:
String - ipLikeString, octet string from IPLIKE operation
Method Detail

parseOctets

public static String[] parseOctets(String octetString)
This method parses the octetString into distinct octet pieces.
Parameters:
String - octetString, original string from IPLIKE operation
Returns:
String [], an array of all octets parsed out

numOctets

public int numOctets()
This method returns the number of octets parse from the original string.
Returns:
int, number of octets

numOctetElements

public int numOctetElements(int octetIndex)
This method calls a method from BBIPOctet to get the number of ranges that occured in the octet.
Parameters:
int - octetIndex, the index of the octet in question
Returns:
int, number of ranges in octet

getOctetRange

public Range getOctetRange(int octetIndex,
                           int rangeIndex)
This method returns a particular range in a particular octet.
Parameters:
int - octetIndex, the index of the octet in question
int - rangeIndex, the index of the range in question
Returns:
Range, a range object for the octet

toString

public String toString()
This method returns the original octet string.
Overrides:
toString in class Object

getIpAsInteger

public static int getIpAsInteger(String octetString)
This method returns the octet string as an integer. Note that there can be no ranges present in the octet string. This basically converts an string ip address to an integer.
Parameters:
String - octetString, the string representation of the ip address
Returns:
int, the integer representation of the ip address

getIpAsOctetString

public static String getIpAsOctetString(int ipAddr)
This method returns an integer ip address as an octet string.
Parameters:
int - ipAddr, the integer representation of the ip address
Returns:
String, the string representation of the ip address

getIpAsOctetString

public static String getIpAsOctetString(Integer ipAddr)
This method returns an integer ip address as an octet string.
Parameters:
Integer - ipAddr, the integer representation of the ip address
Returns:
String, the string representation of the ip address