|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.mkdoc.query.AbstractQueryBuilder
A base implementation of a query interpreter.
Field Summary | |
protected boolean |
extendable
Whether any properties have optional encoding schemes. |
protected boolean |
extended
Whether to use extended bNode queries. |
protected ApplicationProfile |
profile
The application profile to use for interpreting queries. |
Fields inherited from interface com.mkdoc.query.QueryBuilder |
APPEND_AND, APPEND_COMMA, APPEND_OR, CONSTRUCT, DELIMITERS, DISTINCT, FROM, LIKE, NOT_LIKE, QUOTE, SELECT, SPACE, USING, WHERE |
Constructor Summary | |
AbstractQueryBuilder()
|
Method Summary | |
protected void |
addCondition(SchemaProperty property,
java.lang.String term)
Add a condition to the query selection. |
protected void |
addExpression(SchemaProperty property)
Add a path expression to the query. |
protected void |
addNamespaceDeclaration(SchemaProperty property)
Add a namespace declaration to the query selection. |
protected void |
addSummaryExpression(SchemaProperty property)
Add an optional summary expression to the query. |
protected void |
addTitleExpression(SchemaProperty property)
Add an optional title expression to the query. |
protected void |
addVariable(SchemaProperty property)
Add a variable name. |
protected void |
appendConditions(java.lang.StringBuffer query)
Append conditions for the first selection in a union query. |
protected void |
appendPrimaryExpressions(java.lang.StringBuffer query)
Append path expressions for the first selection in a union query. |
protected void |
appendSecondaryExpressions(java.lang.StringBuffer query)
Append path expressions for the second selection in a union query. |
java.util.List |
getQueryTerms(java.lang.String query)
Get query terms from a string input. |
java.lang.String |
getSeRQLQuery(boolean extended)
Get a SeRQL query string. |
protected boolean |
hasExtendableProperties()
Check whether the query has properties that may have encoded schema. |
protected boolean |
isDelimiter(java.lang.String token)
Check whether a string token is a query delimiter. |
protected boolean |
isUriQuery(SchemaProperty property,
java.lang.String term)
Check whether this is a URI query. |
void |
setApplicationProfile(ApplicationProfile profile)
Set the application profile to use for interpreting queries. |
void |
setDistinct(boolean distinct)
Set whether the DISTINCT keyword is applied. |
protected void |
setQueryType(java.lang.String queryType)
Set query type. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.mkdoc.query.QueryBuilder |
getQuery |
Field Detail |
protected boolean extended
protected boolean extendable
protected ApplicationProfile profile
Constructor Detail |
public AbstractQueryBuilder()
Method Detail |
public final void setApplicationProfile(ApplicationProfile profile)
setApplicationProfile
in interface QueryBuilder
profile
- The application profile to use to prepare the query.public final java.util.List getQueryTerms(java.lang.String query)
The parse rules for query parameters are as follows:
White space includes the single space, tab, new line, carriage return, and form feed characters. Any white space after the first, and before the last, non-white space character is interpreted as a single space, which is a word separator.
All leading and trailing white space characters are trimmed and discarded.
A single word is interpreted as a match against the single word content of a metadata field. The SeRQL condition for the query "cat" is:
WHERE label(varX) LIKE "cat"
This query would only match the literal word "cat", not a phrase that included the word, such as "the cat sat on the mat". See "Wildcard before and after".
Multiple words are interpreted as if each word is an alternative match against the single word content of a metadata field. The SeRQL condition for the query "cat dog" is:
WHERE label(varX) LIKE "cat" OR label(varX) LIKE "dog"
This would only match the literal word "cat" or "dog", not a phrase that included either word, such as "fought like cat and dog". See "Wildcard before and after".
The wildcard schemes described below can be applied to multiple query terms. For example, the query "*cat* *dog*" would match "fought like cat and dog", "I like cats" and "I like dogs".
A word with an asterisk before it is interpreted as the end of a phrase, or the suffix to a single word, where any number of characters may be matched before it, but not after it. The SeRQL condition for the query "*cat" is:
WHERE label(varX) LIKE "*cat"
This would match "cat", "senses of a cat" and "polecat", but not "cats" or "fought like cat and dog".
A word with an asterisk after it is interpreted as the start of a phrase, or the prefix to a single word, where any number of characters may be matched after it, but not before it. The SeRQL condition for the query "cat*" is:
WHERE label(varX) LIKE "cat*"
This would match "cat", "cats" and "cats and dogs", but not "polecat" or "senses of a cat".
A word with an asterisk before and after it is interpreted as the middle of a phrase, or part of a compound word, where any number of characters may be matched before and after it. The SeRQL condition for the query "*cat*" is:
WHERE label(varX) LIKE "*cat*"
This would match "cat", "cats", "cats and dogs", "polecat" and "senses of a cat".
A phrase enclosed by double quote characters, "
, is
interpreted as a match against the whole content of a single
metadatum field. The SeRQL condition for "cat litter"
is:
WHERE label(varX) LIKE "cat litter"
This would only match "cat litter", not "cat litter tray", "use cat litter", "cat" or "litter".
Quoted phrases can also be include wildcard asterisks at the beginning and end of the phrase. The query "*cat litter" would match "use cat litter" and "buy cat litter", for example.
Un-terminated quoted phrases are interpreted as everything following an opening double quote to the end of the query parameter.
getQueryTerms
in interface QueryBuilder
query
- The contents of a single metadata query field, which
may include multiple search terms separated by delimiters.
Vector
containing all phrase- and word-query
tokens. If the query is the empty string or pure white space,
the list will be empty, so clients should check its size
before further processing.protected final boolean isDelimiter(java.lang.String token)
token
- The string to test.
true
if the input is a single character from the
set of query delimiters.protected final void addVariable(SchemaProperty property)
property
- The schema property for which to add a query
variable.protected final void addExpression(SchemaProperty property)
property
- The schema property for which to add a query
expression.protected final void addSummaryExpression(SchemaProperty property)
property
- The schema property for which to add an optional
summary expression.protected final void addTitleExpression(SchemaProperty property)
property
- The schema property for which to add an optional
title expression.protected final void addCondition(SchemaProperty property, java.lang.String term)
property
- The schema property for which to add a query
condition.term
- The query term.protected final void addNamespaceDeclaration(SchemaProperty property)
property
- The schema property for which to add a query
namespace declaration.public final void setDistinct(boolean distinct)
DISTINCT
keyword is applied.
setDistinct
in interface QueryBuilder
distinct
- Whether the query interpreter should suppress
duplicate results.protected final void setQueryType(java.lang.String queryType)
queryType
- SELECT
or CONSTRUCT
.public final java.lang.String getSeRQLQuery(boolean extended)
extended
- Whether an extended bNode union query is requested.
protected final boolean hasExtendableProperties()
true
if any property registered for the query has
an optional encoding scheme.protected final void appendPrimaryExpressions(java.lang.StringBuffer query)
query
- The query buffer to which to append the expressions.protected final void appendConditions(java.lang.StringBuffer query)
query
- The query buffer to which to append the expressions.protected final boolean isUriQuery(SchemaProperty property, java.lang.String term)
property
- The schema property against which the query term
is to be tested.term
- The user query term to check.
true
if the schema property has a URI encoding
scheme and the query term is a URI.protected final void appendSecondaryExpressions(java.lang.StringBuffer query)
query
- The query buffer to which to append the expressions.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |