    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 configuration operates on.
    027 * </p>
    028 * <p>
    029 * This class is not thread-safe. It is intended that an instance is constructed and initialized by a single thread
    030 * during configuration of a {@code ConfigurationBuilder}.
    031 * </p>
    032 *
    033 * @since 2.0
    034 */
    035public class DatabaseBuilderParametersImpl extends BasicBuilderParameters implements DatabaseBuilderProperties<DatabaseBuilderParametersImpl> {
    036    /** Constant for the data source property. */
    037    private static final String PROP_DATA_SOURCE = "dataSource";
    038
    039    /** Constant for the table property. */
    040    private static final String PROP_TABLE = "table";
    041
    042    /** Constant for the key column property. */
    043    private static final String PROP_KEY_COLUMN = "keyColumn";
    044
    045    /** Constant for the value column property. */
    046    private static final String PROP_VALUE_COLUMN = "valueColumn";
    047
    048    /** Constant for the configuration name column property. */
    049    private static final String PROP_CONFIG_NAME_COLUMN = "configurationNameColumn";
    050
    051    /** Constant for the configuration name property. */
    052    private static final String PROP_CONFIG_NAME = "configurationName";
    053
    054    /** Constant for the auto commit property. */
    055    private static final String PROP_AUTO_COMMIT = "autoCommit";
    056
    057    @Override
    058    public DatabaseBuilderParametersImpl setDataSource(final DataSource src) {
    059        storeProperty(PROP_DATA_SOURCE, src);
    060        return this;
    061    }
    062
    063    @Override
    064    public DatabaseBuilderParametersImpl setTable(final String tname) {
    065        storeProperty(PROP_TABLE, tname);
    066        return this;
    067    }
    068
    069    @Override
    070    public DatabaseBuilderParametersImpl setKeyColumn(final String name) {
    071        storeProperty(PROP_KEY_COLUMN, name);
    072        return this;
    073    }
    074
    075    @Override
    076    public DatabaseBuilderParametersImpl setValueColumn(final String name) {
    077        storeProperty(PROP_VALUE_COLUMN, name);
    078        return this;
    079    }
    080
    081    @Override
    082    public DatabaseBuilderParametersImpl setConfigurationNameColumn(final String name) {
    083        storeProperty(PROP_CONFIG_NAME_COLUMN, name);
    084        return this;
    085    }
    086
    087    @Override
    088    public DatabaseBuilderParametersImpl setConfigurationName(final String name) {
    089        storeProperty(PROP_CONFIG_NAME, name);
    090        return this;
    091    }
    092
    093    @Override
    094    public DatabaseBuilderParametersImpl setAutoCommit(final boolean f) {
    095        storeProperty(PROP_AUTO_COMMIT, Boolean.valueOf(f));
    096        return this;
    097    }
    098}