com.bigllc.retsiq.simpleclient.util
Class DateFieldSearchStrategy

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

public class DateFieldSearchStrategy
extends DivideAndConquerStrategy<java.util.Date>

Search strategy for full download using an date sensitive field such as list date. The granularity is down to the day. 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
DateFieldSearchStrategy(int recordCountLimit, java.lang.String fieldName, java.util.Date startValue, java.util.Date endValue, java.util.TimeZone zone)
          Create a strategy that is based around an date and time sensitive field.
 
Method Summary
protected  java.util.Date getMidPoint(java.util.Date startDate, java.util.Date endDate)
          Get the mid point of the two supplied value, rounding down however that applies to the type.
protected  java.lang.String getSearchValue(java.util.Date value)
          Return the value as a string that is valid for a DMQL2 query for that data type.
protected  java.util.Date incrementValue(java.util.Date value)
          Increment by a second.
protected  boolean valuesEqual(java.util.Date startDate, java.util.Date endDate)
          Equal to the second
 
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

DateFieldSearchStrategy

public DateFieldSearchStrategy(int recordCountLimit,
                               java.lang.String fieldName,
                               java.util.Date startValue,
                               java.util.Date endValue,
                               java.util.TimeZone zone)
Create a strategy that is based around an date and time sensitive 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 could be the epoch date
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.util.Date getMidPoint(java.util.Date startDate,
                                     java.util.Date endDate)
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.util.Date>
Parameters:
startDate - the lower bounded value
endDate - the upper bounded value
Returns:
the midpoint rounded down however that is applicable

getSearchValue

protected java.lang.String getSearchValue(java.util.Date 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.util.Date>
Parameters:
value - the value
Returns:
the DMQL2 valid string format of the value

incrementValue

protected java.util.Date incrementValue(java.util.Date value)
Increment by a second.

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

valuesEqual

protected boolean valuesEqual(java.util.Date startDate,
                              java.util.Date endDate)
Equal to the second

Specified by:
valuesEqual in class DivideAndConquerStrategy<java.util.Date>
Parameters:
startDate - the value to compare against
endDate - the value to compare to
Returns:
true if they are equal, false otherwise