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 public class MatchQuery implements IndexQuery, QueryId { 20 21 22 public final Object alias; 23 public final Class className; 24 public final String propertyName; 25 public final Comparable value; 26 static final QueryType QUERY_ID=QueryType.MATCH_QUERY; 27 28 29 44 public MatchQuery(Class className, String propertyName, Comparable value){ 45 this(className, propertyName, value, null); 46 } 47 public MatchQuery(Class className, String propertyName, Comparable value, Object alias){ 48 this.className = className; 49 this.propertyName = propertyName; 50 this.value = value; 51 this.alias = alias; 52 } 53 54 69 public MatchQuery(String className, String propertyName, Comparable value){ 70 this(className, propertyName, value, null); 71 } 72 public MatchQuery(String className, String propertyName, Comparable value, Object alias){ 73 Class clazz = null; 74 try{ 75 clazz = ReflectionUtil.classForName(className); 76 }catch (Exception e){ 77 throw new RuntimeException (e); 78 } 79 this.className = clazz; 80 this.propertyName = propertyName; 81 this.value = value; 82 this.alias = alias; 83 } 84 100 public MatchQuery(Comparable value){ 101 this.value = value; 102 alias =null; 103 className =null; 104 propertyName =null; 105 } 106 109 public Class getClassName() { 110 return className; 111 } 112 113 116 public String getPropertyName() { 117 return propertyName; 118 } 119 120 123 public Comparable getValue() { 124 return value; 125 } 126 127 public QueryType getQueryType() 128 { 129 return QUERY_ID; 130 } 131 132 133 public Object getAlias() { 134 return alias; 135 } 136 137 public IndexQuery setParameter(String name, Object value) { 138 throw new UnsupportedOperationException ("Parameters are not supported for convenience classes"); 139 } 140 143 public IndexQuery setParameter(int position, Object value) { 144 throw new UnsupportedOperationException ("Parameters are not supported for convenience classes"); 145 146 } 147 public IndexQuery setFirstResult(int firstResult) { 148 throw new UnsupportedOperationException ("result limits are not supported for convenience classes"); 149 150 } 151 public IndexQuery setMaxResults(int maxResults) { 152 throw new UnsupportedOperationException ("result limits are not supported for convenience classes"); 153 154 } 155 156 } 157 | Popular Tags |