JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util
Class SeqRangeCollector

java.lang.Object
  |
  +--com.klg.jclass.util.SeqRangeCollector

public class SeqRangeCollector
extends Object

Collect added integer values into ranges defined by specified rules (such as contiguous integers in a sequence, all integers of same value, etc). Call addItem() to add items to ranges. Call done() when done. Call getRanges() to get list of ranges (after first calling done()). Call reset() to begin anew.


Nested Class Summary
 class SeqRangeCollector.Range
          Class holding range.
 
Field Summary
protected  int emptyValue
          Value defining integer that is not part of the range.
protected  int lastItemInCurrentRange
          Last item in current range.
static int RANGE_BREAK_HEX_BOUNDARY
          Range Break: as specified by RangeType and at 0xff boundaries.
static int RANGE_BREAK_NORMAL
          Range Break: as specified by RangeType
static int RANGE_INCREASING_BY_1
          Range: contiguous integers, each member one greater than the previous
static int RANGE_SAME_VALUE
          Range: all integers in a row that have same value.
protected  int rangeBreak
          Extra rule for breaking a range
protected  Vector ranges
          List of ranges found so far.
protected  int rangeType
          Type of range to look for
protected  int sizeOfCurrentRange
          Size of current range.
protected  int startOfCurrentRange
          Start of current range.
 
Constructor Summary
SeqRangeCollector()
          Simple constructor.
 
Method Summary
 void addItem(int item)
          Add the given integer to a range as per the rules defined in the RangeType property.
 void done()
          Finished adding items.
protected  void flushRange(int item)
          End current range, add it to the list of ranges, and start new range with given item.
 int getEmptyValue()
          Set the EmptyValue property, which is used to determine the integer value used as an internal delimiter for ranges.
 int getRangeBreak()
          Set the RangeBreak property, which determines the type of range breaks that will be forced in addition to the rule specified in RangeType; Currently, this value must be one of RANGE_BREAK_NORMAL or RANGE_BREAK_HEX_BOUNDARY.
 List getRanges()
          Get list of ranges created from integer input.
 int getRangeType()
          Get the RangeType property, which determines the type of range that is being tracked.
 void reset()
          Clear range list and reset range tracking variables for starting anew.
 void setEmptyValue(int emptyValue)
          Set the EmptyValue property, which is used to determine the integer value used as an internal delimiter for ranges.
 void setRangeBreak(int rangeBreak)
          Set the RangeBreak property, which determines the type of range breaks that will be forced in addition to the rule specified in RangeType; Currently, this value must be one of RANGE_BREAK_NORMAL or RANGE_BREAK_HEX_BOUNDARY.
 void setRangeType(int rangeType)
          Set the RangeType property, which determines the type of range that is being tracked.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RANGE_INCREASING_BY_1

public static final int RANGE_INCREASING_BY_1
Range: contiguous integers, each member one greater than the previous

See Also:
Constant Field Values

RANGE_SAME_VALUE

public static final int RANGE_SAME_VALUE
Range: all integers in a row that have same value. Not yet implemented.

See Also:
Constant Field Values

RANGE_BREAK_NORMAL

public static final int RANGE_BREAK_NORMAL
Range Break: as specified by RangeType

See Also:
Constant Field Values

RANGE_BREAK_HEX_BOUNDARY

public static final int RANGE_BREAK_HEX_BOUNDARY
Range Break: as specified by RangeType and at 0xff boundaries.

See Also:
Constant Field Values

rangeType

protected int rangeType
Type of range to look for


rangeBreak

protected int rangeBreak
Extra rule for breaking a range


emptyValue

protected int emptyValue
Value defining integer that is not part of the range. Used as delimiter.


startOfCurrentRange

protected int startOfCurrentRange
Start of current range. If equal to empty value, no current range exists.


lastItemInCurrentRange

protected int lastItemInCurrentRange
Last item in current range.


sizeOfCurrentRange

protected int sizeOfCurrentRange
Size of current range.


ranges

protected Vector ranges
List of ranges found so far.

Constructor Detail

SeqRangeCollector

public SeqRangeCollector()
Simple constructor. Will reset range list and other tracking values.

Method Detail

reset

public void reset()
Clear range list and reset range tracking variables for starting anew.


addItem

public void addItem(int item)
Add the given integer to a range as per the rules defined in the RangeType property. This item will either be added to the current range, thereby extending it, or will force the creation of a new range.


done

public void done()
Finished adding items. This must be called before calling getRanges(), otherwise getRanges() will be missing final range.


flushRange

protected void flushRange(int item)
End current range, add it to the list of ranges, and start new range with given item.


getRanges

public List getRanges()
Get list of ranges created from integer input. Make sure to call done() before calling this method, otherwise the returned list of ranges will be missing the current (final) range. Each item in the List is an instance of the SeqRangeCollector.Range inner class.


setRangeType

public void setRangeType(int rangeType)
Set the RangeType property, which determines the type of range that is being tracked. Currently, this value must be RANGE_INCREASING_BY_1.


getRangeType

public int getRangeType()
Get the RangeType property, which determines the type of range that is being tracked. Currently, this value must be RANGE_INCREASING_BY_1.


setRangeBreak

public void setRangeBreak(int rangeBreak)
Set the RangeBreak property, which determines the type of range breaks that will be forced in addition to the rule specified in RangeType; Currently, this value must be one of RANGE_BREAK_NORMAL or RANGE_BREAK_HEX_BOUNDARY.


getRangeBreak

public int getRangeBreak()
Set the RangeBreak property, which determines the type of range breaks that will be forced in addition to the rule specified in RangeType; Currently, this value must be one of RANGE_BREAK_NORMAL or RANGE_BREAK_HEX_BOUNDARY.


setEmptyValue

public void setEmptyValue(int emptyValue)
Set the EmptyValue property, which is used to determine the integer value used as an internal delimiter for ranges. This value must never be a part of the input added to ranges with the addItem() method. By default, the value is -1, but users including negative numbers in their ranges will want to change this something else, such as Integer.MAX_VALUE.


getEmptyValue

public int getEmptyValue()
Set the EmptyValue property, which is used to determine the integer value used as an internal delimiter for ranges. This value must never be a part of the input added to ranges with the addItem() method. By default, the value is -1.


Copyright © 2004 Quest Software Inc..
All rights reserved.