Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 4987

Show
Ignore:
Timestamp:
07/19/08 13:43:05 (2 months ago)
Author:
bmamlin
Message:

logic-api-refactoring: added simple logic query parser, available via LogicCriteria.parse(String) method.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/branches/logic-api-refactoring/src/api/org/openmrs/logic/LogicCriteria.java

    r4958 r4987  
    1717import java.util.Map; 
    1818 
    19 import org.openmrs.Concept; 
    2019import org.openmrs.logic.op.Operator; 
    2120 
     
    339338        } 
    340339     
    341      
     340    /** 
     341     * Parses a query string into a LogicCriteria object.  For example, a phrase like <em>"LAST 
     342     * {CD4 COUNT} > 200"</em> is parsed into a LogicCriteria object equivalent to: 
     343     * <code>new LogicCriteria("CD4 COUNT").gt(200).last()</code>. 
     344     *  
     345     * This function will fail quietly.  If an exception occurs during parsing, then this method 
     346     * will return a LogicCriteria constructed with the given query string without any parsing. 
     347     * The actual work of parsing is performed by the LogicQueryParser class. 
     348     *  
     349     * @param query a logic query to be parsed 
     350     * @return the equivalent LogicCriteria to the given query string 
     351     * @see org.openmrs.logic.LogicQueryParser 
     352     */ 
     353    public static LogicCriteria parse(String query) { 
     354        try { 
     355                return LogicQueryParser.parse(query); 
     356        } catch (LogicQueryParseException e) { 
     357                return new LogicCriteria(query); 
     358        } 
     359    } 
    342360 
    343361        /**