http://www.eteks.com

com.eteks.jeks
Class JeksFunctionSyntax

java.lang.Object
  |
  +--com.eteks.parser.AbstractSyntax
        |
        +--com.eteks.jeks.ResourceSyntax
              |
              +--com.eteks.jeks.JeksFunctionSyntax
All Implemented Interfaces:
Syntax
Direct Known Subclasses:
JeksExpressionSyntax

public class JeksFunctionSyntax
extends ResourceSyntax

Localized syntax used by the parser to compile user functions.

Since:
Jeks 1.0
Version:
1.0
Author:
Emmanuel Puybaret

Field Summary
static java.lang.Integer JEKS_FUNCTION_AND
           
static java.lang.Integer JEKS_FUNCTION_CHAR
           
static java.lang.Integer JEKS_FUNCTION_CODE
           
static java.lang.Integer JEKS_FUNCTION_DATE
           
static java.lang.Integer JEKS_FUNCTION_DATEVALUE
           
static java.lang.Integer JEKS_FUNCTION_DAY
           
static java.lang.Integer JEKS_FUNCTION_FACT
           
static java.lang.Integer JEKS_FUNCTION_FALSE
           
static java.lang.Integer JEKS_FUNCTION_FIND
           
static java.lang.Integer JEKS_FUNCTION_HOUR
           
static java.lang.Integer JEKS_FUNCTION_MINUTE
           
static java.lang.Integer JEKS_FUNCTION_MODULO
           
static java.lang.Integer JEKS_FUNCTION_MONTH
           
static java.lang.Integer JEKS_FUNCTION_NOW
           
static java.lang.Integer JEKS_FUNCTION_OR
           
static java.lang.Integer JEKS_FUNCTION_RAND
           
static java.lang.Integer JEKS_FUNCTION_SECOND
           
static java.lang.Integer JEKS_FUNCTION_SUM
           
static java.lang.Integer JEKS_FUNCTION_TIME
           
static java.lang.Integer JEKS_FUNCTION_TIMEVALUE
           
static java.lang.Integer JEKS_FUNCTION_TRUE
           
static java.lang.Integer JEKS_FUNCTION_WEEKDAY
           
static java.lang.Integer JEKS_FUNCTION_YEAR
           
static java.lang.Integer MESSAGE_ASSIGN_OPERATOR_EXPECTED
           
static java.lang.Integer MESSAGE_CLOSING_BRACKET_EXPECTED
           
static java.lang.Integer MESSAGE_CLOSING_BRACKET_WITHOUT_OPENING_BRACKET
           
static java.lang.Integer MESSAGE_COMPILATION_ERROR_TITLE
           
static java.lang.Integer MESSAGE_DUPLICATED_PARAMETER_NAME
           
static java.lang.Integer MESSAGE_ELSE_OPERATOR_EXPECTED
           
static java.lang.Integer MESSAGE_ELSE_OPERATOR_WITHOUT_IF_THEN_OPERATORS
           
static java.lang.Integer MESSAGE_FUNCTION_NAME_ALREADY_EXISTS
           
static java.lang.Integer MESSAGE_INVALID_FUNCTION_NAME
           
static java.lang.Integer MESSAGE_INVALID_JEKS_FILE
           
static java.lang.Integer MESSAGE_INVALID_PARAMETER_NAME
           
static java.lang.Integer MESSAGE_INVALID_PARAMETERS_COUNT_IN_FUNCTION_CALL
           
static java.lang.Integer MESSAGE_MISSING_PARAMETERS_IN_FUNCTION_CALL
           
static java.lang.Integer MESSAGE_OPENING_BRACKET_EXPECTED
           
static java.lang.Integer MESSAGE_RESERVED_WORD
           
static java.lang.Integer MESSAGE_SYNTAX_ERROR
           
static java.lang.Integer MESSAGE_THEN_OPERATOR_EXPECTED
           
static java.lang.Integer MESSAGE_THEN_OPERATOR_WITHOUT_IF_OPERATOR
           
static java.lang.Integer MESSAGE_UNKOWN_IDENTIFIER
           
 
Fields inherited from interface com.eteks.parser.Syntax
CONDITION_ELSE, CONDITION_IF, CONDITION_THEN, CONSTANT_E, CONSTANT_FALSE, CONSTANT_PI, CONSTANT_TRUE, FUNCTION_ABS, FUNCTION_ACOS, FUNCTION_ASIN, FUNCTION_ATAN, FUNCTION_CEIL, FUNCTION_COS, FUNCTION_COSH, FUNCTION_EXP, FUNCTION_FLOOR, FUNCTION_INTEGER, FUNCTION_LN, FUNCTION_LOG, FUNCTION_NOT, FUNCTION_OPPOSITE, FUNCTION_ROUND, FUNCTION_SIN, FUNCTION_SINH, FUNCTION_SQR, FUNCTION_SQRT, FUNCTION_TAN, FUNCTION_TANH, OPERATOR_ADD, OPERATOR_BITWISE_AND, OPERATOR_BITWISE_NOT, OPERATOR_BITWISE_OR, OPERATOR_BITWISE_XOR, OPERATOR_DIFFERENT, OPERATOR_DIVIDE, OPERATOR_EQUAL, OPERATOR_GREATER, OPERATOR_GREATER_OR_EQUAL, OPERATOR_LESS, OPERATOR_LESS_OR_EQUAL, OPERATOR_LOGICAL_AND, OPERATOR_LOGICAL_NOT, OPERATOR_LOGICAL_OR, OPERATOR_LOGICAL_XOR, OPERATOR_MODULO, OPERATOR_MULTIPLY, OPERATOR_OPPOSITE, OPERATOR_POSITIVE, OPERATOR_POWER, OPERATOR_REMAINDER, OPERATOR_SHIFT_LEFT, OPERATOR_SHIFT_RIGHT, OPERATOR_SHIFT_RIGHT_0, OPERATOR_SUBSTRACT, USER_STARTING_KEY
 
Constructor Summary
JeksFunctionSyntax()
          Creates an instance of JeksFunctionSyntax using default locale.
JeksFunctionSyntax(java.util.Locale locale)
          Creates an instance of JeksFunctionSyntax initialized with the resource bundle com.eteks.jeks.syntax.
 
Method Summary
 java.lang.String getExceptionMessage(CompilationException exception)
          Returns the localized message matching the exception.
 java.lang.String getJeksFunction(java.lang.Object jeksFunctionKey)
          Returns the Jeks function name matching the key jeksFunctionKey (one of the JEKS_FUNCTION_... constants).
 java.lang.Object getJeksFunctionKey(java.lang.String jeksFunction)
          Returns the key matching the Jeks function of name jeksFunction.
 java.lang.Object getLiteral(java.lang.String expression, java.lang.StringBuffer extractedLiteral)
          Returns the value of the literal parsed from the string expression or null if expression doesn't start with a literal.
 java.util.Locale getLocale()
          Returns the locale of this syntax.
 java.lang.String getMessage(java.lang.Object messageKey)
          Returns the localized message matching the key messageKey (one of the MESSAGE_... constants).
 java.text.NumberFormat getNumberFormat()
          Returns the number format instance used to format and parse numbers.
 char getQuoteCharacter()
          Returns the char used to quote string litterals.
 boolean isValidIdentifier(java.lang.String identifier)
          Returns true if identifier is a correct name of function or parameter.
 
Methods inherited from class com.eteks.jeks.ResourceSyntax
getBinaryOperator, getCommonFunction, getConditionPart, getConstant, getResourceBoolean, getResourceBoolean, getResourceBundle, getResourceChar, getResourceChar, getResourceString, getResourceString, getUnaryOperator, setResourceBinaryOperatorKey, setResourceBinaryOperatorPriority, setResourceCommonFunctionKey, setResourceConditionPartKey, setResourceConstantKey, setResourceUnaryOperatorKey
 
Methods inherited from class com.eteks.parser.AbstractSyntax
addFunction, getAssignmentOperator, getBinaryOperatorKey, getBinaryOperatorPriority, getClosingBracket, getCommonFunctionKey, getConditionPartCount, getConditionPartKey, getConstantKey, getDelimiters, getFunction, getOpeningBracket, getParameterSeparator, getUnaryOperatorKey, getWhiteSpaceCharacters, isCaseSensitive, isShortSyntax, removeFunction, setAssignmentOperator, setBinaryOperatorKey, setBinaryOperatorPriority, setClosingBracket, setCommonFunctionKey, setConditionPartKey, setConstantKey, setOpeningBracket, setParameterSeparator, setShortSyntax, setUnaryOperatorKey, setWhiteSpaceCharacters
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JEKS_FUNCTION_SUM

