com.mytrendtimer.trendtimer
Class Checker

java.lang.Object
  extended by com.mytrendtimer.trendtimer.Checker

public class Checker
extends java.lang.Object

Generic implementation of some checks for : config file content (datatypes, mandatory etc...), current situation (result of last calculation), arguments given to the main method. This class also increase the number of (WARN) warnings found and raise (ERROR) exception.

Version:
v0.92
Author:
FRM

Field Summary
static int MAX_DAILY_PERC_QUOTE_CHANGE_ERR
          Raise Fatal Error daily quote percent change if above that.
static int NBR_DAY_OBSOLETE_QUOTE_WARN
          Number of days before the current date before last quote in file is considered obsolete (and a warning is raised)
static float SIGNAL_STRENGTH_HIGHER_LIMIT_WARN
          Higher signal strength.
static float SIGNAL_STRENGTH_LOWER_LIMIT_WARN
          Lower signal strength.
 
Constructor Summary
Checker(java.util.Date referenceDateArg, java.util.Date currentQuoteDateArg, float currentStrengthArg, float currentOsc2Arg, float currentQuoteArg, QuoteSourceFile quoteSourceFileArg)
          Main constructor used to store data about current situation (result of last calculation).
 
Method Summary
static void checkArgRelationship(int osc1DaysArg, int osc2DaysArg)
          ERROR : Check arg1 and arg2 relationship
static int[] checkArgs(java.lang.String[] argsToCheck)
          ERROR : Check that we have the correct number of arguments and that integers passed arguments to the main method are correct.
static void checkBigPercChange(float percChangeArg, int maxDailyPercQuoteChangeWarnNameArg, java.lang.String quoteDateArg, int lineNumberArg, MyTrendTimer myTTArg)
          WARN : Check for big percent change in quote file
static void checkDateGap(int dateDiffInDaysArg, int maxDayGapWarnNameArg, java.lang.String quoteDateArg, int lineNumberArg, MyTrendTimer myTTArg)
          WARN : Check for date gap in quote file
static void checkDuplicateQuote(float quoteArg, float prevQuoteArg, java.lang.String quoteDateArg, int fileLineNumberArg, MyTrendTimer myTTArg)
          WARN : Check duplicate quotes (same quote for 2 consecutive days)
static void checkHoleSplit(float percChangeArg, java.lang.String quoteDateArg, int lineNumberArg, QuoteSourceFile quoteSrcArg)
          ERROR : Check for hole (split) in quote file
static boolean checkIsBoolean(java.lang.String boolToCheckArg)
          Check value is a real boolean and return it.
static float checkIsFloat(java.lang.String floatToCheckArg, java.lang.String errorMsgArg)
          ERROR : Check value is a float and return it
static int checkIsInteger(java.lang.String intToCheckArg, java.lang.String errorMsgArg)
          ERROR : Check value is an integer and return it
static void checkIsWritableDir(java.lang.String dirToCheckArg, java.lang.String errorMsgArg)
          ERROR : Check that we have a writable directory
static void checkNbrOfDigits(int nbrOfDigitsNameArg)
          ERROR : Check number of digits provided in xml config file
static void checkNegativeQuote(float quoteArg, int fileLineNumberArg, QuoteSourceFile quoteSrcArg)
          ERROR : Check negative quote
static void checkNotNull(java.lang.String strToCheckArg, java.lang.String errorMsgArg)
          ERROR : Check value is not null.
 boolean checkObsolete(MyTrendTimer myTTArg)
          WARN : Check that last price is not obsolete
 boolean checkQuoteBelowOcs2(MyTrendTimer myTTArg)
          WARN : Check that last price is above long term trend (osc2)
 boolean checkSignalStrength(MyTrendTimer myTTArg)
          WARN : Check that signal strength is in boundary
static void checkSortOrder(int dateDiffInDaysArg, java.lang.String quoteDateArg, int lineNumberArg, QuoteSourceFile quoteSrcArg)
          ERROR : Check sort order of quote file
static void checkYScaleRelationship(int minYaxisArg, int maxYaxisArg)
          ERROR : Check minYaxis and maxYaxis relationship
static void checkZeroQuote(float quoteArg, int fileLineNumberArg, QuoteSourceFile quoteSrcArg)
          ERROR : Check zero quote
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_DAILY_PERC_QUOTE_CHANGE_ERR

