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

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

public class BBIPOctet
extends Object

This class is responsible for parsing an individual octet from an IPLIKE ip string. This octet can be a single number, a * (which gets transformed into the range 0-255), a range consisting of a low value seperated from a high value with a dash, or a combination of the above seperated by a comma (note: * will only ever appear by itself in a range).

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

Field Summary
private static int HIGH_VALUE
          This is the highest value a member of a range octet can be.
private static int LOW_VALUE
          This is the lowest value a member of a range octet can be.
private  Vector ranges
          This vector will hold the list of ranges found in an octet.
 
Constructor Summary
BBIPOctet(String anOctet)
          A constructor that parses an octet into its individual ranges.
 
Method Summary
 Range getRange(int index)
          This method returns the Range object at a given index of an octet.
private  String getRangeString(int index)
          This method reconstructs a range into a string representation
 int numRanges()
          This method returns the number of ranges found in the octet
private  void parseRange(String rangeString)
          This method will parse an indiviual range (that was delimited by commas) and store it in the ranges vector.
 String toString()
          This method reconstructs a representation of the original octet with all ranges.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

ranges

private Vector ranges
This vector will hold the list of ranges found in an octet.

LOW_VALUE

private static final int LOW_VALUE
This is the lowest value a member of a range octet can be.

HIGH_VALUE

private static final int HIGH_VALUE
This is the highest value a member of a range octet can be.
Constructor Detail

BBIPOctet

public BBIPOctet(String anOctet)
A constructor that parses an octet into its individual ranges.
Parameters:
String - anOctet, the octet string to be parsed
Method Detail

getRangeString

private String getRangeString(int index)
This method reconstructs a range into a string representation
Parameters:
int - index, the index of the range to reconstruct
Returns:
String, the ranges recombined into its original string

parseRange

private void parseRange(String rangeString)
This method will parse an indiviual range (that was delimited by commas) and store it in the ranges vector.
Parameters:
String - rangeString, the range to be parsed

numRanges

public int numRanges()
This method returns the number of ranges found in the octet
Returns:
int, the number of ranges in this octet

getRange

public Range getRange(int index)
This method returns the Range object at a given index of an octet.
Returns:
Range, the Range objec for this index

toString

public String toString()
This method reconstructs a representation of the original octet with all ranges.
Overrides:
toString in class Object
Returns:
String, the reconstructed octet