java.lang.Object
org.seasar.doma.internal.util.SqlTokenUtil
High-performance SQL token character classification utility.
This class provides optimized character classification methods for SQL parsing using pre-computed lookup tables for maximum performance.
Performance Benefits
- Constant Time: O(1) lookup for ASCII characters (0-127)
- Branch Reduction: Eliminates multiple if-else chains
- Cache Friendly: Small lookup tables fit in CPU cache
- JIT Optimization: Simple array access is highly optimizable
Design Principles
- ASCII Optimization: Most SQL content is ASCII, so we optimize for this case
- Bit Flags: Use byte bit flags for efficient character property storage
- Static Initialization: Pre-compute all classifications at class load time
- Compatibility: Maintains exact behavior compatibility with ClassicSqlTokenUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisWhitespace(char c) Determines if a character is SQL whitespace.static booleanisWordPart(char c) Determines if a character can be part of an SQL word.
-
Method Details
-
isWordPart
public static boolean isWordPart(char c) Determines if a character can be part of an SQL word.This method uses the same logic as ClassicSqlTokenUtil: a character is considered a word part unless it's whitespace or one of the specific SQL delimiters. This method is optimized for ASCII characters with O(1) lookup time.
- Parameters:
c- the character to test- Returns:
- true if the character can be part of an SQL word
-
isWhitespace
public static boolean isWhitespace(char c) Determines if a character is SQL whitespace.SQL whitespace includes space, tab, form feed, and other control characters that should be treated as separators in SQL parsing.
- Parameters:
c- the character to test- Returns:
- true if the character is SQL whitespace
-