KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > storagemanager > logging > SmQueryEvent


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.storagemanager.logging;
13
14 import com.versant.core.jdo.QueryDetails;
15 import com.versant.core.metadata.ModelMetaData;
16 import com.versant.core.metadata.ClassMetaData;
17 import com.versant.core.server.CompiledQuery;
18
19 /**
20  * An event logged for compiling and executing a query.
21  */

22 public class SmQueryEvent extends SmStatesReturnedEvent {
23
24     private String JavaDoc language;
25     private String JavaDoc candidateClass;
26     private String JavaDoc filter;
27     private String JavaDoc imports;
28     private String JavaDoc variables;
29     private String JavaDoc ordering;
30     private boolean ignoreCache;
31     private String JavaDoc params;
32
33     private String JavaDoc fetchGroup;
34     private boolean randomAccess;
35     private boolean countStarOnSize;
36     private boolean bounded;
37
38     private String JavaDoc compiledQuery;
39     private int count;
40     private int skipAmount;
41     private int index;
42     private int fetchAmount;
43
44     public SmQueryEvent(int storageManagerId, int type, QueryDetails q,
45             CompiledQuery cq, ModelMetaData jmd) {
46         super(storageManagerId, type);
47         if (q == null && cq != null) {
48             q = cq.getQueryDetails();
49         }
50         if (q != null) {
51             language = q.getLanguageStr();
52             final Class JavaDoc c = q.getCandidateClass();
53             candidateClass = c == null ? null : c.getName();
54             filter = q.getFilter();
55             imports = q.getImports();
56             variables = q.getVariables();
57             ordering = q.getOrdering();
58             ignoreCache = q.isIgnoreCache();
59             int fgi = q.getFetchGroupIndex();
60             if (c != null && fgi >= 0) {
61                 ClassMetaData cmd = jmd.getClassMetaData(c);
62                 fetchGroup = cmd.fetchGroups[fgi].name;
63             }
64             randomAccess = q.isRandomAccess();
65             countStarOnSize = q.isCountOnSize();
66             bounded = q.isBounded();
67         }
68         if (cq != null) {
69             compiledQuery = cq.toString();
70         }
71     }
72
73     /**
74      * Get a long description for this event (e.g. the query text).
75      */

76     public String JavaDoc getDescription() {
77         StringBuffer JavaDoc s = new StringBuffer JavaDoc();
78         s.append(language);
79         if (candidateClass != null) {
80             s.append(' ');
81             s.append(candidateClass);
82         }
83         if (filter != null) {
84             s.append(' ');
85             s.append(filter);
86         }
87         return s.toString();
88     }
89
90     public String JavaDoc getLanguage() {
91         return language;
92     }
93
94     public String JavaDoc getCandidateClass() {
95         return candidateClass;
96     }
97
98     public String JavaDoc getFilter() {
99         return filter;
100     }
101
102     public String JavaDoc getImports() {
103         return imports;
104     }
105
106     public String JavaDoc getVariables() {
107         return variables;
108     }
109
110     public String JavaDoc getOrdering() {
111         return ordering;
112     }
113
114     public boolean isIgnoreCache() {
115         return ignoreCache;
116     }
117
118     public String JavaDoc getParams() {
119         return params;
120     }
121
122     public String JavaDoc getFetchGroup() {
123         return fetchGroup;
124     }
125
126     public boolean getRandomAccess() {
127         return randomAccess;
128     }
129
130     public boolean getCountStarOnSize() {
131         return countStarOnSize;
132     }
133
134     public int getCount() {
135         return count;
136     }
137
138     public void setCount(int count) {
139         this.count = count;
140     }
141
142     public void setFilter(String JavaDoc filter) {
143         this.filter = filter;
144     }
145
146     public void setImports(String JavaDoc imports) {
147         this.imports = imports;
148     }
149
150     public void setVariables(String JavaDoc variables) {
151         this.variables = variables;
152     }
153
154     public void setOrdering(String JavaDoc ordering) {
155         this.ordering = ordering;
156     }
157
158     public void setParams(String JavaDoc params) {
159         this.params = params;
160     }
161
162     public void setFetchGroup(String JavaDoc fetchGroup) {
163         this.fetchGroup = fetchGroup;
164     }
165
166     public void setCandidateClass(String JavaDoc candidateClass) {
167         this.candidateClass = candidateClass;
168     }
169
170     public boolean isBounded() {
171         return bounded;
172     }
173
174     public void setBounded(boolean bounded) {
175         this.bounded = bounded;
176     }
177
178     public String JavaDoc getCompiledQuery() {
179         return compiledQuery;
180     }
181
182     public int getSkipAmount() {
183         return skipAmount;
184     }
185
186     public void setSkipAmount(int skipAmount) {
187         this.skipAmount = skipAmount;
188     }
189
190     public int getIndex() {
191         return index;
192     }
193
194     public void setIndex(int index) {
195         this.index = index;
196     }
197
198     public int getFetchAmount() {
199         return fetchAmount;
200     }
201
202     public void setFetchAmount(int fetchAmount) {
203         this.fetchAmount = fetchAmount;
204     }
205
206 }
207
Popular Tags