Package org.apache.jackrabbit.oak.query
Class SQL2Parser
- java.lang.Object
-
- org.apache.jackrabbit.oak.query.SQL2Parser
-
public class SQL2Parser extends Object
The SQL2 parser can convert a JCR-SQL2 query to a query. The 'old' SQL query language (here named SQL-1) is also supported.
-
-
Constructor Summary
Constructors Constructor Description SQL2Parser(NamePathMapper namePathMapper, NodeTypeInfoProvider nodeTypes, QueryEngineSettings settings, QueryStatsData.QueryExecutionStats stats)
Create a new parser.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
escapeStringLiteral(String value)
static int
getPropertyTypeFromName(String name)
Get the property type from the given case insensitive name.static boolean
isInternal(String statement)
Whether the given statement is an internal query.Query
parse(String query)
asparse(String, boolean)
by providingtrue
to the initialisation flag.Query
parse(String query, boolean initialise)
Parse the statement and return the query.void
setAllowNumberLiterals(boolean allowNumberLiterals)
void
setAllowTextLiterals(boolean allowTextLiterals)
Enable or disable support for text literals in queries.void
setIncludeSelectorNameInWildcardColumns(boolean value)
void
setSupportSQL1(boolean sql1)
Enable or disable support for SQL-1 queries.
-
-
-
Constructor Detail
-
SQL2Parser
public SQL2Parser(NamePathMapper namePathMapper, NodeTypeInfoProvider nodeTypes, QueryEngineSettings settings, QueryStatsData.QueryExecutionStats stats)
Create a new parser. A parser can be re-used, but it is not thread safe.- Parameters:
namePathMapper
- the name-path mapper to usenodeTypes
- the nodetypessettings
- the query engine settings
-
-
Method Detail
-
parse
public Query parse(String query, boolean initialise) throws ParseException
Parse the statement and return the query.- Parameters:
query
- the query stringinitialise
- if performing the query init (true
) or not (false
)- Returns:
- the query
- Throws:
ParseException
- if parsing fails
-
parse
public Query parse(String query) throws ParseException
asparse(String, boolean)
by providingtrue
to the initialisation flag.- Parameters:
query
-- Returns:
- the parsed query
- Throws:
ParseException
-
setSupportSQL1
public void setSupportSQL1(boolean sql1)
Enable or disable support for SQL-1 queries.- Parameters:
sql1
- the new value
-
getPropertyTypeFromName
public static int getPropertyTypeFromName(String name)
Get the property type from the given case insensitive name.- Parameters:
name
- the property type name (case insensitive)- Returns:
- the type, or
PropertyType.UNDEFINED
if unknown
-
setAllowTextLiterals
public void setAllowTextLiterals(boolean allowTextLiterals)
Enable or disable support for text literals in queries. The default is enabled.- Parameters:
allowTextLiterals
-
-
setAllowNumberLiterals
public void setAllowNumberLiterals(boolean allowNumberLiterals)
-
setIncludeSelectorNameInWildcardColumns
public void setIncludeSelectorNameInWildcardColumns(boolean value)
-
isInternal
public static boolean isInternal(String statement)
Whether the given statement is an internal query.- Parameters:
statement
- the statement- Returns:
- true for an internal query
-
-