KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb > plugins > cmp > jdbc > metadata > JDBCAutomaticQueryMetaData


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.ejb.plugins.cmp.jdbc.metadata;
23
24 import java.lang.reflect.Method JavaDoc;
25
26 /**
27  * This immutable class contains information about an automatically generated
28  * query. This class is a place holder used to make an automaticlly generated
29  * query look more like a user specified query. This class only contains a
30  * referance to the method used to invoke this query.
31  *
32  * @author <a HREF="mailto:dain@daingroup.com">Dain Sundstrom</a>
33  * @author <a HREF="sebastien.alborini@m4x.org">Sebastien Alborini</a>
34  * @version $Revision: 37459 $
35  */

36 public final class JDBCAutomaticQueryMetaData implements JDBCQueryMetaData
37 {
38    /**
39     * A referance to the method which invokes this query.
40     */

41    private final Method JavaDoc method;
42
43    /**
44     * Read ahead meta data.
45     */

46    private final JDBCReadAheadMetaData readAhead;
47
48    private final Class JavaDoc compiler;
49
50    private final boolean lazyResultSetLoading;
51
52    /**
53     * Constructs a JDBCAutomaticQueryMetaData which is invoked by the specified
54     * method.
55     *
56     * @param method the method which invokes this query
57     * @readAhead Read ahead meta data.
58     */

59    public JDBCAutomaticQueryMetaData(Method JavaDoc method, JDBCReadAheadMetaData readAhead, Class JavaDoc qlCompiler, boolean lazyResultSetLoading)
60    {
61       this.method = method;
62       this.readAhead = readAhead;
63       this.compiler = qlCompiler;
64       this.lazyResultSetLoading = lazyResultSetLoading;
65    }
66
67    public Method JavaDoc getMethod()
68    {
69       return method;
70    }
71
72    public boolean isResultTypeMappingLocal()
73    {
74       return false;
75    }
76
77    /**
78     * Gets the read ahead metadata for the query.
79     *
80     * @return the read ahead metadata for the query.
81     */

82    public JDBCReadAheadMetaData getReadAhead()
83    {
84       return readAhead;
85    }
86
87    public Class JavaDoc getQLCompilerClass()
88    {
89       return compiler;
90    }
91
92    public boolean isLazyResultSetLoading()
93    {
94       return lazyResultSetLoading;
95    }
96
97    /**
98     * Compares this JDBCAutomaticQueryMetaData against the specified object. Returns
99     * true if the objects are the same. Two JDBCAutomaticQueryMetaData are the same
100     * if they are both invoked by the same method.
101     *
102     * @param o the reference object with which to compare
103     * @return true if this object is the same as the object argument; false otherwise
104     */

105    public boolean equals(Object JavaDoc o)
106    {
107       if(o instanceof JDBCAutomaticQueryMetaData)
108       {
109          return ((JDBCAutomaticQueryMetaData) o).method.equals(method);
110       }
111       return false;
112    }
113
114    /**
115     * Returns a hashcode for this JDBCAutomaticQueryMetaData. The hashcode is computed
116     * by the method which invokes this query.
117     *
118     * @return a hash code value for this object
119     */

120    public int hashCode()
121    {
122       return method.hashCode();
123    }
124
125    /**
126     * Returns a string describing this JDBCAutomaticQueryMetaData. The exact details
127     * of the representation are unspecified and subject to change, but the following
128     * may be regarded as typical:
129     * <p/>
130     * "[JDBCAutomaticQueryMetaData: method=public org.foo.User findByName(java.lang.String)]"
131     *
132     * @return a string representation of the object
133     */

134    public String JavaDoc toString()
135    {
136       return "[JDBCAutomaticQueryMetaData : method=" + method + "]";
137    }
138 }
139
Popular Tags