001: /*
002: * Created on 16-Jan-2006
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.HashMap;
010: import java.util.List;
011: import java.util.Map;
012: import java.util.Stack;
013:
014: import com.jofti.api.IndexQuery;
015: import com.jofti.core.INameSpaceAware;
016: import com.jofti.core.IParsedQuery;
017: import com.jofti.core.QueryId;
018: import com.jofti.core.QueryType;
019: import com.jofti.util.CompositeComparator;
020:
021: /**
022: * @author xenephon
023: *
024: * TODO To change the template for this generated type comment go to
025: * Window - Preferences - Java - Code Style - Code Templates
026: */
027: public class ParsedQueryWrapper implements IParsedQuery, IndexQuery,
028: INameSpaceAware, QueryId {
029:
030: private ParsedQuery parsedQuery;
031: private Map nameValueMap;
032: private Object nameSpace;
033: int firstResult = 0;
034: int maxResults = 0;
035:
036: /**
037: *
038: */
039: public ParsedQueryWrapper(ParsedQuery parsedQuery) {
040: this .parsedQuery = parsedQuery;
041:
042: }
043:
044: /* (non-Javadoc)
045: * @see com.jofti.core.IParsedQuery#getClassName()
046: */
047: public Class getClassName() {
048:
049: return parsedQuery.getClassName();
050: }
051:
052: /* (non-Javadoc)
053: * @see com.jofti.core.IParsedQuery#getAliasMap()
054: */
055: public Map getAliasMap() {
056:
057: return parsedQuery.getAliasMap();
058: }
059:
060: /* (non-Javadoc)
061: * @see com.jofti.core.IParsedQuery#getPredicates()
062: */
063: public Stack getPredicates() {
064:
065: return parsedQuery.getPredicates();
066: }
067:
068: /* (non-Javadoc)
069: * @see com.jofti.core.IParsedQuery#getResultFieldsMap()
070: */
071: public Map getResultFieldsMap() {
072:
073: return parsedQuery.getResultFieldsMap();
074: }
075:
076: /* (non-Javadoc)
077: * @see com.jofti.core.IParsedQuery#getNamedValueMap()
078: */
079: public Map getNamedValueMap() {
080:
081: return nameValueMap;
082: }
083:
084: public void setNamedValueMap(Map map) {
085:
086: this .nameValueMap = map;
087: }
088:
089: /* (non-Javadoc)
090: * @see com.jofti.core.IParsedQuery#getNameSpace()
091: */
092: public Object getNameSpace() {
093: if (nameSpace == null) {
094: return parsedQuery.getNameSpace();
095: }
096: return nameSpace;
097: }
098:
099: /* (non-Javadoc)
100: * @see com.jofti.core.INameSpaceAware#setNameSpace(java.lang.Object)
101: */
102: public void setNameSpace(Object nameSpace) {
103: this .nameSpace = nameSpace;
104:
105: }
106:
107: /* (non-Javadoc)
108: * @see com.jofti.core.QueryId#getQueryType()
109: */
110: public QueryType getQueryType() {
111:
112: return parsedQuery.getQueryType();
113: }
114:
115: /* (non-Javadoc)
116: * @see com.jofti.api.IndexQuery#setParameter(java.lang.String, java.lang.Object)
117: */
118: public IndexQuery setParameter(String name, Object value) {
119: if (nameValueMap == null) {
120: nameValueMap = new HashMap();
121: }
122: nameValueMap.put(name, value);
123: return this ;
124: }
125:
126: /* (non-Javadoc)
127: * @see com.jofti.api.IndexQuery#setParameter(int, java.lang.Object)
128: */
129: public IndexQuery setParameter(int position, Object value) {
130:
131: if (nameValueMap == null) {
132: nameValueMap = new HashMap();
133: }
134: nameValueMap.put("" + position, value);
135: return this ;
136:
137: }
138:
139: public CompositeComparator getOrderingComparator() {
140: return parsedQuery.getOrderingComparator();
141: }
142:
143: public void setOrderingComparator(CompositeComparator comparator) {
144: parsedQuery.setOrderingComparator(comparator);
145: }
146:
147: public IndexQuery setFirstResult(int firstResult) {
148:
149: this .firstResult = firstResult;
150: return this ;
151: }
152:
153: public int getFirstResult() {
154:
155: return firstResult;
156: }
157:
158: public IndexQuery setMaxResults(int maxResults) {
159:
160: this .maxResults = maxResults;
161: return this ;
162: }
163:
164: public int getMaxResults() {
165:
166: return maxResults;
167: }
168:
169: }
|