## org.firebirdsql.jdbc
Class FBEscapedParser

    java.lang.Object
      org.firebirdsql.jdbc.FBEscapedParser

    public class FBEscapedParser

extends Object

The class `FBEscapedParser` parses the SQL and converts escaped syntax to native form.

Version:
  1.0
Author:
  Roman Rokytskyy

Field Summary
`protected static String` `CHECK_CALL_1`
`protected static String` `CHECK_CALL_2`
`protected static String` `CHECK_DATE`
`protected static String` `CHECK_ESCAPE`
`protected static String` `CHECK_FUNCTION`
`protected static String` `CHECK_OUTERJOIN`
`protected static String` `CHECK_TIME`
`protected static String` `CHECK_TIMESTAMP`
`static String` `ESCAPE_CALL_KEYWORD`
`static String` `ESCAPE_CALL_KEYWORD3`
`static String` `ESCAPE_DATE_KEYWORD`
`static String` `ESCAPE_ESCAPE_KEYWORD`
`static String` `ESCAPE_FUNCTION_KEYWORD`
`static String` `ESCAPE_OUTERJOIN_KEYWORS`
`protected static int` `ESCAPE_STATE`
`static String` `ESCAPE_TIME_KEYWORD`
`static String` `ESCAPE_TIMESTAMP_KEYWORD`
`protected static int` `LITERAL_STATE`
`protected static int` `NORMAL_STATE`
`protected static int` `UNDEFINED_STATE`
`static int` `USE_BUILT_IN`
`static int` `USE_STANDARD_UDF`

Constructor Summary
`FBEscapedParser(int mode)`

Method Summary
`protected boolean` `checkForEscapes(String sql)` Check if the target SQL contains at least one of the escaped syntax commands.
`protected String` `convertEscapedFunction(String escapedFunction)` This method converts escaped function to a server function call.
`protected String` `convertEscapeString(String escapeString)` Convert the `"{escape '...'}"` call into the corresponding escape clause for Firebird.
`protected String` `convertOuterJoin(String outerJoin)` This method converts the escaped outer join call syntax into the native outer join.
`protected String` `convertProcedureCall(String procedureCall)` This methods converts the escaped procedure call syntax into the native procedure call.
`protected String` `escapeToNative(String escaped)` This method checks the passed parameter to conform the escaped syntax, checks for the unknown keywords and re-formats result according to the Firebird SQL syntax.
`protected int` `getLastState()` Returns the current state.
`protected int` `getState()` Returns the current state.
`protected boolean` `isInState(int state)` Returns if the system is in state `state`.
`String` `parse(String sql)` Converts escaped parts in the passed SQL to native representation.
`protected void` `processEscaped(String escaped, StringBuffer keyword, StringBuffer payload)`
`protected void` `setState(int state)` Sets the current state.
`static boolean` `supportsLikeEscapeClause()`
`static boolean` `supportsStoredProcedures()`
`protected void` `switchState(char testChar)` Test the character to be the state switching character and switches the state if necessary.
`protected String` `toDateString(String dateStr)` This method converts the 'yyyy-mm-dd' date format into the Firebird understandable format.
`protected String` `toTimestampString(String timestampStr)` This method converts the 'yyyy-mm-dd hh:mm:ss' timestamp format into the Firebird understandable format.
`protected String` `toTimeString(String timeStr)` This method converts the 'hh:mm:ss' time format into the Firebird understandable format.
`protected boolean` `wasInState(int state)` Returns if the system was in state `state`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### USE_BUILT_IN

    public static final int USE_BUILT_IN

See Also:
  Constant Field Values

### USE_STANDARD_UDF

    public static final int USE_STANDARD_UDF

See Also:
  Constant Field Values

### UNDEFINED_STATE

    protected static final int UNDEFINED_STATE

See Also:
  Constant Field Values

### NORMAL_STATE

    protected static final int NORMAL_STATE

See Also:
  Constant Field Values

### LITERAL_STATE

    protected static final int LITERAL_STATE

See Also:
  Constant Field Values

### ESCAPE_STATE

    protected static final int ESCAPE_STATE

See Also:
  Constant Field Values

### ESCAPE_CALL_KEYWORD

    public static final String ESCAPE_CALL_KEYWORD

See Also:
  Constant Field Values

### ESCAPE_CALL_KEYWORD3

    public static final String ESCAPE_CALL_KEYWORD3

See Also:
  Constant Field Values

### ESCAPE_DATE_KEYWORD

    public static final String ESCAPE_DATE_KEYWORD

See Also:
  Constant Field Values

### ESCAPE_TIME_KEYWORD

    public static final String ESCAPE_TIME_KEYWORD

See Also:
  Constant Field Values

### ESCAPE_TIMESTAMP_KEYWORD

    public static final String ESCAPE_TIMESTAMP_KEYWORD

See Also:
  Constant Field Values

### ESCAPE_FUNCTION_KEYWORD

    public static final String ESCAPE_FUNCTION_KEYWORD

See Also:
  Constant Field Values

### ESCAPE_ESCAPE_KEYWORD

    public static final String ESCAPE_ESCAPE_KEYWORD

See Also:
  Constant Field Values

### ESCAPE_OUTERJOIN_KEYWORS

    public static final String ESCAPE_OUTERJOIN_KEYWORS

See Also:
  Constant Field Values

### CHECK_CALL_1

    protected static final String CHECK_CALL_1

See Also:
  Constant Field Values

### CHECK_CALL_2

    protected static final String CHECK_CALL_2

