Package org.synchronoss.cpo.core.parser
Class BoundExpressionParser
java.lang.Object
org.synchronoss.cpo.core.parser.BoundExpressionParser
- All Implemented Interfaces:
ExpressionParser
ExpressionParser implementation for native expressions that use positional ? bind
markers (the common JDBC/CQL convention). Parses INSERT statements by matching the
column-list and values-list parentheses, and all other statement types by scanning left of each
? for the preceding column/attribute token.- Since:
- 10/20/2008
- Author:
- Michael Bellomo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the count of the bind markers in the expressionstatic Collection<Integer> getBindMarkerIndexes(String source) Finds the character offsets of every unquoted?bind marker insource.Returns the expression used by this parserparse()Returns a list of columns from the expression for each bind markervoidsetExpression(String expression) Sets the expression to be used for this parser
-
Constructor Details
-
BoundExpressionParser
public BoundExpressionParser()Creates a parser with no expression set. CallsetExpression(String)before use.
-
-
Method Details
-
getExpression
Returns the expression used by this parser- Specified by:
getExpressionin interfaceExpressionParser- Returns:
- The expression
-
setExpression
Sets the expression to be used for this parser- Specified by:
setExpressionin interfaceExpressionParser- Parameters:
expression- The expression
-
countArguments
public int countArguments()Returns the count of the bind markers in the expression- Specified by:
countArgumentsin interfaceExpressionParser- Returns:
- the number of bind markers
-
getBindMarkerIndexes
Finds the character offsets of every unquoted?bind marker insource. Markers inside single- or double-quoted literals are ignored.- Parameters:
source- the expression to scan, may benullor empty- Returns:
- the offsets of each bind marker, in order; empty if
sourceisnullor empty
-
parse
Returns a list of columns from the expression for each bind markerSupports two expression shapes:
INSERT INTO table(col1, col2...) VALUES(val1, val2...), parsed by matching the column-list and values-list parentheses; and any other expression of the form...col1 = ?, col2 = ?..., parsed by scanning left from each?for the preceding column/attribute token.- Specified by:
parsein interfaceExpressionParser- Returns:
- List of Strings for the columns for the bind markers
- Throws:
ParseException- thrown if the expression cannot be parsed
-