Package edu.caltech.nanodb.sqlparse
Class ParseUtil
- java.lang.Object
-
- edu.caltech.nanodb.sqlparse.ParseUtil
-
public class ParseUtil extends java.lang.Object
This helper class parses a string into a SQL operation using the NanoSQL parser.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.logging.log4j.Logger
logger
A logging object for reporting anything interesting that happens.
-
Constructor Summary
Constructors Constructor Description ParseUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
appendSemicolon(java.lang.String command)
This helper function conditionally appends a semicolon onto a command string if one is not already present.static Command
parseCommand(java.lang.String command)
Parse an input string into some kind ofCommand
.static Command
parseCommand(java.lang.String command, FunctionDirectory functionDirectory)
Parse an input string into some kind ofCommand
.static java.util.List<Command>
parseCommands(java.lang.String commands, FunctionDirectory functionDirectory)
static Expression
parseExpression(java.lang.String expression)
static Expression
parseExpression(java.lang.String expression, FunctionDirectory functionDirectory)
-
-
-
Method Detail
-
appendSemicolon
public static java.lang.String appendSemicolon(java.lang.String command)
This helper function conditionally appends a semicolon onto a command string if one is not already present. Note that leading and trailing whitespace are also trimmed by this function.- Parameters:
command
- the SQL command to optionally append a semicolon to.- Returns:
- a SQL command that is definitely terminated with a semicolon.
-
parseCommand
public static Command parseCommand(java.lang.String command, FunctionDirectory functionDirectory) throws org.antlr.v4.runtime.RecognitionException
Parse an input string into some kind ofCommand
.- Parameters:
command
- the string representation of the commandfunctionDirectory
- a directory of functions to resolve function-calls against- Returns:
- a
Command
object representing the command - Throws:
org.antlr.v4.runtime.RecognitionException
- if the string could not be parsed
-
parseCommand
public static Command parseCommand(java.lang.String command) throws org.antlr.v4.runtime.RecognitionException
Parse an input string into some kind ofCommand
.- Parameters:
command
- the string representation of the command- Returns:
- a
Command
object representing the command - Throws:
org.antlr.v4.runtime.RecognitionException
- if the string could not be parsed
-
parseCommands
public static java.util.List<Command> parseCommands(java.lang.String commands, FunctionDirectory functionDirectory) throws org.antlr.v4.runtime.RecognitionException
- Throws:
org.antlr.v4.runtime.RecognitionException
-
parseExpression
public static Expression parseExpression(java.lang.String expression, FunctionDirectory functionDirectory)
-
parseExpression
public static Expression parseExpression(java.lang.String expression)
-
-