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  /**
20   * A bean to use in testing toBean() and toBeanList().
21   */
22  public class TestBean {
23  
24      public enum Ordinal {
25  
26          THREE, SIX;
27  
28      }
29  
30      private String one = null;
31  
32      private String two = null;
33  
34      private Ordinal three = null;
35  
36      private int intTest = 0;
37  
38      private Integer integerTest = Integer.valueOf(0);
39  
40      // UNUSED private Timestamp timestamp = null;
41  
42      private String doNotSet = "not set";
43  
44      /**
45       * toBean() should set primitive fields to their defaults (ie. 0) when
46       * null is returned from the ResultSet.
47       */
48      private int nullPrimitiveTest = 7;
49  
50      /**
51       * toBean() should set Object fields to null when null is returned from the
52       * ResultSet
53       */
54      private Object nullObjectTest = "overwrite";
55  
56      /**
57       * A Date will be returned from the ResultSet but the property is a String.
58       * BeanProcessor should create a String from the Date and set this property.
59       */
60      private String notDate = "not a date";
61  
62      /**
63       * The ResultSet will have a BigDecimal in this column and the
64       * BasicColumnProcessor should convert that to a double and store the value
65       * in this property.
66       */
67      private double columnProcessorDoubleTest = -1;
68  
69      /**
70       * Constructor for TestBean.
71       */
72      public TestBean() {
73      }
74  
75      public double getColumnProcessorDoubleTest() {
76          return columnProcessorDoubleTest;
77      }
78  
79      public String getDoNotSet() {
80          return doNotSet;
81      }
82  
83      public Integer getIntegerTest() {
84          return integerTest;
85      }
86  
87      public int getIntTest() {
88          return intTest;
89      }
90  
91      public String getNotDate() {
92          return notDate;
93      }
94  
95      public Object getNullObjectTest() {
96          return nullObjectTest;
97      }
98  
99      public int getNullPrimitiveTest() {
100         return nullPrimitiveTest;
101     }
102 
103     public String getOne() {
104         return one;
105     }
106 
107     public Ordinal getThree() {
108         return three;
109     }
110 
111     public String getTwo() {
112         return two;
113     }
114 
115     public void setColumnProcessorDoubleTest(final double d) {
116         columnProcessorDoubleTest = d;
117     }
118 
119     public void setDoNotSet(final String string) {
120         doNotSet = string;
121     }
122 
123     public void setIntegerTest(final Integer integer) {
124         integerTest = integer;
125     }
126 
127     public void setIntTest(final int i) {
128         intTest = i;
129     }
130 
131     public void setNotDate(final String string) {
132         notDate = string;
133     }
134 
135     public void setNullObjectTest(final Object object) {
136         nullObjectTest = object;
137     }
138 
139     public void setNullPrimitiveTest(final int i) {
140         nullPrimitiveTest = i;
141     }
142 
143     public void setOne(final String string) {
144         one = string;
145     }
146 
147     public void setThree(final Ordinal ordinal) {
148         three = ordinal;
149     }
150 
151     public void setTwo(final String string) {
152         two = string;
153     }
154 
155 }