public static final int MAX_DAILY_PERC_QUOTE_CHANGE_ERR
Raise Fatal Error daily quote percent change if above that.

See Also:
Constant Field Values

NBR_DAY_OBSOLETE_QUOTE_WARN

public static final int NBR_DAY_OBSOLETE_QUOTE_WARN
Number of days before the current date before last quote in file is considered obsolete (and a warning is raised)

See Also:
Constant Field Values

SIGNAL_STRENGTH_HIGHER_LIMIT_WARN

public static final float SIGNAL_STRENGTH_HIGHER_LIMIT_WARN
Higher signal strength. A warning is raised when the signal strength is between o and this limit

See Also:
Constant Field Values

SIGNAL_STRENGTH_LOWER_LIMIT_WARN

public static final float SIGNAL_STRENGTH_LOWER_LIMIT_WARN
Lower signal strength. A warning is raised when the signal strength is between this limit and 0

See Also:
Constant Field Values
Constructor Detail

Checker

public Checker(java.util.Date referenceDateArg,
               java.util.Date currentQuoteDateArg,
               float currentStrengthArg,
               float currentOsc2Arg,
               float currentQuoteArg,
               QuoteSourceFile quoteSourceFileArg)
        throws java.lang.Exception
Main constructor used to store data about current situation (result of last calculation).

Parameters:
referenceDateArg - Date used as a reference (usually today) to see if quote is obsolete.
currentQuoteDateArg - Last date in file
currentStrengthArg - Last strength calculated
currentOsc2Arg - Last Osc2 calculated
currentQuoteArg - Last quote in file
Throws:
java.lang.Exception
Method Detail

checkArgRelationship

public static void checkArgRelationship(int osc1DaysArg,
                                        int osc2DaysArg)
                                 throws java.lang.Exception
ERROR : Check arg1 and arg2 relationship

Parameters:
osc1DaysArg - The arg1
osc2DaysArg - The arg2
Throws:
java.lang.Exception

checkArgs

public static int[] checkArgs(java.lang.String[] argsToCheck)
                       throws java.lang.Exception
ERROR : Check that we have the correct number of arguments and that integers passed arguments to the main method are correct.

Parameters:
argsToCheck - Same than args array in the main method
Returns:
checkedIntegerArgs An array of the 2 checked (and correct) integers.
Throws:
java.lang.Exception

checkBigPercChange

public static void checkBigPercChange(float percChangeArg,
                                      int maxDailyPercQuoteChangeWarnNameArg,
                                      java.lang.String quoteDateArg,
                                      int lineNumberArg,
                                      MyTrendTimer myTTArg)
WARN : Check for big percent change in quote file

Parameters:
percChangeArg - The daily percent change between 2 quotes
maxDailyPercQuoteChangeWarnNameArg - The maximum before warning
quoteDateArg - The date of the quote
lineNumberArg - The lineNumber of the file where error was found

checkDateGap

public static void checkDateGap(int dateDiffInDaysArg,
                                int maxDayGapWarnNameArg,
                                java.lang.String quoteDateArg,
                                int lineNumberArg,
                                MyTrendTimer myTTArg)
WARN : Check for date gap in quote file

Parameters:
dateDiffInDaysArg - The difference in days, negative or zero when wrong dates are found in quote file.
maxDayGapWarnNameArg - The maximum before warning
quoteDateArg - The date of the quote
lineNumberArg - The lineNumber of the file where error was found

checkDuplicateQuote

public static void checkDuplicateQuote(float quoteArg,
                                       float prevQuoteArg,
                                       java.lang.String quoteDateArg,
                                       int fileLineNumberArg,
                                       MyTrendTimer myTTArg)
WARN : Check duplicate quotes (same quote for 2 consecutive days)

Parameters:
quoteArg - The quote
prevQuoteArg - The previous quote
quoteDateArg - The date of the quote
fileLineNumberArg - The line number where error was found in file.

checkHoleSplit

public static void checkHoleSplit(float percChangeArg,
                                  java.lang.String quoteDateArg,
                                  int lineNumberArg,
                                  QuoteSourceFile quoteSrcArg)
                           throws java.lang.Exception
ERROR : Check for hole (split) in quote file

Parameters:
percChangeArg - The daily percent change between 2 quotes
quoteDateArg - The date of the quote
lineNumberArg - The lineNumber of the file where error was found
Throws:
java.lang.Exception

