001: /*
002: * Created on 17-Jul-2005
003: *
004: * TODO To change the template for this generated file go to
005: * Window - Preferences - Java - Code Style - Code Templates
006: */
007: package com.jofti.parser;
008:
009: import java.util.ArrayList;
010: import java.util.HashMap;
011: import java.util.LinkedHashMap;
012: import java.util.List;
013: import java.util.Map;
014: import java.util.Stack;
015:
016: import com.jofti.api.IndexQuery;
017: import com.jofti.core.INameSpaceAware;
018: import com.jofti.core.IParsedQuery;
019: import com.jofti.core.QueryId;
020: import com.jofti.core.QueryType;
021: import com.jofti.util.CompositeComparator;
022:
023: /**
024: *
025: *
026: * Implementation of the IParsedQuery.
027: *
028: * @author xenephon (xenephon@jofti.com)
029: */
030: public class ParsedQuery implements IParsedQuery, IndexQuery,
031: INameSpaceAware, QueryId {
032:
033: private Class className;
034: private Map aliasMap = new HashMap();
035:
036: private Map namedValueMap = null;
037: private Stack predicates = new Stack();
038:
039: private Object nameSpace = null;
040:
041: private Map fieldReturnMap = new LinkedHashMap();
042:
043: private CompositeComparator orderingComp = new CompositeComparator();
044:
045: private int classes;
046:
047: private int maxResults;
048:
049: private int firstResult;
050:
051: static final QueryType QUERY_ID = QueryType.PARSED_QUERY;
052:
053: public Class getClassName() {
054: return className;
055: }
056:
057: public void setClassName(Class className) {
058: this .className = className;
059: }
060:
061: public Map getAliasMap() {
062: return aliasMap;
063: }
064:
065: public void setAliasMap(Map aliasMap) {
066: this .aliasMap = aliasMap;
067: }
068:
069: /**
070: * @return Returns the predicates.
071: */
072: public synchronized Stack getPredicates() {
073: return predicates;
074: }
075:
076: /**
077: * @param predicates The predicates to set.
078: */
079: public synchronized void setPredicates(Stack predicates) {
080: this .predicates = predicates;
081: }
082:
083: public int getClasses() {
084: return classes;
085: }
086:
087: public void setClasses(int classes) {
088: this .classes = classes;
089: }
090:
091: public Object getNameSpace() {
092: return nameSpace;
093: }
094:
095: public void setNameSpace(Object nameSpace) {
096: this .nameSpace = nameSpace;
097:
098: }
099:
100: public QueryType getQueryType() {
101: // TODO Auto-generated method stub
102: return QUERY_ID;
103: }
104:
105: /**
106: * @return Returns the fieldReturnMap.
107: */
108: public Map getResultFieldsMap() {
109: return fieldReturnMap;
110: }
111:
112: /**
113: * @param fieldReturnMap The fieldReturnMap to set.
114: */
115: public void setResultFieldsMap(Map fieldReturnMap) {
116: this .fieldReturnMap = fieldReturnMap;
117: }
118:
119: public Map getFieldReturnMap() {
120: return fieldReturnMap;
121: }
122:
123: public void setFieldReturnMap(Map fieldReturnMap) {
124: this .fieldReturnMap = fieldReturnMap;
125: }
126:
127: public Map getNamedValueMap() {
128: return namedValueMap;
129: }
130:
131: public void setNamedValueMap(Map namedValueMap) {
132: this .namedValueMap = namedValueMap;
133: }
134:
135: /* (non-Javadoc)
136: * @see com.jofti.api.IndexQuery#setParameter(java.lang.String, java.lang.Object)
137: */
138: public IndexQuery setParameter(String name, Object value) {
139: namedValueMap.put(name, value);
140: return this ;
141: }
142:
143: /* (non-Javadoc)
144: * @see com.jofti.api.IndexQuery#setParameter(int, java.lang.Object)
145: */
146: public IndexQuery setParameter(int position, Object value) {
147: namedValueMap.put("" + position, value);
148: return this ;
149: }
150:
151: public CompositeComparator getOrderingComparator() {
152: return orderingComp;
153: }
154:
155: public void setOrderingComparator(CompositeComparator orderingComp) {
156: this .orderingComp = orderingComp;
157: }
158:
159: public IndexQuery setMaxResults(int maxResults) {
160: this .maxResults = maxResults;
161: return this ;
162: }
163:
164: public IndexQuery setFirstResult(int firstResult) {
165: this .firstResult = firstResult;
166: return this ;
167: }
168:
169: public int getFirstResult() {
170: return firstResult;
171: }
172:
173: public int getMaxResults() {
174: return maxResults;
175: }
176: }
|