DatabaseBuilderParametersImpl.java

  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. import javax.sql.DataSource;

  19. /**
  20.  * <p>
  21.  * A specialized parameters object for database configurations.
  22.  * </p>
  23.  * <p>
  24.  * This class has properties for defining the database structures the configuration operates on.
  25.  * </p>
  26.  * <p>
  27.  * This class is not thread-safe. It is intended that an instance is constructed and initialized by a single thread
  28.  * during configuration of a {@code ConfigurationBuilder}.
  29.  * </p>
  30.  *
  31.  * @since 2.0
  32.  */
  33. public class DatabaseBuilderParametersImpl extends BasicBuilderParameters implements DatabaseBuilderProperties<DatabaseBuilderParametersImpl> {
  34.     /** Constant for the data source property. */
  35.     private static final String PROP_DATA_SOURCE = "dataSource";

  36.     /** Constant for the table property. */
  37.     private static final String PROP_TABLE = "table";

  38.     /** Constant for the key column property. */
  39.     private static final String PROP_KEY_COLUMN = "keyColumn";

  40.     /** Constant for the value column property. */
  41.     private static final String PROP_VALUE_COLUMN = "valueColumn";

  42.     /** Constant for the configuration name column property. */
  43.     private static final String PROP_CONFIG_NAME_COLUMN = "configurationNameColumn";

  44.     /** Constant for the configuration name property. */
  45.     private static final String PROP_CONFIG_NAME = "configurationName";

  46.     /** Constant for the auto commit property. */
  47.     private static final String PROP_AUTO_COMMIT = "autoCommit";

  48.     @Override
  49.     public DatabaseBuilderParametersImpl setAutoCommit(final boolean f) {
  50.         storeProperty(PROP_AUTO_COMMIT, Boolean.valueOf(f));
  51.         return this;
  52.     }

  53.     @Override
  54.     public DatabaseBuilderParametersImpl setConfigurationName(final String name) {
  55.         storeProperty(PROP_CONFIG_NAME, name);
  56.         return this;
  57.     }

  58.     @Override
  59.     public DatabaseBuilderParametersImpl setConfigurationNameColumn(final String name) {
  60.         storeProperty(PROP_CONFIG_NAME_COLUMN, name);
  61.         return this;
  62.     }

  63.     @Override
  64.     public DatabaseBuilderParametersImpl setDataSource(final DataSource src) {
  65.         storeProperty(PROP_DATA_SOURCE, src);
  66.         return this;
  67.     }

  68.     @Override
  69.     public DatabaseBuilderParametersImpl setKeyColumn(final String name) {
  70.         storeProperty(PROP_KEY_COLUMN, name);
  71.         return this;
  72.     }

  73.     @Override
  74.     public DatabaseBuilderParametersImpl setTable(final String tableName) {
  75.         storeProperty(PROP_TABLE, tableName);
  76.         return this;
  77.     }

  78.     @Override
  79.     public DatabaseBuilderParametersImpl setValueColumn(final String name) {
  80.         storeProperty(PROP_VALUE_COLUMN, name);
  81.         return this;
  82.     }
  83. }