Java Doc for ConstraintParser.java in  » Database-ORM » MMBase » org » mmbase » storage » search » legacy » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » MMBase » org.mmbase.storage.search.legacy 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.mmbase.storage.search.legacy.ConstraintParser

ConstraintParser
public class ConstraintParser (Code)
Parser, tries to parse a SQL-search-condition for a query to a org.mmbase.storage.search.Constraint Constraint object.

This class is provided for the sole purpose of alignment of old code with the new org.mmbase.storage.search.SearchQuery SearchQuery framework, and should not be called by new code.

A SQL-search-condition can be one of these forms:

  • [NOT] (SQL-search-condition)
  • [NOT] simple-SQL-search-condition
  • SQL-search-condition AND SQL-search-condition
  • SQL-search-condition OR SQL-search-condition
A simple-SQL-search-condition string can be of one of these forms:
  • field [NOT] LIKE value
  • UPPER(field) [NOT] LIKE value
  • LOWER(field) [NOT] LIKE value
  • field IS [NOT] NULL
  • field [NOT] IN (value1, value2, ..)
  • field [NOT] BETWEEN value1 AND value2
  • UPPER(field) [NOT] BETWEEN value1 AND value2
  • LOWER(field) [NOT] BETWEEN value1 AND value2
  • field = value
  • field = field2
  • UPPER(field) = value
  • LOWER(field) = value
  • field == value
  • field == field2
  • field <= value
  • field <= field2
  • field < value
  • field < field2
  • field >= value
  • field >= field2
  • field > value
  • field > field2
  • field <> value
  • field <> field2
  • field != value
  • field != field2
  • string-search-condition
A field can be one of these forms:
  • stepalias.fieldname
  • fieldname (only when the query has just one step).
A value can be one of these forms:
  • string between single quotes for string fields, example: 'A string value'
  • numerical value for numerical fields, example: 123.456
  • numerical value between single quotes for numerical fields, example" '123.456'
A string-search-condition can be of this form:
  • StringSearch(field,PHRASE|PROXIMITY|WORD, FUZZY|LITERAL|SYNONYM, searchterms, casesensitive) [.set(FUZZINESS,fuzziness)] [.set(PROXIMITY_LIMIT,proximity)]
searchterms can be of one of these forms:
  • 'term1'
  • "term1"
  • 'term1 term2'
  • "term1 term2"
  • etc...
casesensitive can be of one on these forms:
  • true
  • false
fuzziness must be a float value between 0.0 and 1.0, proximity must be a int value > 0

See org.mmbase.storage.search.StringSearchConstraintStringSearchConstraint for more info on string-search constraints.

A search condition that is not of one of these forms will be converted to a org.mmbase.storage.search.LegacyConstraint 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.
author:
   Rob van Maris
version:
   $Id: ConstraintParser.java,v 1.35 2007/11/28 10:17:47 michiel Exp $
since:
   MMBase-1.7




Constructor Summary
public  ConstraintParser(SearchQuery query)
    

Method Summary
public static  StringconvertClauseToDBS(String constraints)
     Converts a constraint by turning all 'quoted' fields into database supported fields.
public static  StepFieldgetField(String token, List<? extends Step> steps)
     Creates StepField corresponding to field indicated by token, of one of the specified steps.

A field can be one of these forms:

  • stepalias.fieldname
  • [stepalias.fieldname]
  • fieldname (only when just one step is specified).
  • [fieldname] (only when just one step is specified).

Parameters:
  token - The token.
Parameters:
  steps - The steps.
static  StepFieldgetField(String token, List<BasicStep> steps, SearchQuery query)
     Creates StepField corresponding to field indicated by token, of one of the specified steps.
 StepFieldgetField(String token)
     Parses a field string, and produces a corresponding StepField object.

See ConstraintParser above for the format of a field
Parameters:
  token - The token.

 BasicConstraintparseCondition(ListIterator<String> iTokens)
     Parses SQL-search-condition string from list of tokens, and produces a corresponding BasicConstraint object.

See ConstraintParser above for the format of a SQL-search-condition
Parameters:
  iTokens - Tokens iterator, must be positioned before the (first)token representing the condition.

 BasicConstraintparseSimpleCondition(ListIterator<String> iTokens)
     Parses a simple-SQL-search-condition string from list of tokens, and produces a corresponding BasicConstraint object.

See ConstraintParser above for the format of a simple-SQL-search-condition
Parameters:
  iTokens - Tokens iterator, must be positioned before the (first)token representing the condition.

