com.bigllc.retsiq.simpleclient.util
Class IntegerFieldSearchStrategy

java.lang.Object
  extended by com.bigllc.retsiq.simpleclient.util.DivideAndConquerStrategy<java.lang.Integer>
      extended by com.bigllc.retsiq.simpleclient.util.IntegerFieldSearchStrategy
All Implemented Interfaces:
SearchStrategy

public class IntegerFieldSearchStrategy
extends DivideAndConquerStrategy<java.lang.Integer>

Search strategy for full download using an integer based field such as list price. This checks a record count for a range of the field supplied. If the count falls within the record limit then the query is added to the stack. If it exceed the limit then the range is halved. When search queries have been created to allow a full listing download the queries are all executed sequentially.

Author:
Marc G. Smith

Constructor Summary
IntegerFieldSearchStrategy(int recordCountLimit, java.lang.String fieldName, int startValue, int endValue)
          Create a strategy that is based around an integer field.
 
Method Summary
protected  java.lang.Integer getMidPoint(java.lang.Integer start, java.lang.Integer end)
          Get the mid point of the two supplied value, rounding down however that applies to the type.
protected  java.lang.String getSearchValue(java.lang.Integer value)
          Return the value as a string that is valid for a DMQL2 query for that data type.
protected  java.lang.Integer incrementValue(java.lang.Integer value)
          Increment the value by one unit whatever that means for the type.
protected  boolean valuesEqual(java.lang.Integer start, java.lang.Integer end)
          Compare the two values for equality.
 
Methods inherited from class com.bigllc.retsiq.simpleclient.util.DivideAndConquerStrategy
getQueryBatches, search
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegerFieldSearchStrategy

public IntegerFieldSearchStrategy(int recordCountLimit,
                                  java.lang.String fieldName,
                                  int startValue,
                                  int endValue)
Create a strategy that is based around an integer field.

Parameters:
recordCountLimit - the limit for each search, this should be less than any limit imposed by the server
fieldName - the name of the field to be used for dividing and conquering searches. For example the list price
startValue - The inclusive start value of the range to query, typically this would be 0
endValue - The inclusive end value of the range to query. A further query is executed for anything above this value to catch outliers.
Method Detail

getMidPoint

protected java.lang.Integer getMidPoint(java.lang.Integer start,
                                        java.lang.Integer end)
Description copied from class: DivideAndConquerStrategy
Get the mid point of the two supplied value, rounding down however that applies to the type. So for an integer this would be akin to ((end - start) / 2) + start.

Specified by:
getMidPoint in class DivideAndConquerStrategy<java.lang.Integer>
Parameters:
start - the lower bounded value
end - the upper bounded value
Returns:
the midpoint rounded down however that is applicable

getSearchValue

protected java.lang.String getSearchValue(java.lang.Integer value)
Description copied from class: DivideAndConquerStrategy
Return the value as a string that is valid for a DMQL2 query for that data type.

Specified by:
getSearchValue in class DivideAndConquerStrategy<java.lang.Integer>
Parameters:
value - the value
Returns:
the DMQL2 valid string format of the value

incrementValue

protected java.lang.Integer incrementValue(java.lang.Integer value)
Description copied from class: DivideAndConquerStrategy
Increment the value by one unit whatever that means for the type.

Specified by:
incrementValue in class DivideAndConquerStrategy<java.lang.Integer>
Parameters:
value - the value to increment
Returns:
the incremented value

valuesEqual

protected boolean valuesEqual(java.lang.Integer start,
                              java.lang.Integer end)
Description copied from class: DivideAndConquerStrategy
Compare the two values for equality. This is used for the escape condition if the granularity is to coarse for the record limit.

Specified by:
valuesEqual in class DivideAndConquerStrategy<java.lang.Integer>
Parameters:
start - the value to compare against
end - the value to compare to
Returns:
true if they are equal, false otherwise