public class ConstraintParser extends Object
Constraint object.
This class is provided for the sole purpose of alignment of old code with
the new SearchQuery framework,
and should not be called by new code.
A SQL-search-condition can be one of these forms:
'A string value'
123.456
'123.456'
See StringSearchConstraint for more info on string-search constraints.
A search condition that is not of one of these forms will be converted to a
LegacyConstraint, i.e.
in that case the search condition string will not be interpreted, but
instead be used "as-is".
Each time this occurs is logged with priority service to
category org.mmbase.storage.search.legacyConstraintParser.fallback.
| Constructor and Description |
|---|
ConstraintParser(SearchQuery query)
Creates a new instance of ConstraintParser
|
| Modifier and Type | Method and Description |
|---|---|
static String |
convertClauseToDBS(String constraints)
Converts a constraint by turning all 'quoted' fields into
database supported fields.
|
(package private) StepField |
getField(String token)
Parses a field string, and produces a corresponding
StepField object. |
static StepField |
getField(String token,
List<? extends Step> steps)
Creates
StepField corresponding to field indicated by
token, of one of the specified steps. |
(package private) static StepField |
getField(String token,
List<BasicStep> steps,
SearchQuery query)
Creates
StepField corresponding to field indicated by
token, of one of the specified steps. |
(package private) BasicConstraint |
parseCondition(ListIterator<String> iTokens)
Parses SQL-search-condition string from list of tokens, and
produces a corresponding
BasicConstraint object. |
(package private) BasicConstraint |
parseSimpleCondition(ListIterator<String> iTokens)
Parses a simple-SQL-search-condition string from list of tokens,
and produces a corresponding
BasicConstraint object. |
(package private) static Object |
parseValue(Iterator<String> iTokens,
StepField field)
Parses string or numerical value from list of tokens, to match the type
of the specified field.
|
Constraint |
toConstraint(String sqlConstraint)
Parses SQL-search-condition, and produces a corresponding
Constraint object. |
(package private) static List<String> |
tokenize(String sqlConstraint)
Parses SQL search condition string into separate tokens, discarding
white spaces, concatenating strings between (single/double) quotes,
and replacing escaped (single/double) quotes in strings by the
original character.
|
static boolean |
validConstraints(String constraints)
returns false, when escaping wasnt closed, or when a ";" was found outside a escaped part (to prefent spoofing)
This is used by createQuery (i wonder if it still makes sense)
|
public ConstraintParser(SearchQuery query)
query - public static String convertClauseToDBS(String constraints)
constraints - constraints to convertpublic static boolean validConstraints(String constraints)
constraints - constraint to checkstatic Object parseValue(Iterator<String> iTokens, StepField field) throws NumberFormatException
iTokens - Tokens iterator, must be positioned before the (first)
token representing the value.field - The field.String or Double object representing
the value.NumberFormatException - when the first token is not (the start of)
a valid value expression (it may be a field instead).static List<String> tokenize(String sqlConstraint)
sqlConstraint - The SQL constraint string.public static StepField getField(String token, List<? extends Step> steps)
StepField corresponding to field indicated by
token, of one of the specified steps.
A field can be one of these forms:
token - The token.steps - The steps.static StepField getField(String token, List<BasicStep> steps, SearchQuery query)
StepField corresponding to field indicated by
token, of one of the specified steps.
A field can be one of these forms:
token - The token.steps - The steps.query - The used querypublic Constraint toConstraint(String sqlConstraint)
Constraint object.
See above for the format of a
SQL-search-condition.
sqlConstraint - The non-null SQL constraint string.StepField getField(String token)
StepField object.
See above for the format of a
field
token - The token.BasicConstraint parseCondition(ListIterator<String> iTokens)
BasicConstraint object.
See above for the format of a
SQL-search-condition
iTokens - Tokens iterator, must be positioned before the (first)
token representing the condition.BasicConstraint parseSimpleCondition(ListIterator<String> iTokens)
BasicConstraint object.
See above for the format of a
simple-SQL-search-condition
iTokens - Tokens iterator, must be positioned before the (first)
token representing the condition.MMBase 1.9-SNAPSHOT - ${javadoctimestamp}