public static final java.lang.Integer JEKS_FUNCTION_SUM

JEKS_FUNCTION_RAND

public static final java.lang.Integer JEKS_FUNCTION_RAND

JEKS_FUNCTION_MODULO

public static final java.lang.Integer JEKS_FUNCTION_MODULO

JEKS_FUNCTION_FACT

public static final java.lang.Integer JEKS_FUNCTION_FACT

JEKS_FUNCTION_AND

public static final java.lang.Integer JEKS_FUNCTION_AND

JEKS_FUNCTION_OR

public static final java.lang.Integer JEKS_FUNCTION_OR

JEKS_FUNCTION_TRUE

public static final java.lang.Integer JEKS_FUNCTION_TRUE

JEKS_FUNCTION_FALSE

public static final java.lang.Integer JEKS_FUNCTION_FALSE

JEKS_FUNCTION_DATE

public static final java.lang.Integer JEKS_FUNCTION_DATE

JEKS_FUNCTION_DATEVALUE

public static final java.lang.Integer JEKS_FUNCTION_DATEVALUE

JEKS_FUNCTION_NOW

public static final java.lang.Integer JEKS_FUNCTION_NOW

JEKS_FUNCTION_TIME

public static final java.lang.Integer JEKS_FUNCTION_TIME

JEKS_FUNCTION_TIMEVALUE

public static final java.lang.Integer JEKS_FUNCTION_TIMEVALUE

JEKS_FUNCTION_YEAR

public static final java.lang.Integer JEKS_FUNCTION_YEAR

JEKS_FUNCTION_MONTH

public static final java.lang.Integer JEKS_FUNCTION_MONTH

JEKS_FUNCTION_DAY

public static final java.lang.Integer JEKS_FUNCTION_DAY

JEKS_FUNCTION_WEEKDAY

public static final java.lang.Integer JEKS_FUNCTION_WEEKDAY

JEKS_FUNCTION_HOUR

public static final java.lang.Integer JEKS_FUNCTION_HOUR

JEKS_FUNCTION_MINUTE

public static final java.lang.Integer JEKS_FUNCTION_MINUTE

JEKS_FUNCTION_SECOND

public static final java.lang.Integer JEKS_FUNCTION_SECOND

JEKS_FUNCTION_CHAR

public static final java.lang.Integer JEKS_FUNCTION_CHAR

JEKS_FUNCTION_FIND

public static final java.lang.Integer JEKS_FUNCTION_FIND

JEKS_FUNCTION_CODE

public static final java.lang.Integer JEKS_FUNCTION_CODE

MESSAGE_COMPILATION_ERROR_TITLE

public static final java.lang.Integer MESSAGE_COMPILATION_ERROR_TITLE

MESSAGE_OPENING_BRACKET_EXPECTED

public static final java.lang.Integer MESSAGE_OPENING_BRACKET_EXPECTED

MESSAGE_INVALID_FUNCTION_NAME

public static final java.lang.Integer MESSAGE_INVALID_FUNCTION_NAME

MESSAGE_RESERVED_WORD

public static final java.lang.Integer MESSAGE_RESERVED_WORD

MESSAGE_FUNCTION_NAME_ALREADY_EXISTS

public static final java.lang.Integer MESSAGE_FUNCTION_NAME_ALREADY_EXISTS

MESSAGE_CLOSING_BRACKET_EXPECTED

public static final java.lang.Integer MESSAGE_CLOSING_BRACKET_EXPECTED

MESSAGE_ASSIGN_OPERATOR_EXPECTED

public static final java.lang.Integer MESSAGE_ASSIGN_OPERATOR_EXPECTED

MESSAGE_INVALID_PARAMETER_NAME

public static final java.lang.Integer MESSAGE_INVALID_PARAMETER_NAME

MESSAGE_DUPLICATED_PARAMETER_NAME

public static final java.lang.Integer MESSAGE_DUPLICATED_PARAMETER_NAME

MESSAGE_SYNTAX_ERROR

public static final java.lang.Integer MESSAGE_SYNTAX_ERROR

