/jboss-as-7.1.1.Final/cmp/src/main/java/org/jboss/as/cmp/jdbc/metadata/JDBCAutomaticQueryMetaData.java
Java | 127 lines | 41 code | 14 blank | 72 comment | 1 complexity | 206b532ae73d1b336380ef212f490c14 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
1/*
2 * JBoss, Home of Professional Open Source.
3 * Copyright 2008, Red Hat Middleware LLC, and individual contributors
4 * as indicated by the @author tags. See the copyright.txt file in the
5 * distribution for a 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 */
22package org.jboss.as.cmp.jdbc.metadata;
23
24import java.lang.reflect.Method;
25
26/**
27 * This immutable class contains information about an automatically generated
28 * query. This class is a place holder used to make an automatically generated
29 * query look more like a user specified query. This class only contains a
30 * reference 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: 81030 $
35 */
36public final class JDBCAutomaticQueryMetaData implements JDBCQueryMetaData {
37 /**
38 * A reference to the method which invokes this query.
39 */
40 private final Method method;
41
42 /**
43 * Read ahead meta data.
44 */
45 private final JDBCReadAheadMetaData readAhead;
46
47 private final Class compiler;
48
49 private final boolean lazyResultSetLoading;
50
51 /**
52 * Constructs a JDBCAutomaticQueryMetaData which is invoked by the specified
53 * method.
54 *
55 * @param method the method which invokes this query
56 * @readAhead Read ahead meta data.
57 */
58 public JDBCAutomaticQueryMetaData(Method method, JDBCReadAheadMetaData readAhead, Class qlCompiler, boolean lazyResultSetLoading) {
59 this.method = method;
60 this.readAhead = readAhead;
61 this.compiler = qlCompiler;
62 this.lazyResultSetLoading = lazyResultSetLoading;
63 }
64
65 public Method getMethod() {
66 return method;
67 }
68
69 public boolean isResultTypeMappingLocal() {
70 return false;
71 }
72
73 /**
74 * Gets the read ahead metadata for the query.
75 *
76 * @return the read ahead metadata for the query.
77 */
78 public JDBCReadAheadMetaData getReadAhead() {
79 return readAhead;
80 }
81
82 public Class getQLCompilerClass() {
83 return compiler;
84 }
85
86 public boolean isLazyResultSetLoading() {
87 return lazyResultSetLoading;
88 }
89
90 /**
91 * Compares this JDBCAutomaticQueryMetaData against the specified object. Returns
92 * true if the objects are the same. Two JDBCAutomaticQueryMetaData are the same
93 * if they are both invoked by the same method.
94 *
95 * @param o the reference object with which to compare
96 * @return true if this object is the same as the object argument; false otherwise
97 */
98 public boolean equals(Object o) {
99 if (o instanceof JDBCAutomaticQueryMetaData) {
100 return ((JDBCAutomaticQueryMetaData) o).method.equals(method);
101 }
102 return false;
103 }
104
105 /**
106 * Returns a hashcode for this JDBCAutomaticQueryMetaData. The hashcode is computed
107 * by the method which invokes this query.
108 *
109 * @return a hash code value for this object
110 */
111 public int hashCode() {
112 return method.hashCode();
113 }
114
115 /**
116 * Returns a string describing this JDBCAutomaticQueryMetaData. The exact details
117 * of the representation are unspecified and subject to change, but the following
118 * may be regarded as typical:
119 * <p/>
120 * "[JDBCAutomaticQueryMetaData: method=public org.foo.User findByName(java.lang.String)]"
121 *
122 * @return a string representation of the object
123 */
124 public String toString() {
125 return "[JDBCAutomaticQueryMetaData : method=" + method + "]";
126 }
127}