checkIsBoolean

public static boolean checkIsBoolean(java.lang.String boolToCheckArg)
Check value is a real boolean and return it. In fact we dont really check because the received string can be either "true" or whatever else, even null. So, it's more a cast than a check.

Parameters:
boolToCheckArg - The supposed boolean to be checked
Returns:
The boolean

checkIsFloat

public static float checkIsFloat(java.lang.String floatToCheckArg,
                                 java.lang.String errorMsgArg)
                          throws java.lang.Exception
ERROR : Check value is a float and return it

Parameters:
floatToCheckArg - The supposed integer to be checked
errorMsgArg - The dynamic error message to raise
Returns:
The float
Throws:
java.lang.Exception

checkIsInteger

public static int checkIsInteger(java.lang.String intToCheckArg,
                                 java.lang.String errorMsgArg)
                          throws java.lang.Exception
ERROR : Check value is an integer and return it

Parameters:
intToCheckArg - The supposed integer to be checked
errorMsgArg - The dynamic error message to raise
Returns:
The integer
Throws:
java.lang.Exception

checkIsWritableDir

public static void checkIsWritableDir(java.lang.String dirToCheckArg,
                                      java.lang.String errorMsgArg)
                               throws java.lang.Exception
ERROR : Check that we have a writable directory

Parameters:
dirToCheckArg - The directory to be checked
errorMsgArg - The dynamic error message to raise
Throws:
java.lang.Exception

checkNbrOfDigits

public static void checkNbrOfDigits(int nbrOfDigitsNameArg)
                             throws java.lang.Exception
ERROR : Check number of digits provided in xml config file

Parameters:
nbrOfDigitsNameArg - The number of digits retreived from xml config file
Throws:
java.lang.Exception

checkNegativeQuote

public static void checkNegativeQuote(float quoteArg,
                                      int fileLineNumberArg,
                                      QuoteSourceFile quoteSrcArg)
                               throws java.lang.Exception
ERROR : Check negative quote

Parameters:
quoteArg - The quote
fileLineNumberArg - The line number where error was found in file.
Throws:
java.lang.Exception

checkNotNull

public static void checkNotNull(java.lang.String strToCheckArg,
                                java.lang.String errorMsgArg)
                         throws java.lang.Exception
ERROR : Check value is not null.

Parameters:
strToCheckArg - The mandatory String to be checked
errorMsgArg - The dynamic error message to raise
Throws:
java.lang.Exception

checkObsolete

public boolean checkObsolete(MyTrendTimer myTTArg)
                      throws java.lang.Exception
WARN : Check that last price is not obsolete

Returns:
boolean set to true if an obsolete quote was found
Throws:
java.lang.Exception

checkQuoteBelowOcs2

public boolean checkQuoteBelowOcs2(MyTrendTimer myTTArg)
WARN : Check that last price is above long term trend (osc2)

Returns:
boolean set to true if quote is below osc2

checkSignalStrength

public boolean checkSignalStrength(MyTrendTimer myTTArg)
WARN : Check that signal strength is in boundary

Returns:
boolean set to true if we are in the boundary

checkSortOrder

public static void checkSortOrder(int dateDiffInDaysArg,
                                  java.lang.String quoteDateArg,
                                  int lineNumberArg,
                                  QuoteSourceFile quoteSrcArg)
                           throws java.lang.Exception
ERROR : Check sort order of quote file

Parameters:
dateDiffInDaysArg - The difference in days, negative or zero when wrong dates are found in quote file.
quoteDateArg - The date of the quote
lineNumberArg - The lineNumber of the file where error was found
Throws:
java.lang.Exception

checkYScaleRelationship

public static void checkYScaleRelationship(int minYaxisArg,
                                           int maxYaxisArg)
                                    throws java.lang.Exception
ERROR : Check minYaxis and maxYaxis relationship

Parameters:
minYaxisArg - The minYaxis (lowest value on Y scale)
maxYaxisArg - The maxYaxis (highest value on Y scale)
Throws:
java.lang.Exception

checkZeroQuote

public static void checkZeroQuote(float quoteArg,
                                  int fileLineNumberArg,
                                  QuoteSourceFile quoteSrcArg)
                           throws java.lang.Exception
ERROR : Check zero quote

Parameters:
quoteArg - The quote
fileLineNumberArg - The line number where error was found in file.
Throws:
java.lang.Exception