KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Imutable class which holds information about a raw sql query.
28  * A raw sql query allows you to do anything sql allows you to do.
29  *
30  * @author <a HREF="mailto:dain@daingroup.com">Dain Sundstrom</a>
31  * @version $Revision: 37459 $
32  */

33 public final class JDBCRawSqlQueryMetaData implements JDBCQueryMetaData
34 {
35    private final Method JavaDoc method;
36
37    private final Class JavaDoc compiler;
38
39    private final boolean lazyResultSetLoading;
40
41    /**
42     * Constructs a JDBCRawSqlQueryMetaData which is invoked by the specified
43     * method.
44     *
45     * @param method the method which invokes this query
46     */

47    public JDBCRawSqlQueryMetaData(Method JavaDoc method, Class JavaDoc qlCompiler, boolean lazyResultSetLoading)
48    {
49       this.method = method;
50       this.compiler = qlCompiler;
51       this.lazyResultSetLoading = lazyResultSetLoading;
52    }
53
54    public Method JavaDoc getMethod()
55    {
56       return method;
57    }
58
59    public boolean isResultTypeMappingLocal()
60    {
61       return false;
62    }
63
64    public Class JavaDoc getQLCompilerClass()
65    {
66       return compiler;
67    }
68
69    /**
70     * Gets the read ahead metadata for the query.
71     *
72     * @return the read ahead metadata for the query.
73     */

74    public JDBCReadAheadMetaData getReadAhead()
75    {
76       return JDBCReadAheadMetaData.DEFAULT;
77    }
78
79    public boolean isLazyResultSetLoading()
80    {
81       return lazyResultSetLoading;
82    }
83
84    /**
85     * Compares this JDBCRawSqlQueryMetaData against the specified object. Returns
86     * true if the objects are the same. Two JDBCRawSqlQueryMetaData are the same
87     * if they are both invoked by the same method.
88     *
89     * @param o the reference object with which to compare
90     * @return true if this object is the same as the object argument; false otherwise
91     */

92    public boolean equals(Object JavaDoc o)
93    {
94       if(o instanceof JDBCRawSqlQueryMetaData)
95       {
96          return ((JDBCRawSqlQueryMetaData) o).method.equals(method);
97       }
98       return false;
99    }
100
101    /**
102     * Returns a hashcode for this JDBCRawSqlQueryMetaData. The hashcode is computed
103     * by the method which invokes this query.
104     *
105     * @return a hash code value for this object
106     */

107    public int hashCode()
108    {
109       return method.hashCode();
110    }
111
112    /**
113     * Returns a string describing this JDBCRawSqlQueryMetaData. The exact details
114     * of the representation are unspecified and subject to change, but the following
115     * may be regarded as typical:
116     * <p/>
117     * "[JDBCRawSqlQueryMetaData: method=public org.foo.User findByName(java.lang.String)]"
118     *
119     * @return a string representation of the object
120     */

121    public String JavaDoc toString()
122    {
123       return "[JDBCRawSqlQueryMetaData : method=" + method + "]";
124    }
125 }
126
Popular Tags