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 24 public class MatchNSNotQuery implements IndexQuery,INameSpaceAware,QueryId { 25 26 Class className; 27 Object nameSpace; 28 String propertyName; 29 Comparable value; 30 public final Object alias; 31 static final QueryType QUERY_ID=QueryType.NOT_NS_QUERY; 32 48 49 public MatchNSNotQuery(Class className, Object nameSpace,String propertyName, Comparable value){ 50 this(className,nameSpace,propertyName,value,null); 51 } 52 public MatchNSNotQuery(Class className, Object nameSpace,String propertyName, Comparable value,Object alias){ 53 this.className = className; 54 this.propertyName = propertyName; 55 this.value = value; 56 this.nameSpace = nameSpace; 57 this.alias = alias; 58 } 59 60 public MatchNSNotQuery(String className, Object nameSpace,String propertyName, Comparable value){ 61 this(className,nameSpace, propertyName,value,null); 62 } 63 64 public MatchNSNotQuery(String className, Object nameSpace,String propertyName, Comparable value,Object alias){ 65 Class clazz = null; 66 try{ 67 clazz = ReflectionUtil.classForName(className); 68 }catch (Exception e){ 69 throw new RuntimeException (e); 70 } 71 this.className = clazz; 72 this.propertyName = propertyName; 73 this.value = value; 74 this.nameSpace = nameSpace; 75 this.alias = alias; 76 } 77 78 79 97 public MatchNSNotQuery(Object nameSpace,Comparable value){ 98 this(nameSpace,value,null); 99 } 100 public MatchNSNotQuery(Object nameSpace,Comparable value,Object alias){ 101 this.value = value; 102 this.nameSpace = nameSpace; 103 this.alias = alias; 104 105 } 106 107 110 public Class getClassName() { 111 return className; 112 } 113 114 117 public String getPropertyName() { 118 return propertyName; 119 } 120 121 124 public Comparable getValue() { 125 return value; 126 } 127 128 129 130 131 134 public synchronized INameSpace getNameSpaceWrapper() { 135 136 if (nameSpace instanceof INameSpace){ 137 return (INameSpace) nameSpace; 138 }else{ 139 return new NameSpaceWrapper(nameSpace); 140 } 141 } 142 143 146 public synchronized Object getNameSpace() { 147 return nameSpace; 148 } 149 152 public synchronized void setNameSpace(Object nameSpace) { 153 this.nameSpace = nameSpace; 154 } 155 156 public boolean equals(Object o){ 157 if (o instanceof MatchNSNotQuery){ 158 MatchNSNotQuery temp = (MatchNSNotQuery)o; 159 boolean result = nameSpace.equals(temp.nameSpace); 160 if (!result){ 161 return result; 162 } 163 if (className != null && temp.className != null){ 164 result = className.equals(temp.className); 165 if (!result){ 166 return result; 167 } 168 }else { 169 result = className == null & temp.className == null; 170 if (!result){ 171 return result; 172 } 173 } 174 175 if (propertyName != null && temp.propertyName != null){ 176 result = propertyName.equals(temp.propertyName); 177 if (!result){ 178 return result; 179 } 180 }else { 181 result = propertyName == null & temp.propertyName == null; 182 if (!result){ 183 return result; 184 } 185 } 186 if (value != null && temp.value != null){ 187 result = value.equals(temp.value); 188 if (!result){ 189 return result; 190 } 191 }else { 192 result = value == null & temp.value == null; 193 if (!result){ 194 return result; 195 } 196 } 197 return result; 198 } 199 return false; 200 } 201 202 public int hashCode(){ 203 int temp = nameSpace.hashCode(); 204 if (className != null){ 205 temp+= className.hashCode(); 206 } 207 if (propertyName != null){ 208 temp+= propertyName.hashCode(); 209 } 210 if (value != null){ 211 temp+= value.hashCode(); 212 } 213 return temp; 214 215 216 } 217 public Object getAlias() { 218 return alias; 219 } 220 223 public QueryType getQueryType() { 224 225 return QUERY_ID; 226 } 227 228 public IndexQuery setParameter(String name, Object value) { 229 throw new UnsupportedOperationException ("Parameters are not supported for convenience classes"); 230 } 231 234 public IndexQuery setParameter(int position, Object value) { 235 throw new UnsupportedOperationException ("Parameters are not supported for convenience classes"); 236 237 } 238 public IndexQuery setFirstResult(int firstResult) { 239 throw new UnsupportedOperationException ("Result limitation is not supported for convenience classes"); 240 } 241 public IndexQuery setMaxResults(int maxResults) { 242 throw new UnsupportedOperationException ("Result limitation is not supported for convenience classes"); 243 } 244 } 245 | Popular Tags |