1 package com.jofti.query; 2 3 import com.jofti.api.IndexQuery; 4 import com.jofti.core.QueryId; 5 import com.jofti.core.QueryType; 6 import com.jofti.util.ReflectionUtil; 7 8 19 20 public class MatchRangeQuery implements IndexQuery, QueryId { 21 22 public final Object alias; 23 int hashCode =0; 24 Class className; 25 String propertyName; 26 Comparable startValue; 27 Comparable endValue; 28 boolean inclusive =true; 29 30 static final QueryType QUERY_ID=QueryType.RANGE_QUERY; 31 32 47 public MatchRangeQuery(Class className, String propertyName, Comparable startValue,Comparable endValue){ 48 this(className,propertyName,startValue,endValue,null); 49 } 50 51 public MatchRangeQuery(Class className, String propertyName, Comparable startValue,Comparable endValue,Object alias){ 52 this.className = className; 53 this.propertyName = propertyName; 54 this.startValue = startValue; 55 this.endValue = endValue; 56 this.alias = alias; 57 } 58 59 74 public MatchRangeQuery(String className, String propertyName, Comparable startValue,Comparable endValue){ 75 this(className,propertyName,startValue,endValue,null); 76 } 77 public MatchRangeQuery(String className, String propertyName, Comparable startValue,Comparable endValue,Object alias){ 78 Class clazz = null; 79 try{ 80 clazz = ReflectionUtil.classForName(className); 81 }catch (Exception e){ 82 throw new RuntimeException (e); 83 } 84 this.className = clazz; 85 this.propertyName = propertyName; 86 this.startValue = startValue; 87 this.endValue = endValue; 88 this.alias =alias; 89 } 90 106 public MatchRangeQuery(Class className, String propertyName, Comparable startValue,Comparable endValue,boolean inclusive){ 107 this(className,propertyName,startValue,endValue,null); 108 } 109 public MatchRangeQuery(Class className, String propertyName, Comparable startValue,Comparable endValue,boolean inclusive,Object alias){ 110 this.className = className; 111 this.propertyName = propertyName; 112 this.startValue = startValue; 113 this.endValue = endValue; 114 this.inclusive = inclusive; 115 this.alias = alias; 116 } 117 118 134 public MatchRangeQuery(String className, String propertyName, Comparable startValue,Comparable endValue,boolean inclusive){ 135 this(className, propertyName,startValue,endValue,inclusive,null); 136 } 137 138 public MatchRangeQuery(String className, String propertyName, Comparable startValue,Comparable endValue,boolean inclusive,Object alias){ 139 Class clazz = null; 140 try{ 141 clazz = ReflectionUtil.classForName(className); 142 }catch (Exception e){ 143 throw new RuntimeException (e); 144 } 145 this.className = clazz; 146 this.propertyName = propertyName; 147 this.startValue = startValue; 148 this.endValue = endValue; 149 this.inclusive = inclusive; 150 this.alias =alias; 151 } 152 167 public MatchRangeQuery(Comparable startValue,Comparable endValue, boolean inclusive){ 168 this(startValue,endValue,inclusive,null); 169 } 170 public MatchRangeQuery(Comparable startValue,Comparable endValue, boolean inclusive,Object alias){ 171 this.startValue = startValue; 172 this.endValue = endValue; 173 this.inclusive = inclusive; 174 this.alias =alias; 175 } 176 179 public Class getClassName() { 180 return className; 181 } 182 183 186 public String getPropertyName() { 187 return propertyName; 188 } 189 190 193 194 195 198 public Comparable getEndValue() { 199 return endValue; 200 } 201 202 205 public Comparable getStartValue() { 206 return startValue; 207 } 208 public boolean isInclusive() { 209 return inclusive; 210 } 211 public void setInclusive(boolean inclusive) { 212 this.inclusive = inclusive; 213 } 214 215 public QueryType getQueryType() 216 { 217 218 return QUERY_ID; 219 } 220 221 222 public Object getAlias() { 223 return alias; 224 } 225 226 public IndexQuery setParameter(String name, Object value) { 227 throw new UnsupportedOperationException ("Parameters are not supported for convenience classes"); 228 } 229 232 public IndexQuery setParameter(int position, Object value) { 233 throw new UnsupportedOperationException ("Parameters are not supported for convenience classes"); 234 235 } 236 237 public IndexQuery setFirstResult(int firstResult) { 238 throw new UnsupportedOperationException ("result limits are not supported for convenience classes"); 239 240 } 241 public IndexQuery setMaxResults(int maxResults) { 242 throw new UnsupportedOperationException ("result limits are not supported for convenience classes"); 243 244 } 245 } 246 | Popular Tags |