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.configuration2.builder;
18  
19  import javax.sql.DataSource;
20  
21  /**
22   * <p>
23   * A specialized parameters object for database configurations.
24   * </p>
25   * <p>
26   * This class has properties for defining the database structures the configuration operates on.
27   * </p>
28   * <p>
29   * This class is not thread-safe. It is intended that an instance is constructed and initialized by a single thread
30   * during configuration of a {@code ConfigurationBuilder}.
31   * </p>
32   *
33   * @since 2.0
34   */
35  public class DatabaseBuilderParametersImpl extends BasicBuilderParameters implements DatabaseBuilderProperties<DatabaseBuilderParametersImpl> {
36      /** Constant for the data source property. */
37      private static final String PROP_DATA_SOURCE = "dataSource";
38  
39      /** Constant for the table property. */
40      private static final String PROP_TABLE = "table";
41  
42      /** Constant for the key column property. */
43      private static final String PROP_KEY_COLUMN = "keyColumn";
44  
45      /** Constant for the value column property. */
46      private static final String PROP_VALUE_COLUMN = "valueColumn";
47  
48      /** Constant for the configuration name column property. */
49      private static final String PROP_CONFIG_NAME_COLUMN = "configurationNameColumn";
50  
51      /** Constant for the configuration name property. */
52      private static final String PROP_CONFIG_NAME = "configurationName";
53  
54      /** Constant for the auto commit property. */
55      private static final String PROP_AUTO_COMMIT = "autoCommit";
56  
57      @Override
58      public DatabaseBuilderParametersImpl setDataSource(final DataSource src) {
59          storeProperty(PROP_DATA_SOURCE, src);
60          return this;
61      }
62  
63      @Override
64      public DatabaseBuilderParametersImpl setTable(final String tableName) {
65          storeProperty(PROP_TABLE, tableName);
66          return this;
67      }
68  
69      @Override
70      public DatabaseBuilderParametersImpl setKeyColumn(final String name) {
71          storeProperty(PROP_KEY_COLUMN, name);
72          return this;
73      }
74  
75      @Override
76      public DatabaseBuilderParametersImpl setValueColumn(final String name) {
77          storeProperty(PROP_VALUE_COLUMN, name);
78          return this;
79      }
80  
81      @Override
82      public DatabaseBuilderParametersImpl setConfigurationNameColumn(final String name) {
83          storeProperty(PROP_CONFIG_NAME_COLUMN, name);
84          return this;
85      }
86  
87      @Override
88      public DatabaseBuilderParametersImpl setConfigurationName(final String name) {
89          storeProperty(PROP_CONFIG_NAME, name);
90          return this;
91      }
92  
93      @Override
94      public DatabaseBuilderParametersImpl setAutoCommit(final boolean f) {
95          storeProperty(PROP_AUTO_COMMIT, Boolean.valueOf(f));
96          return this;
97      }
98  }