Venice 0.7beta

org.mov.analyser
Class OrderComparator

java.lang.Object
  extended by org.mov.analyser.OrderComparator
All Implemented Interfaces:
java.util.Comparator

public class OrderComparator
extends java.lang.Object
implements java.util.Comparator

This comparator orders the stock quotes on a given date. The GP allows the user or order the evaluation of stock quotes, by several criteria such as unordered, alphabetically by symbol, volume decreasing etc. This comparator performs the ordering.

Author:
Andrew Leppard
See Also:
OrderCache, QuoteRangePage

Field Summary
static int CHANGE_DECREASING
          Order the stock symbols by the highest change on the date.
static int CHANGE_INCREASING
          Order the stock symbols by the lowest change on the date.
static int DAY_CLOSE_DECREASING
          Order the stock symbols by the highest day close on the date.
static int DAY_CLOSE_INCREASING
          Order the stock symbols by the lowest day close on the date.
static int DAY_HIGH_DECREASING
          Order the stock symbols by the highest day high on the date.
static int DAY_HIGH_INCREASING
          Order the stock symbols by the lowest day high on the date.
static int DAY_LOW_DECREASING
          Order the stock symbols by the highest day low on the date.
static int DAY_LOW_INCREASING
          Order the stock symbols by the lowest day low on the date.
static int DAY_OPEN_DECREASING
          Order the stock symbols by the highest day open on the date.
static int DAY_OPEN_INCREASING
          Order the stock symbols by the lowest day open on the date.
static int DAY_VOLUME_DECREASING
          Order the stock symbols by the highest volume on the date.
static int DAY_VOLUME_INCREASING
          Order the stock symbols by the lowest volume on the date.
static int EQUATION
          Order the stock symbols by the given equation.
static int NO_ORDER
          Don't order the stock symbols.
static int STOCK_SYMBOL
          Order the stock symbols alphabetically.
 
Constructor Summary
OrderComparator(EODQuoteBundle quoteBundle, Expression orderByEquation)
          Create a new order comparator that will order the quotes in the given quote bundle using the given equation.
OrderComparator(EODQuoteBundle quoteBundle, int orderByKey)
          Create a new order comparator that will order the quotes in the given quote bundle using the given order.
 
Method Summary
 int compare(java.lang.Object object1, java.lang.Object object2)
          Compare two stock symbols on the date set by setDateOffset(int).
 int getOrderByKey()
          Return the method of ordering.
 boolean isOrdered()
          Return whether the stock quotes are ordered.
 void setDateOffset(int dateOffset)
          Set the date to order the stock quotes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

NO_ORDER

public static final int NO_ORDER
Don't order the stock symbols.

See Also:
Constant Field Values

STOCK_SYMBOL

public static final int STOCK_SYMBOL
Order the stock symbols alphabetically.

See Also:
Constant Field Values

DAY_VOLUME_DECREASING

public static final int DAY_VOLUME_DECREASING
Order the stock symbols by the highest volume on the date.

See Also:
Constant Field Values

DAY_VOLUME_INCREASING

public static final int DAY_VOLUME_INCREASING
Order the stock symbols by the lowest volume on the date.

See Also:
Constant Field Values

DAY_LOW_DECREASING

public static final int DAY_LOW_DECREASING
Order the stock symbols by the highest day low on the date.

See Also:
Constant Field Values

DAY_LOW_INCREASING

public static final int DAY_LOW_INCREASING
Order the stock symbols by the lowest day low on the date.

See Also:
Constant Field Values

DAY_HIGH_DECREASING

public static final int DAY_HIGH_DECREASING
Order the stock symbols by the highest day high on the date.

See Also:
Constant Field Values

DAY_HIGH_INCREASING

public static final int DAY_HIGH_INCREASING
Order the stock symbols by the lowest day high on the date.

See Also:
Constant Field Values

DAY_OPEN_DECREASING

public static final int DAY_OPEN_DECREASING
Order the stock symbols by the highest day open on the date.

See Also:
Constant Field Values

DAY_OPEN_INCREASING

public static final int DAY_OPEN_INCREASING
Order the stock symbols by the lowest day open on the date.

See Also:
Constant Field Values

DAY_CLOSE_DECREASING

public static final int DAY_CLOSE_DECREASING
Order the stock symbols by the highest day close on the date.

See Also:
Constant Field Values

DAY_CLOSE_INCREASING

public static final int DAY_CLOSE_INCREASING
Order the stock symbols by the lowest day close on the date.

See Also:
Constant Field Values

CHANGE_DECREASING

public static final int CHANGE_DECREASING
Order the stock symbols by the highest change on the date.

See Also:
Constant Field Values

CHANGE_INCREASING

public static final int CHANGE_INCREASING
Order the stock symbols by the lowest change on the date.

See Also:
Constant Field Values

EQUATION

public static final int EQUATION
Order the stock symbols by the given equation.

See Also:
Constant Field Values
Constructor Detail

OrderComparator

public OrderComparator(EODQuoteBundle quoteBundle,
                       int orderByKey)
Create a new order comparator that will order the quotes in the given quote bundle using the given order.

Parameters:
quoteBundle - quote data used for ordering
orderByKey - method of ordering

OrderComparator

public OrderComparator(EODQuoteBundle quoteBundle,
                       Expression orderByEquation)
Create a new order comparator that will order the quotes in the given quote bundle using the given equation.

Parameters:
quoteBundle - quote data used for ordering
orderByEquation - equation used for ordering
Method Detail

getOrderByKey

public int getOrderByKey()
Return the method of ordering. If the quotes will be ordered by equation then this function will return EQUATION.

Returns:
order key

isOrdered

public boolean isOrdered()
Return whether the stock quotes are ordered.

Returns:
true if the order is not NO_ORDER.

setDateOffset

public void setDateOffset(int dateOffset)
Set the date to order the stock quotes.

Parameters:
dateOffset - fast access date offset

compare

public int compare(java.lang.Object object1,
                   java.lang.Object object2)
Compare two stock symbols on the date set by setDateOffset(int).

Specified by:
compare in interface java.util.Comparator
Parameters:
object1 - first symbol
object2 - second symbol
Returns:
-1 if the first symbol comes first, 0 if the symbols are equal OR 1 if the first symbol comes last.

Venice 0.7beta