1 23 24 package org.apache.slide.search.basic.expression; 25 26 import org.apache.slide.content.NodeProperty.NamespaceCache; 27 import org.apache.slide.search.InvalidQueryException; 28 import org.apache.slide.search.basic.ComparableResource; 29 import org.apache.slide.search.basic.ComparableResourcesPool; 30 import org.apache.slide.search.basic.Literals; 31 import org.jdom.Element; 32 33 38 public abstract class ComparePropertyExpression extends CompareExpression { 39 40 protected ComparedProperty comparedProperty; 41 42 43 44 56 63 public ComparePropertyExpression (Element e, ComparableResourcesPool requestedResourcesPool, boolean expectLiteral) throws InvalidQueryException { 64 this(e, requestedResourcesPool, new ComparedProperty (e, expectLiteral)); 65 } 66 73 protected ComparePropertyExpression (Element e, ComparableResourcesPool requestedResourcesPool, ComparedProperty comparedProperty) throws InvalidQueryException { 74 super (e, requestedResourcesPool); 75 this.comparedProperty = comparedProperty; 76 } 77 78 79 80 88 protected abstract boolean compare (ComparableResource item); 89 90 95 protected String toString (String op) { 96 return "(" +comparedProperty.getProperty() + " " 97 + op + " " + comparedProperty.getLiteral() + ")"; 98 } 99 100 110 protected String getLiteral(Element e) throws InvalidQueryException { 111 Element lit = e.getChild (Literals.LITERAL, NamespaceCache.DEFAULT_NAMESPACE); 112 if (lit == null) 113 throw new InvalidQueryException 114 ("No literal element supplied"); 115 116 return lit.getText (); 117 } 118 } 119 120 | Popular Tags |