View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.dbutils;
18  
19  import java.sql.Timestamp;
20  
21  /**
22   * A bean to use in testing toBean() and toBeanList().
23   */
24  public class TestBean {
25  
26      public enum Ordinal {
27  
28          THREE, SIX;
29  
30      };
31  
32      private String one = null;
33  
34      private String two = null;
35  
36      private Ordinal three = null;
37  
38      private int intTest = 0;
39  
40      private Integer integerTest = Integer.valueOf(0);
41  
42      private Timestamp timestamp = null;
43  
44      private String doNotSet = "not set";
45  
46      /**
47       * toBean() should set primitive fields to their defaults (ie. 0) when
48       * null is returned from the ResultSet.
49       */
50      private int nullPrimitiveTest = 7;
51  
52      /**
53       * toBean() should set Object fields to null when null is returned from the
54       * ResultSet
55       */
56      private Object nullObjectTest = "overwrite";
57  
58      /**
59       * A Date will be returned from the ResultSet but the property is a String.
60       * BeanProcessor should create a String from the Date and set this property.
61       */
62      private String notDate = "not a date";
63  
64      /**
65       * The ResultSet will have a BigDecimal in this column and the
66       * BasicColumnProcessor should convert that to a double and store the value
67       * in this property.
68       */
69      private double columnProcessorDoubleTest = -1;
70  
71      /**
72       * Constructor for TestBean.
73       */
74      public TestBean() {
75          super();
76      }
77  
78      public String getOne() {
79          return one;
80      }
81  
82      public Ordinal getThree() {
83          return three;
84      }
85  
86      public String getTwo() {
87          return two;
88      }
89  
90      public void setOne(String string) {
91          one = string;
92      }
93  
94      public void setThree(Ordinal ordinal) {
95          three = ordinal;
96      }
97  
98      public void setTwo(String string) {
99          two = string;
100     }
101 
102     public String getDoNotSet() {
103         return doNotSet;
104     }
105 
106     public void setDoNotSet(String string) {
107         doNotSet = string;
108     }
109 
110     public Integer getIntegerTest() {
111         return integerTest;
112     }
113 
114     public int getIntTest() {
115         return intTest;
116     }
117 
118     public void setIntegerTest(Integer integer) {
119         integerTest = integer;
120     }
121 
122     public void setIntTest(int i) {
123         intTest = i;
124     }
125 
126     public Object getNullObjectTest() {
127         return nullObjectTest;
128     }
129 
130     public int getNullPrimitiveTest() {
131         return nullPrimitiveTest;
132     }
133 
134     public void setNullObjectTest(Object object) {
135         nullObjectTest = object;
136     }
137 
138     public void setNullPrimitiveTest(int i) {
139         nullPrimitiveTest = i;
140     }
141 
142     public String getNotDate() {
143         return notDate;
144     }
145 
146     public void setNotDate(String string) {
147         notDate = string;
148     }
149 
150     public double getColumnProcessorDoubleTest() {
151         return columnProcessorDoubleTest;
152     }
153 
154     public void setColumnProcessorDoubleTest(double d) {
155         columnProcessorDoubleTest = d;
156     }
157 
158 }