com.sun.slamd.example
Class NumericRange

java.lang.Object
  extended by com.sun.slamd.example.NumericRange

public class NumericRange
extends java.lang.Object

This class defines a data structure for representing a numeric range. The range can select values seuqentially or at random, in increasing or decreasing order and with varying increments.

Author:
Neil A. Wilson

Constructor Summary
NumericRange(int lowerBound, int upperBound, boolean sequential, int increment, java.util.Random random, java.text.NumberFormat format)
          Creates a new numeric range with the provided information.
NumericRange(java.lang.String valueString)
          Creates a new numeric range that will always returned.
 
Method Summary
 int getLowerBound()
          Retrieves the lower bound for this numeric range.
 int getSequentialIncrement()
          Retrieves the sequential increment that will be used for this numeric range.
 java.lang.String getStringValue()
          Retrieves the string value for this element.
 int getUpperBound()
          Retrieves the upper bound for this numeric range.
 boolean isNumeric()
          Indicates whether the value of this element is numeric or a string.
 boolean isSequential()
          Indicates whether the numeric range is configured to select values in sequential order or at random.
 void nextValue(java.lang.StringBuffer buffer)
          Appends the next value in the range to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumericRange

public NumericRange(int lowerBound,
                    int upperBound,
                    boolean sequential,
                    int increment,
                    java.util.Random random,
                    java.text.NumberFormat format)
Creates a new numeric range with the provided information.

Parameters:
lowerBound - The lower bound to use for the range.
upperBound - The upper bound to use for the range.
sequential - Indicates whether to iterate through the values in sequential order or at random.
increment - The increment to use for iterating through the values in sequential order.
random - The random number generator to use to construct the random values.
format - The number formatter to use if special formatting is required for the value. It may be null if no special formatting is required.

NumericRange

public NumericRange(java.lang.String valueString)
Creates a new numeric range that will always returned.

Parameters:
valueString - The value string to use instead of a numeric range.
Method Detail

nextValue

public void nextValue(java.lang.StringBuffer buffer)
Appends the next value in the range to the provided buffer.

Parameters:
buffer - The buffer to which the value should be appended.

isNumeric

public boolean isNumeric()
Indicates whether the value of this element is numeric or a string.

Returns:
true if this element is numeric, or false if the value is a string.

isSequential

public boolean isSequential()
Indicates whether the numeric range is configured to select values in sequential order or at random. This method is only relevant for cases in which isNumeric returns true.

Returns:
true if the values are chosen in sequential order, or false if they are random.

getLowerBound

public int getLowerBound()
Retrieves the lower bound for this numeric range. This method is only relevant for cases in which isNumeric returns true.

Returns:
The lower bound for this numeric range.

getUpperBound

public int getUpperBound()
Retrieves the upper bound for this numeric range. This method is only relevant for cases in which isNumeric returns true.

Returns:
The upper bound for this numeric range.

getSequentialIncrement

public int getSequentialIncrement()
Retrieves the sequential increment that will be used for this numeric range. This is only relevant for cases in which both isNumeric and isSequential return true.

Returns:
The sequential increment that will be used for this numeric range.

getStringValue

public java.lang.String getStringValue()
Retrieves the string value for this element. This is only relevant for cases in which isNumeric returns false.

Returns:
The string value for this element.