    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *     http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.configuration2.builder;
    018
    019import javax.sql.DataSource;
    020
    021/**
    022 * <p>
    023 * A specialized parameters object for database configurations.
    024 * </p>
    025 * <p>
    026 * This class has properties for defining the database structures the
    027 * configuration operates on.
    028 * </p>
    029 * <p>
    030 * This class is not thread-safe. It is intended that an instance is constructed
    031 * and initialized by a single thread during configuration of a
    032 * {@code ConfigurationBuilder}.
    033 * </p>
    034 *
    035 * @since 2.0
    036 */
    037public class DatabaseBuilderParametersImpl extends BasicBuilderParameters
    038        implements DatabaseBuilderProperties<DatabaseBuilderParametersImpl>
    039{
    040    /** Constant for the data source property. */
    041    private static final String PROP_DATA_SOURCE = "dataSource";
    042
    043    /** Constant for the table property. */
    044    private static final String PROP_TABLE = "table";
    045
    046    /** Constant for the key column property. */
    047    private static final String PROP_KEY_COLUMN = "keyColumn";
    048
    049    /** Constant for the value column property. */
    050    private static final String PROP_VALUE_COLUMN = "valueColumn";
    051
    052    /** Constant for the configuration name column property. */
    053    private static final String PROP_CONFIG_NAME_COLUMN =
    054            "configurationNameColumn";
    055
    056    /** Constant for the configuration name property. */
    057    private static final String PROP_CONFIG_NAME = "configurationName";
    058
    059    /** Constant for the auto commit property. */
    060    private static final String PROP_AUTO_COMMIT = "autoCommit";
    061
    062    @Override
    063    public DatabaseBuilderParametersImpl setDataSource(final DataSource src)
    064    {
    065        storeProperty(PROP_DATA_SOURCE, src);
    066        return this;
    067    }
    068
    069    @Override
    070    public DatabaseBuilderParametersImpl setTable(final String tname)
    071    {
    072        storeProperty(PROP_TABLE, tname);
    073        return this;
    074    }
    075
    076    @Override
    077    public DatabaseBuilderParametersImpl setKeyColumn(final String name)
    078    {
    079        storeProperty(PROP_KEY_COLUMN, name);
    080        return this;
    081    }
    082
    083    @Override
    084    public DatabaseBuilderParametersImpl setValueColumn(final String name)
    085    {
    086        storeProperty(PROP_VALUE_COLUMN, name);
    087        return this;
    088    }
    089
    090    @Override
    091    public DatabaseBuilderParametersImpl setConfigurationNameColumn(final String name)
    092    {
    093        storeProperty(PROP_CONFIG_NAME_COLUMN, name);
    094        return this;
    095    }
    096
    097    @Override
    098    public DatabaseBuilderParametersImpl setConfigurationName(final String name)
    099    {
    100        storeProperty(PROP_CONFIG_NAME, name);
    101        return this;
    102    }
    103
    104    @Override
    105    public DatabaseBuilderParametersImpl setAutoCommit(final boolean f)
    106    {
    107        storeProperty(PROP_AUTO_COMMIT, Boolean.valueOf(f));
    108        return this;
    109    }
    110}