1 package com.jofti.query.namespace; 2 3 import com.jofti.api.IndexQuery; 4 import com.jofti.cache.adapter.NameSpaceWrapper; 5 import com.jofti.core.INameSpace; 6 import com.jofti.core.INameSpaceAware; 7 import com.jofti.core.QueryId; 8 import com.jofti.core.QueryType; 9 import com.jofti.util.ReflectionUtil; 10 11 25 public class MatchNSRangeQuery implements IndexQuery, INameSpaceAware,QueryId { 26 27 public final Object alias; 28 Object nameSpace; 29 Class className; 30 String propertyName; 31 Comparable startValue; 32 Comparable endValue; 33 NameSpaceWrapper wrapper; 34 boolean inclusive =true; 35 36 static final QueryType QUERY_ID=QueryType.RANGE_NS_QUERY; 37 54 public MatchNSRangeQuery(Class className, Object nameSpace, String propertyName, Comparable startValue,Comparable endValue){ 55 this(className,nameSpace,propertyName,startValue,endValue,null); 56 } 57 public MatchNSRangeQuery(Class className, Object nameSpace, String propertyName, Comparable startValue,Comparable endValue,Object alias){ 58 this.className = className; 59 this.propertyName = propertyName; 60 this.startValue = startValue; 61 this.endValue = endValue; 62 this.nameSpace = nameSpace; 63 this.alias=alias; 64 } 65 66 public MatchNSRangeQuery(String className, Object nameSpace, String propertyName, Comparable startValue,Comparable endValue){ 67 this(className,nameSpace,propertyName,startValue,endValue,null); 68 } 69 public MatchNSRangeQuery(String className, Object nameSpace, String propertyName, Comparable startValue,Comparable endValue,Object alias){ 70 Class clazz = null; 71 try{ 72 clazz = ReflectionUtil.classForName(className); 73 }catch (Exception e){ 74 throw new RuntimeException (e); 75 } 76 this.className = clazz; 77 this.propertyName = propertyName; 78 this.startValue = startValue; 79 this.endValue = endValue; 80 this.nameSpace = nameSpace; 81 this.alias =alias; 82 } 83 84 103 104 public MatchNSRangeQuery(Class className, Object nameSpace, String propertyName, Comparable startValue,Comparable endValue, boolean inclusive){ 105 this(className,nameSpace,propertyName,startValue,endValue,inclusive,null); 106 } 107 public MatchNSRangeQuery(Class className, Object nameSpace, String propertyName, Comparable startValue,Comparable endValue, boolean inclusive,Object alias){ 108 this.className = className; 109 this.propertyName = propertyName; 110 this.startValue = startValue; 111 this.endValue = endValue; 112 this.nameSpace = nameSpace; 113 this.inclusive = inclusive; 114 this.alias = alias; 115 } 116 117 public MatchNSRangeQuery(String className, Object nameSpace, String propertyName, Comparable startValue,Comparable endValue, boolean inclusive){ 118 this(className,nameSpace,propertyName,startValue,endValue,inclusive,null); 119 } 120 public MatchNSRangeQuery(String className, Object nameSpace, String propertyName, Comparable startValue,Comparable endValue, boolean inclusive,Object alias){ 121 Class clazz = null; 122 try{ 123 clazz = ReflectionUtil.classForName(className); 124 }catch (Exception e){ 125 throw new RuntimeException (e); 126 } 127 this.className = clazz; 128 this.propertyName = propertyName; 129 this.startValue = startValue; 130 this.endValue = endValue; 131 this.nameSpace = nameSpace; 132 this.inclusive = inclusive; 133 this.alias = alias; 134 } 135 136 155 156 public MatchNSRangeQuery(Object nameSpace,Comparable startValue,Comparable endValue, boolean inclusive){ 157 this(nameSpace,startValue,endValue,inclusive,null); 158 } 159 public MatchNSRangeQuery(Object nameSpace,Comparable startValue,Comparable endValue, boolean inclusive,Object alias){ 160 this.nameSpace = nameSpace; 161 this.startValue = startValue; 162 this.endValue = endValue; 163 this.inclusive = inclusive; 164 this.alias=alias; 165 } 166 169 public Class getClassName() { 170 return className; 171 } 172 173 176 public String getPropertyName() { 177 return propertyName; 178 } 179 180 183 184 185 188 public Comparable getEndValue() { 189 return endValue; 190 } 191 192 195 public Comparable getStartValue() { 196 return startValue; 197 } 198 199 public synchronized INameSpace getNameSpaceWrapper() { 200 201 if (nameSpace instanceof INameSpace){ 202 return (INameSpace) nameSpace; 203 }else{ 204 return new NameSpaceWrapper(nameSpace); 205 } 206 } 207 210 public synchronized Object getNameSpace() { 211 return nameSpace; 212 } 213 216 public synchronized void setNameSpace(Object nameSpace) { 217 this.nameSpace = nameSpace; 218 } 219 public boolean isInclusive() { 220 return inclusive; 221 } 222 public void setInclusive(boolean inclusive) { 223 this.inclusive = inclusive; 224 } 225 public Object getAlias() { 226 return alias; 227 } 228 229 public QueryType getQueryType() { 230 231 return QUERY_ID; 232 } 233 234 public IndexQuery setParameter(String name, Object value) { 235 throw new UnsupportedOperationException ("Parameters are not supported for convenience classes"); 236 } 237 240 public IndexQuery setParameter(int position, Object value) { 241 throw new UnsupportedOperationException ("Parameters are not supported for convenience classes"); 242 243 } 244 public IndexQuery setFirstResult(int firstResult) { 245 throw new UnsupportedOperationException ("Result limitation is not supported for convenience classes"); 246 } 247 public IndexQuery setMaxResults(int maxResults) { 248 throw new UnsupportedOperationException ("Result limitation is not supported for convenience classes"); 249 } 250 } 251 | Popular Tags |