001: /**
002: * Speedo: an implementation of JDO compliant personality on top of JORM generic
003: * I/O sub-system.
004: * Copyright (C) 2001-2006 France Telecom
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * Contact: speedo@objectweb.org
021: *
022: * Authors: S.Chassande-Barrioz.
023: */package org.objectweb.speedo.query.ejb;
024:
025: import org.objectweb.speedo.query.api.QueryDefinition;
026:
027: public class EJBQueryDefinitionImpl implements QueryDefinition {
028:
029: boolean withPrefetch;
030: String query;
031: long rangeFirst;
032: long rangeLast;
033: boolean fetchIdentifierOnly;
034: short queryType;
035:
036: public EJBQueryDefinitionImpl() {
037: defineWith(null);
038: }
039:
040: public EJBQueryDefinitionImpl(EJBQueryDefinitionImpl qd) {
041: defineWith(qd);
042: }
043:
044: public void defineWith(EJBQueryDefinitionImpl qd) {
045: if (qd == null) {
046: this .withPrefetch = true;
047: this .query = null;
048: this .rangeFirst = 0;
049: this .rangeLast = Long.MAX_VALUE;
050: } else {
051: this .withPrefetch = qd.withPrefetch;
052: this .query = qd.query;
053: this .rangeFirst = qd.rangeFirst;
054: this .rangeLast = qd.rangeLast;
055: }
056: }
057:
058: public boolean fetchIdentifierOnly() {
059: return fetchIdentifierOnly;
060: }
061:
062: public short getQueryType() {
063: return queryType;
064: }
065:
066: public boolean withPrefetch() {
067: return withPrefetch;
068: }
069:
070: public void withPrefetch(boolean withprefetch) {
071: this .withPrefetch = withprefetch;
072: }
073:
074: public long getIndexFirst() {
075: return rangeFirst;
076: }
077:
078: public long getIndexLast() {
079: return rangeLast;
080: }
081:
082: public String qdToString(boolean oneLine) {
083: StringBuffer sb = new StringBuffer();
084: String sep = "";
085: final String sepNext = (oneLine ? ", " : "\n\t-");
086: if (query != null) {
087: sb.append(sep).append("query=\"").append(query)
088: .append("\"");
089: sep = sepNext;
090: }
091: if (!withPrefetch) {
092: sb.append(sep).append("withPrefetch=\"").append(
093: withPrefetch).append("\"");
094: sep = sepNext;
095: }
096: if (rangeFirst != 0) {
097: sb.append(sep).append("range first=").append(rangeFirst);
098: sep = sepNext;
099: }
100: if (rangeLast != 0) {
101: sb.append(sep).append("range last=").append(rangeLast);
102: sep = sepNext;
103: }
104: return sb.toString();
105: }
106: }
|