lt.monarch.math
Class FormulaUtil

java.lang.Object
  extended by lt.monarch.math.FormulaUtil

public class FormulaUtil
extends java.lang.Object


Field Summary
Modifier and Type Field and Description
protected static java.lang.String logDelimiters
          String of possible logical delimiters
protected static java.lang.String[] logOperation
          Array of possible logical operations
protected static java.lang.String operators
          Possible operators
 
Method Summary
Modifier and Type Method and Description
static int compareOperators(java.lang.String op1, java.lang.String op2)
          Compares the operators.
static boolean isBoolean(java.lang.String string)
          Checks if the string is boolean value
static boolean isConstant(java.lang.String string)
          Checks if the string is the constant.
static boolean isDouble(java.lang.String string)
          Checks if the string is double number.
static boolean isExpression(java.lang.String string)
          Checks if the string is numerical formula (not logical)
static boolean isFunction(java.lang.String string)
          Checks if the string is the function.
static boolean isInteger(java.lang.String string)
          Checks if the string is integer number.
static boolean isLeftBracket(java.lang.String string)
          Checks if the string is the left bracket.
static boolean isLogOperator(java.lang.String operation)
          Checks if the string is a logical operation
static boolean isOperator(java.lang.String string)
          Checks if the string is the operator.
static boolean isRightBracket(java.lang.String string)
          Checks if the string is the right bracket.
static boolean isVariable(java.lang.String string)
          Checks if the string is the variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

operators

protected static final java.lang.String operators
Possible operators

See Also:
Constant Field Values

logOperation

protected static final java.lang.String[] logOperation
Array of possible logical operations


logDelimiters

protected static final java.lang.String logDelimiters
String of possible logical delimiters

See Also:
Constant Field Values
Method Detail

isVariable

public static boolean isVariable(java.lang.String string)
Checks if the string is the variable. Variable must start with "variables_prefix" and end with any amount of number (e.g. "x12345")

Parameters:
string - the supplied string that contains one variables_prefix and several (or none) number symbols.
Returns:
True if the string is variable.

compareOperators

public static int compareOperators(java.lang.String op1,
                                   java.lang.String op2)
                            throws java.lang.Exception
Compares the operators. If less equal then false, if greater then true

Parameters:
op1 - First operation
op2 - Second operation
Returns:
Returns positive if first operand is higher priority than the second one. Negative otherwise. Zero if equal.
Throws:
java.lang.Exception - if wrong delimiter has been found

isLeftBracket

public static boolean isLeftBracket(java.lang.String string)
Checks if the string is the left bracket.

Parameters:
string - The supplied string that contains one symbol.
Returns:
True is the string is left bracket.

isRightBracket

public static boolean isRightBracket(java.lang.String string)
Checks if the string is the right bracket.

Parameters:
string - The supplied string that contains one symbol.
Returns:
True is the string is right bracket.

isConstant

public static boolean isConstant(java.lang.String string)
Checks if the string is the constant.

Parameters:
string - The string which contains one symbol.
Returns:
True if the string is a constant.

isFunction

public static boolean isFunction(java.lang.String string)
Checks if the string is the function.

Parameters:
string - The string which contains one symbol
Returns:
True if the string is a function

isDouble

public static boolean isDouble(java.lang.String string)
Checks if the string is double number.

Parameters:
string - The string which contains one or more symbols
Returns:
True if the string is a double number

isInteger

public static boolean isInteger(java.lang.String string)
Checks if the string is integer number.

Parameters:
string - The string which contains one or more symbols
Returns:
True if the string is an integer number

isOperator

public static boolean isOperator(java.lang.String string)
Checks if the string is the operator.

Parameters:
string - The string which contains one or more symbols
Returns:
True if the string is an operator

isLogOperator

public static boolean isLogOperator(java.lang.String operation)
Checks if the string is a logical operation

Parameters:
operation - The string which contains one or more symbols
Returns:
true if it is logical operation

isExpression

public static boolean isExpression(java.lang.String string)
Checks if the string is numerical formula (not logical)

Parameters:
string - string to check
Returns:
true if it has numeric value

isBoolean

public static boolean isBoolean(java.lang.String string)
Checks if the string is boolean value

Parameters:
string - string to check for boolean value
Returns:
true if string is boolean value