Package org.h2.util

Class ParserUtil


  • public class ParserUtil
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int _ROWID_
      The token "_ROWID_".
      static int ALL
      The token "ALL".
      static int AND
      The token "AND".
      static int ANY
      The token "ANY".
      static int ARRAY
      The token "ARRAY".
      static int AS
      The token "AS".
      static int ASYMMETRIC
      The token "ASYMMETRIC".
      static int AUTHORIZATION
      The token "AUTHORIZATION".
      static int BETWEEN
      The token "BETWEEN".
      static int CASE
      The token "CASE".
      static int CAST
      The token "CAST".
      static int CHECK
      The token "CHECK".
      static int CONSTRAINT
      The token "CONSTRAINT".
      static int CROSS
      The token "CROSS".
      static int CURRENT_CATALOG
      The token "CURRENT_CATALOG".
      static int CURRENT_DATE
      The token "CURRENT_DATE".
      static int CURRENT_PATH
      The token "CURRENT_PATH".
      static int CURRENT_ROLE
      The token "CURRENT_ROLE".
      static int CURRENT_SCHEMA
      The token "CURRENT_SCHEMA".
      static int CURRENT_TIME
      The token "CURRENT_TIME".
      static int CURRENT_TIMESTAMP
      The token "CURRENT_TIMESTAMP".
      static int CURRENT_USER
      The token "CURRENT_USER".
      static int DAY
      The token "DAY".
      static int DEFAULT
      The token "DEFAULT".
      static int DISTINCT
      The token "DISTINCT".
      static int ELSE
      The token "ELSE".
      static int END
      The token "END".
      static int EXCEPT
      The token "EXCEPT".
      static int EXISTS
      The token "EXISTS".
      static int FALSE
      The token "FALSE".
      static int FETCH
      The token "FETCH".
      static int FIRST_KEYWORD
      The ordinal number of the first keyword.
      static int FOR
      The token "FOR".
      static int FOREIGN
      The token "FOREIGN".
      static int FROM
      The token "FROM".
      static int FULL
      The token "FULL".
      static int GROUP
      The token "GROUP".
      static int HAVING
      The token "HAVING".
      static int HOUR
      The token "HOUR".
      static int IDENTIFIER
      An identifier (table name, column name,...).
      static int IF
      The token "IF".
      static int IN
      The token "IN".
      static int INNER
      The token "INNER".
      static int INTERSECT
      The token "INTERSECT".
      static int INTERVAL
      The token "INTERVAL".
      static int IS
      The token "IS".
      static int JOIN
      The token "JOIN".
      static int KEY
      The token "KEY".
      static int KEYWORD
      A keyword.
      private static java.util.HashMap<java.lang.String,​java.lang.Integer> KEYWORDS  
      static int LAST_KEYWORD
      The ordinal number of the last keyword.
      static int LEFT
      The token "LEFT".
      static int LIKE
      The token "LIKE".
      static int LIMIT
      The token "LIMIT".
      static int LOCALTIME
      The token "LOCALTIME".
      static int LOCALTIMESTAMP
      The token "LOCALTIMESTAMP".
      static int MINUS
      The token "MINUS".
      static int MINUTE
      The token "MINUTE".
      static int MONTH
      The token "MONTH".
      static int NATURAL
      The token "NATURAL".
      static int NOT
      The token "NOT".
      static int NULL
      The token "NULL".
      static int OFFSET
      The token "OFFSET".
      static int ON
      The token "ON".
      static int OR
      The token "OR".
      static int ORDER
      The token "ORDER".
      static int PRIMARY
      The token "PRIMARY".
      static int QUALIFY
      The token "QUALIFY".
      static int RIGHT
      The token "RIGHT".
      static int ROW
      The token "ROW".
      static int ROWNUM
      The token "ROWNUM".
      static int SECOND
      The token "SECOND".
      static int SELECT
      The token "SELECT".
      static int SESSION_USER
      The token "SESSION_USER".
      static int SET
      The token "SET".
      static int SOME
      The token "SOME".
      static int SYMMETRIC
      The token "SYMMETRIC".
      static int SYSTEM_USER
      The token "SYSTEM_USER".
      static int TABLE
      The token "TABLE".
      static int TO
      The token "TO".
      static int TRUE
      The token "TRUE".
      static int UESCAPE
      The token "UESCAPE".
      static int UNION
      The token "UNION".
      static int UNIQUE
      The token "UNIQUE".
      static int UNKNOWN
      The token "UNKNOWN".
      static int USER
      The token "USER".
      static int USING
      The token "USING".
      static int VALUE
      The token "VALUE".
      static int VALUES
      The token "VALUES".
      static int WHEN
      The token "WHEN".
      static int WHERE
      The token "WHERE".
      static int WINDOW
      The token "WINDOW".
      static int WITH
      The token "WITH".
      static int YEAR
      The token "YEAR".
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ParserUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean checkLetter​(boolean databaseToUpper, boolean databaseToLower, char c)  
      static int getTokenType​(java.lang.String s, boolean ignoreCase, boolean additionalKeywords)
      Get the token type.
      static boolean isKeyword​(java.lang.String s, boolean ignoreCase)
      Checks if this string is a SQL keyword.
      static boolean isSimpleIdentifier​(java.lang.String s, boolean databaseToUpper, boolean databaseToLower)
      Is this a simple identifier (in the JDBC specification sense).
      static java.lang.StringBuilder quoteIdentifier​(java.lang.StringBuilder builder, java.lang.String s, int sqlFlags)
      Add double quotes around an identifier if required and appends it to the specified string builder.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ParserUtil

        private ParserUtil()
    • Method Detail

      • quoteIdentifier

        public static java.lang.StringBuilder quoteIdentifier​(java.lang.StringBuilder builder,
                                                              java.lang.String s,
                                                              int sqlFlags)
        Add double quotes around an identifier if required and appends it to the specified string builder.
        Parameters:
        builder - string builder to append to
        s - the identifier
        sqlFlags - formatting flags
        Returns:
        the specified builder
      • isKeyword

        public static boolean isKeyword​(java.lang.String s,
                                        boolean ignoreCase)
        Checks if this string is a SQL keyword.
        Parameters:
        s - the token to check
        ignoreCase - true if case should be ignored, false if only upper case tokens are detected as keywords
        Returns:
        true if it is a keyword
      • isSimpleIdentifier

        public static boolean isSimpleIdentifier​(java.lang.String s,
                                                 boolean databaseToUpper,
                                                 boolean databaseToLower)
        Is this a simple identifier (in the JDBC specification sense).
        Parameters:
        s - identifier to check
        databaseToUpper - whether unquoted identifiers are converted to upper case
        databaseToLower - whether unquoted identifiers are converted to lower case
        Returns:
        is specified identifier may be used without quotes
        Throws:
        java.lang.NullPointerException - if s is null
      • checkLetter

        private static boolean checkLetter​(boolean databaseToUpper,
                                           boolean databaseToLower,
                                           char c)
      • getTokenType

        public static int getTokenType​(java.lang.String s,
                                       boolean ignoreCase,
                                       boolean additionalKeywords)
        Get the token type.
        Parameters:
        s - the string with token
        ignoreCase - true if case should be ignored, false if only upper case tokens are detected as keywords
        additionalKeywords - whether context-sensitive keywords are returned as KEYWORD
        Returns:
        the token type