MESSAGE_CLOSING_BRACKET_WITHOUT_OPENING_BRACKET

public static final java.lang.Integer MESSAGE_CLOSING_BRACKET_WITHOUT_OPENING_BRACKET

MESSAGE_UNKOWN_IDENTIFIER

public static final java.lang.Integer MESSAGE_UNKOWN_IDENTIFIER

MESSAGE_MISSING_PARAMETERS_IN_FUNCTION_CALL

public static final java.lang.Integer MESSAGE_MISSING_PARAMETERS_IN_FUNCTION_CALL

MESSAGE_INVALID_PARAMETERS_COUNT_IN_FUNCTION_CALL

public static final java.lang.Integer MESSAGE_INVALID_PARAMETERS_COUNT_IN_FUNCTION_CALL

MESSAGE_THEN_OPERATOR_EXPECTED

public static final java.lang.Integer MESSAGE_THEN_OPERATOR_EXPECTED

MESSAGE_ELSE_OPERATOR_EXPECTED

public static final java.lang.Integer MESSAGE_ELSE_OPERATOR_EXPECTED

MESSAGE_THEN_OPERATOR_WITHOUT_IF_OPERATOR

public static final java.lang.Integer MESSAGE_THEN_OPERATOR_WITHOUT_IF_OPERATOR

MESSAGE_ELSE_OPERATOR_WITHOUT_IF_THEN_OPERATORS

public static final java.lang.Integer MESSAGE_ELSE_OPERATOR_WITHOUT_IF_THEN_OPERATORS

MESSAGE_INVALID_JEKS_FILE

public static final java.lang.Integer MESSAGE_INVALID_JEKS_FILE
Constructor Detail

JeksFunctionSyntax

public JeksFunctionSyntax()
Creates an instance of JeksFunctionSyntax using default locale.

JeksFunctionSyntax

public JeksFunctionSyntax(java.util.Locale locale)
Creates an instance of JeksFunctionSyntax initialized with the resource bundle com.eteks.jeks.syntax. The syntax may be localized with an appropriate locale. See the default locale file com/eteks/jeks/resources/syntax.properties to see which type of syntax is described by a JeksFunctionSyntax object.
Method Detail

getLocale

public java.util.Locale getLocale()
Returns the locale of this syntax.

getMessage

public java.lang.String getMessage(java.lang.Object messageKey)
Returns the localized message matching the key messageKey (one of the MESSAGE_... constants).

getExceptionMessage

public java.lang.String getExceptionMessage(CompilationException exception)
Returns the localized message matching the exception.

getJeksFunctionKey

public java.lang.Object getJeksFunctionKey(java.lang.String jeksFunction)
Returns the key matching the Jeks function of name jeksFunction. Jeks functions may be localized.

getJeksFunction

public java.lang.String getJeksFunction(java.lang.Object jeksFunctionKey)
Returns the Jeks function name matching the key jeksFunctionKey (one of the JEKS_FUNCTION_... constants). Jeks functions may be localized.

getLiteral

public java.lang.Object getLiteral(java.lang.String expression,
                                   java.lang.StringBuffer extractedLiteral)
Returns the value of the literal parsed from the string expression or null if expression doesn't start with a literal. If a literal is found at the beginning of expression, this method extracts the parsed literal in the string buffer extractedLiteral. The extracted literal is a number, a string or a character. Numbers are parsed with a localized number parser.
Parameters:
expression - the string to parse.
extractedLiteral - the literal extracted from expression identified as a valid literal with the syntax of the parser.
Returns:
the value of the extracted literal or null if expression doesn't start with a valid literal. If the literal is a number, an instance of Number is returned, if the literal is a string an instance of String is returned.

getQuoteCharacter

public char getQuoteCharacter()
Returns the char used to quote string litterals.
Returns:
0 by default.

getNumberFormat

public java.text.NumberFormat getNumberFormat()
Returns the number format instance used to format and parse numbers.
Returns:
an instance of NumberFormat.

isValidIdentifier

public boolean isValidIdentifier(java.lang.String identifier)
Returns true if identifier is a correct name of function or parameter. identifier may contain letters, digits, or the character _. Its first character can't be a digit.
Parameters:
identifier - the string to test.
Returns:
true if identifier is a correct identifier.

&cp; 1998-2003 eTeks - All rights reserved