1 5 package com.jofti.query; 6 7 8 import java.util.HashMap ; 9 import java.util.Map ; 10 11 import com.jofti.api.IndexQuery; 12 import com.jofti.core.QueryId; 13 import com.jofti.core.QueryType; 14 15 90 public class EJBQuery implements IndexQuery, QueryId { 91 92 String query = null; 93 94 int hashCode =0; 95 Map parameterMap = new HashMap (); 96 97 int maxResults; 98 int firstResult; 99 100 static final QueryType QUERY_ID=QueryType.UNPARSED_QUERY; 101 102 private static final String TERMINATOR =";"; 103 104 public EJBQuery(String query){ 105 this.query = query + TERMINATOR; 106 } 107 108 public String getQuery(){ 109 return this.query; 110 } 111 112 113 public QueryType getQueryType() 114 { 115 116 return QUERY_ID; 117 } 118 119 129 public IndexQuery setParameter(String name, Object value){ 130 parameterMap.put(name, value); 131 return this; 132 } 133 134 135 144 public IndexQuery setParameter(int parameter, Object value){ 145 parameterMap.put(""+parameter, value); 146 return this; 147 } 148 149 154 public Map getParameterMap(){ 155 return parameterMap; 156 } 157 158 public void clearParameters(){ 159 parameterMap.clear(); 160 } 161 162 165 public int hashCode(){ 166 if (hashCode ==0){ 167 hashCode = query.hashCode(); 168 } 169 return hashCode; 170 } 171 172 175 public boolean equals(Object obj){ 176 return query.equals(obj); 177 } 178 179 public String toString(){ 180 return query; 181 } 182 183 public IndexQuery setFirstResult(int firstResult) { 184 this.firstResult= firstResult; 185 return this; 186 } 187 188 public int getFirstResult() { 189 190 return firstResult; 191 } 192 193 public int getMaxResults() { 194 195 return maxResults; 196 } 197 198 public IndexQuery setMaxResults(int maxResults) { 199 this.maxResults=maxResults; 200 return this; 201 } 202 } 203 | Popular Tags |