/** * Given a [queriable] instance, tells wether this instance satisfies the * query. * This implementation delegates the work to the underlying [real] query. */ public boolean validate (final Object o) throws QueryException { //log.debug("validate() this is \n"+this.toString()); final QueryItem qi = fetch(); //log.debug("validate() fetch returned \n"+qi.toString()); return qi.validate(o); }
/** * Does the query and returns a set, the necessary info is given as a java * instance. * This implementation delegates the work to the underlying [real] query. */ public Set query (final Object o) throws QueryException { final QueryItem qi = fetch(); return qi.query(o); }
/** * Given a query item in its XML element form, returns the corresponding * query item. */ public QueryItem determineQueryItem (final Query parentQuery, final Object o) throws QueryException { final org.jdom.Element elt = (org.jdom.Element)o; final String classname = (String)this.config.get(elt.getName()); //log.debug("determineQueryItem() classname : "+classname); if (classname == null) { throw new QueryException ("no query item class for elt named '"+elt.getName()+"'"); } final QueryItem qi = (QueryItem)ReflectionUtils.buildNewInstance(classname); qi.init(this, parentQuery, elt); //if (parentQuery != null) parentQuery.put(qi); return qi; }
public boolean validate (final Object o) throws QueryException { if (getChildren() == null || getChildren().size() < 1) return false; final java.util.Iterator it = getChildren().iterator(); while (it.hasNext()) { final QueryItem qi = (QueryItem)it.next(); if ( ! qi.validate(o)) return false; } return true; }
public Set query (final Object o) throws QueryException { if (getChildren() == null || getChildren().size() < 1) return null; Set result = null; final java.util.Iterator it = getChildren().iterator(); while (it.hasNext()) { final QueryItem qi = (QueryItem)it.next(); if (result == null) result = qi.query(o); else result = SetUtils.doUnion(result, qi.query(o)); } return result; }
public boolean validate (final Object o) throws QueryException { if (getChild() == null) return false; return ! getChild().validate(o); }
public Set query (final Object o) throws QueryException { if (getChildren() == null || getChildren().size() < 1) return null; Set result = null; final java.util.Iterator it = getChildren().iterator(); while (it.hasNext()) { final QueryItem qi = (QueryItem)it.next(); if (result == null) result = qi.query(o); else result = SetUtils.doIntersection(result, qi.query(o)); if (result.isEmpty()) break; } return result; }
public boolean validate (final Object o) throws QueryException { //log.debug("validate()"); if (getChildren() == null || getChildren().size() < 1) { //log.debug("validate() no children : returning false"); return false; } final java.util.Iterator it = getChildren().iterator(); while (it.hasNext()) { final QueryItem qi = (QueryItem)it.next(); if (qi.validate(o)) return true; } //log.debug("validate() finally returning false"); return false; }
public Set query (final Object o) throws QueryException { if (getChild() == null) return null; final Set result = getChild().query(o); result.invert(); return result; }
public static void main (String[] args) throws Exception { // // init query map //ApplicationContext con = new ApplicationContext(); java.util.Map params = new java.util.HashMap(); params.put ("queryConfigurationFile", "tst/query-config.xml"); XmlQueryMap queryMap = new XmlQueryMap(); queryMap.init("queryMap", null, params); QueryItem qi = queryMap.lookupQuery("tst/query-map.xml#Store.querystore#charly"); //log.debug("qi.class is "+qi.getClass().getName()); org.jdom.Element elt = new org.jdom.Element("toto"); elt.setAttribute("participantName", "role-bravo"); log.debug("validate returns "+qi.validate(elt)); }
if (queryItem.validate(item)) results.add(item);