static  ObjectparseValue(Iterator<String> iTokens, StepField field)
     Parses string or numerical value from list of tokens, to match the type of the specified field. If the first token is not "'", it is interpreted as a numerical value, otherwise it is required to be the first token of the sequence "'", "value", "'", representing a string value for string fields, or a numerical value for numerical fields.
Parameters:
  iTokens - Tokens iterator, must be positioned before the (first)token representing the value.
Parameters:
  field - The field.
public  ConstrainttoConstraint(String sqlConstraint)
     Parses SQL-search-condition, and produces a corresponding org.mmbase.storage.search.Constraint Constraint object.

See ConstraintParser above for the format of a SQL-search-condition.
Parameters:
  sqlConstraint - The non-null SQL constraint string.

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.
Parameters:
  sqlConstraint - The SQL constraint string.
public static  booleanvalidConstraints(String constraints)
    


Constructor Detail
ConstraintParser
public ConstraintParser(SearchQuery query)(Code)
Creates a new instance of ConstraintParser
Parameters:
  query -




Method Detail
convertClauseToDBS
public static String convertClauseToDBS(String constraints)(Code)
Converts a constraint by turning all 'quoted' fields into database supported fields. XXX: todo: escape characters for '[' and ']'.
Parameters:
  constraints - constraints to convert converted constraint
since:
   MMBase-1.8.1 (moved from org.mmbase.bridge.util.Queries)



getField
public static StepField getField(String token, List<? extends Step> steps)(Code)
Creates StepField corresponding to field indicated by token, of one of the specified steps.

A field can be one of these forms:

  • stepalias.fieldname
  • [stepalias.fieldname]
  • fieldname (only when just one step is specified).
  • [fieldname] (only when just one step is specified).

Parameters:
  token - The token.
Parameters:
  steps - The steps. The field.



getField
static StepField getField(String token, List<BasicStep> steps, SearchQuery query)(Code)
Creates StepField corresponding to field indicated by token, of one of the specified steps.

A field can be one of these forms:

  • stepalias.fieldname
  • [stepalias.fieldname]
  • fieldname (only when just one step is specified, or query is an instance of NodeQuery).
  • [fieldname] (only when just one step is specified, or query is an instance of NodeQuery).

Parameters:
  token - The token.
Parameters:
  steps - The steps.
Parameters:
  query - The used query The field.
since:
   MMBase-1.7.1



getField
StepField getField(String token)(Code)
Parses a field string, and produces a corresponding StepField object.

See ConstraintParser above for the format of a field
Parameters:
  token - The token. The field.




parseCondition
BasicConstraint parseCondition(ListIterator<String> iTokens)(Code)
Parses SQL-search-condition string from list of tokens, and produces a corresponding BasicConstraint object.

See ConstraintParser above for the format of a SQL-search-condition
Parameters:
  iTokens - Tokens iterator, must be positioned before the (first)token representing the condition. The constraint.




parseSimpleCondition
BasicConstraint parseSimpleCondition(ListIterator<String> iTokens)(Code)
Parses a simple-SQL-search-condition string from list of tokens, and produces a corresponding BasicConstraint object.

See ConstraintParser above for the format of a simple-SQL-search-condition
Parameters:
  iTokens - Tokens iterator, must be positioned before the (first)token representing the condition. The constraint.




parseValue
static Object parseValue(Iterator<String> iTokens, StepField field) throws NumberFormatException(Code)
Parses string or numerical value from list of tokens, to match the type of the specified field. If the first token is not "'", it is interpreted as a numerical value, otherwise it is required to be the first token of the sequence "'", "value", "'", representing a string value for string fields, or a numerical value for numerical fields.
Parameters:
  iTokens - Tokens iterator, must be positioned before the (first)token representing the value.
Parameters:
  field - The field. A String or Double object representingthe value.
throws:
  NumberFormatException - when the first token is not (the start of)a valid value expression (it may be a field instead).



toConstraint
public Constraint toConstraint(String sqlConstraint)(Code)
Parses SQL-search-condition, and produces a corresponding org.mmbase.storage.search.Constraint Constraint object.

See ConstraintParser above for the format of a SQL-search-condition.
Parameters:
  sqlConstraint - The non-null SQL constraint string. The constraint.




tokenize
static List<String> tokenize(String sqlConstraint)(Code)
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.
Parameters:
  sqlConstraint - The SQL constraint string. List of tokens.



validConstraints
public static boolean validConstraints(String constraints)(Code)
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)
Parameters:
  constraints - constraint to check is valid constraint
since:
   MMBase-1.8.1 (moved from org.mmbase.bridge.util.Queries)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.