View Javadoc

1   package org.apache.torque.templates.typemapping;
2   
3   
4   /*
5    * Licensed to the Apache Software Foundation (ASF) under one
6    * or more contributor license agreements.  See the NOTICE file
7    * distributed with this work for additional information
8    * regarding copyright ownership.  The ASF licenses this file
9    * to you under the Apache License, Version 2.0 (the
10   * "License"); you may not use this file except in compliance
11   * with the License.  You may obtain a copy of the License at
12   *
13   *   http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing,
16   * software distributed under the License is distributed on an
17   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18   * KIND, either express or implied.  See the License for the
19   * specific language governing permissions and limitations
20   * under the License.
21   */
22  
23  /**
24   * All available result set getter methods.
25   *
26   * $Id: ResultSetGetter.java 1331196 2012-04-27 02:56:12Z tfischer $
27   */
28  public enum ResultSetGetter
29  {
30      /** getArray Method. */
31      ARRAY("getArray"),
32      /** getAsciiStream Method. */
33      ASCII_STREAM("getAsciiStream"),
34      /** getBigDecimal Method. */
35      BIG_DECIMAL("getBigDecimal"),
36      /** getBinaryStream Method. */
37      BINARY_STREAM("getBinaryStream"),
38      /** getBlob Method. */
39      BLOB("getBlob"),
40      /** getBoolean Method. */
41      BOOLEAN("getBoolean"),
42      /** getByte Method. */
43      BYTE("getByte"),
44      /** getBytes Method. */
45      BYTES("getBytes"),
46      /** getCharacterStream Method. */
47      CHARACTER_STREAM("getCharacterStream"),
48      /** getClob Method. */
49      CLOB("getClob"),
50      /** getDate Method. */
51      DATE("getDate"),
52      /** getDouble Method. */
53      DOUBLE("getDouble"),
54      /** getFloat Method. */
55      FLOAT("getFloat"),
56      /** getInt Method. */
57      INT("getInt"),
58      /** getLong Method. */
59      LONG("getLong"),
60      /** getObject Method. */
61      OBJECT("getObject"),
62      /** getRef Method. */
63      REF("getRef"),
64      /** getShort Method. */
65      SHORT("getShort"),
66      /** getString Method. */
67      STRING("getString"),
68      /** getTime Method. */
69      TIME("getTime"),
70      /** getTimestamp Method. */
71      TIMESTAMP("getTimestamp"),
72      /** getUnicodeStream Method. */
73      UNICODE_STREAM("getUnicodeStream"),
74      /** getURL Method. */
75      URL("getURL");
76  
77      /** The method name. */
78      private String method;
79  
80      /**
81       * Constructor.
82       *
83       * @param method the method name, not null.
84       */
85      private ResultSetGetter(String method)
86      {
87          this.method = method;
88      }
89  
90      /**
91       * Returns the method name.
92       *
93       * @return the method name, not null.
94       */
95      public String getMethod()
96      {
97          return method;
98      }
99  
100     /**
101      * Returns the method name.
102      *
103      * @return the method name, not null.
104      */
105     public String toString()
106     {
107         return method;
108     }
109 
110     /**
111      * Retursn the ResultSetGetter with the given method name.
112      *
113      * @param methodName the method name.
114      *
115      * @return the matching ResultSetGetter, not null.
116      *
117      * @throws IllegalArgumentException if no matching ResultSetGetter
118      *         exists.
119      */
120     public static ResultSetGetter getByMethodName(String methodName)
121     {
122         for (ResultSetGetter resultSetGetter : values())
123         {
124             if (resultSetGetter.getMethod().equals(methodName))
125             {
126                 return resultSetGetter;
127             }
128         }
129         throw new IllegalArgumentException("Unknown value " + methodName);
130     }
131 }