See Also:
  Constant Field Values

### CHECK_DATE

    protected static final String CHECK_DATE

See Also:
  Constant Field Values

### CHECK_TIME

    protected static final String CHECK_TIME

See Also:
  Constant Field Values

### CHECK_TIMESTAMP

    protected static final String CHECK_TIMESTAMP

See Also:
  Constant Field Values

### CHECK_FUNCTION

    protected static final String CHECK_FUNCTION

See Also:
  Constant Field Values

### CHECK_ESCAPE

    protected static final String CHECK_ESCAPE

See Also:
  Constant Field Values

### CHECK_OUTERJOIN

    protected static final String CHECK_OUTERJOIN

See Also:
  Constant Field Values

Constructor Detail

### FBEscapedParser

    public FBEscapedParser(int mode)

Method Detail

### getLastState

    protected int getLastState()

  Returns the current state.

### getState

    protected int getState()

  Returns the current state.

### setState

    protected void setState(int state)
                     throws IllegalStateException

  Sets the current state.

  Parameters:
    `state` - to enter.
  Throws:
    ``java.lang.IllegalStateException`` - if the system cannot enter the desired state.
    `IllegalStateException`

### isInState

    protected boolean isInState(int state)

  Returns if the system is in state `state`.

  Parameters:
    `state` - we're testing
  Returns:
    `true` if the system is in state `state`.

### wasInState

    protected boolean wasInState(int state)

  Returns if the system was in state `state`.

  Parameters:
    `state` - we're testing
  Returns:
    `true` if the system was in state `state`.

### switchState

    protected void switchState(char testChar)

  Test the character to be the state switching character and switches the state if necessary.

  Parameters:
    `testChar` - character to test

### checkForEscapes

    protected boolean checkForEscapes(String sql)

  Check if the target SQL contains at least one of the escaped syntax commands. This method performs simple substring matching, so it may report that SQL contains escaped syntax when the `"{"` is followed by the escaped syntax command in regular string constants that are passed as parameters. In this case `parse(String)` will perform complete SQL parsing.

  Parameters:
    `sql` - to test
  Returns:
    `true` if the `sql` is suspected to contain escaped syntax.

### parse

    public String parse(String sql)
                 throws FBSQLException

  Converts escaped parts in the passed SQL to native representation.

  Parameters:
    `sql` - to parse
  Returns:
    native form of the `sql`.
  Throws:
    `FBSQLException`

### processEscaped

    protected void processEscaped(String escaped,
                                  StringBuffer keyword,
                                  StringBuffer payload)

### escapeToNative

    protected String escapeToNative(String escaped)
                             throws FBSQLException

  This method checks the passed parameter to conform the escaped syntax, checks for the unknown keywords and re-formats result according to the Firebird SQL syntax.

  Parameters:
    `escaped` - the part of escaped SQL between the '{' and '}'.
  Returns:
    the native representation of the SQL code.
  Throws:
    `FBSQLException`

### toDateString

    protected String toDateString(String dateStr)
                           throws FBSQLParseException

  This method converts the 'yyyy-mm-dd' date format into the Firebird understandable format.

  Parameters:
    `dateStr` - the date in the 'yyyy-mm-dd' format.
  Returns:
    Firebird understandable date format.
  Throws:
    `FBSQLParseException`

### toTimeString

    protected String toTimeString(String timeStr)
                           throws FBSQLParseException

  This method converts the 'hh:mm:ss' time format into the Firebird understandable format.

  Parameters:
    `timeStr` - the date in the 'hh:mm:ss' format.
  Returns:
    Firebird understandable date format.
  Throws:
    `FBSQLParseException`

### toTimestampString

    protected String toTimestampString(String timestampStr)
                                throws FBSQLParseException

  This method converts the 'yyyy-mm-dd hh:mm:ss' timestamp format into the Firebird understandable format.

  Parameters:
    `timestampStr` - the date in the 'yyyy-mm-dd hh:mm:ss' format.
  Returns:
    Firebird understandable date format.
  Throws:
    `FBSQLParseException`

### convertProcedureCall

    protected String convertProcedureCall(String procedureCall)
                                   throws FBSQLException

  This methods converts the escaped procedure call syntax into the native procedure call.

  Parameters:
    `procedureCall` - part of {call proc_name(...)} without curly braces and "call" word.
  Returns:
    native procedure call.
  Throws:
    `FBSQLException`

### convertOuterJoin

    protected String convertOuterJoin(String outerJoin)
                               throws FBSQLParseException

  This method converts the escaped outer join call syntax into the native outer join. Actually, we do not change anything here, since Firebird's syntax is the same.

  Throws:
    `FBSQLParseException`

### convertEscapeString

    protected String convertEscapeString(String escapeString)

  Convert the `"{escape '...'}"` call into the corresponding escape clause for Firebird.

  Parameters:
    `escapeString` - escape string to convert
  Returns:
    converted code.

### convertEscapedFunction

    protected String convertEscapedFunction(String escapedFunction)
                                     throws FBSQLParseException

  This method converts escaped function to a server function call. Actually we do not change anything here, we hope that all UDF are defined.

  Parameters:
    `escapedFunction` - escaped function call
  Returns:
    server-side function call.
  Throws:
    `FBSQLParseException` - if something was wrong.

### supportsStoredProcedures

    public static boolean supportsStoredProcedures()

### supportsLikeEscapeClause

    public static boolean supportsLikeEscapeClause()

Copyright © 2001-2010. All Rights Reserved.