PageRenderTime 51ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/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. */
  22. package org.jboss.as.cmp.jdbc.metadata;
  23. import java.lang.reflect.Method;
  24. /**
  25. * This immutable class contains information about an automatically generated
  26. * query. This class is a place holder used to make an automatically generated
  27. * query look more like a user specified query. This class only contains a
  28. * reference to the method used to invoke this query.
  29. *
  30. * @author <a href="mailto:dain@daingroup.com">Dain Sundstrom</a>
  31. * @author <a href="sebastien.alborini@m4x.org">Sebastien Alborini</a>
  32. * @version $Revision: 81030 $
  33. */
  34. public final class JDBCAutomaticQueryMetaData implements JDBCQueryMetaData {
  35. /**
  36. * A reference to the method which invokes this query.
  37. */
  38. private final Method method;
  39. /**
  40. * Read ahead meta data.
  41. */
  42. private final JDBCReadAheadMetaData readAhead;
  43. private final Class compiler;
  44. private final boolean lazyResultSetLoading;
  45. /**
  46. * Constructs a JDBCAutomaticQueryMetaData which is invoked by the specified
  47. * method.
  48. *
  49. * @param method the method which invokes this query
  50. * @readAhead Read ahead meta data.
  51. */
  52. public JDBCAutomaticQueryMetaData(Method method, JDBCReadAheadMetaData readAhead, Class qlCompiler, boolean lazyResultSetLoading) {
  53. this.method = method;
  54. this.readAhead = readAhead;
  55. this.compiler = qlCompiler;
  56. this.lazyResultSetLoading = lazyResultSetLoading;
  57. }
  58. public Method getMethod() {
  59. return method;
  60. }
  61. public boolean isResultTypeMappingLocal() {
  62. return false;
  63. }
  64. /**
  65. * Gets the read ahead metadata for the query.
  66. *
  67. * @return the read ahead metadata for the query.
  68. */
  69. public JDBCReadAheadMetaData getReadAhead() {
  70. return readAhead;
  71. }
  72. public Class getQLCompilerClass() {
  73. return compiler;
  74. }
  75. public boolean isLazyResultSetLoading() {
  76. return lazyResultSetLoading;
  77. }
  78. /**
  79. * Compares this JDBCAutomaticQueryMetaData against the specified object. Returns
  80. * true if the objects are the same. Two JDBCAutomaticQueryMetaData are the same
  81. * if they are both invoked by the same method.
  82. *
  83. * @param o the reference object with which to compare
  84. * @return true if this object is the same as the object argument; false otherwise
  85. */
  86. public boolean equals(Object o) {
  87. if (o instanceof JDBCAutomaticQueryMetaData) {
  88. return ((JDBCAutomaticQueryMetaData) o).method.equals(method);
  89. }
  90. return false;
  91. }
  92. /**
  93. * Returns a hashcode for this JDBCAutomaticQueryMetaData. The hashcode is computed
  94. * by the method which invokes this query.
  95. *
  96. * @return a hash code value for this object
  97. */
  98. public int hashCode() {
  99. return method.hashCode();
  100. }
  101. /**
  102. * Returns a string describing this JDBCAutomaticQueryMetaData. The exact details
  103. * of the representation are unspecified and subject to change, but the following
  104. * may be regarded as typical:
  105. * <p/>
  106. * "[JDBCAutomaticQueryMetaData: method=public org.foo.User findByName(java.lang.String)]"
  107. *
  108. * @return a string representation of the object
  109. */
  110. public String toString() {
  111. return "[JDBCAutomaticQueryMetaData : method=" + method + "]";
  112. }
  113. }