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 * @version $Id: DatabaseBuilderParametersImpl.java 1842194 2018-09-27 22:24:23Z ggregory $ 036 * @since 2.0 037 */ 038public class DatabaseBuilderParametersImpl extends BasicBuilderParameters 039 implements DatabaseBuilderProperties<DatabaseBuilderParametersImpl> 040{ 041 /** Constant for the data source property. */ 042 private static final String PROP_DATA_SOURCE = "dataSource"; 043 044 /** Constant for the table property. */ 045 private static final String PROP_TABLE = "table"; 046 047 /** Constant for the key column property. */ 048 private static final String PROP_KEY_COLUMN = "keyColumn"; 049 050 /** Constant for the value column property. */ 051 private static final String PROP_VALUE_COLUMN = "valueColumn"; 052 053 /** Constant for the configuration name column property. */ 054 private static final String PROP_CONFIG_NAME_COLUMN = 055 "configurationNameColumn"; 056 057 /** Constant for the configuration name property. */ 058 private static final String PROP_CONFIG_NAME = "configurationName"; 059 060 /** Constant for the auto commit property. */ 061 private static final String PROP_AUTO_COMMIT = "autoCommit"; 062 063 @Override 064 public DatabaseBuilderParametersImpl setDataSource(final DataSource src) 065 { 066 storeProperty(PROP_DATA_SOURCE, src); 067 return this; 068 } 069 070 @Override 071 public DatabaseBuilderParametersImpl setTable(final String tname) 072 { 073 storeProperty(PROP_TABLE, tname); 074 return this; 075 } 076 077 @Override 078 public DatabaseBuilderParametersImpl setKeyColumn(final String name) 079 { 080 storeProperty(PROP_KEY_COLUMN, name); 081 return this; 082 } 083 084 @Override 085 public DatabaseBuilderParametersImpl setValueColumn(final String name) 086 { 087 storeProperty(PROP_VALUE_COLUMN, name); 088 return this; 089 } 090 091 @Override 092 public DatabaseBuilderParametersImpl setConfigurationNameColumn(final String name) 093 { 094 storeProperty(PROP_CONFIG_NAME_COLUMN, name); 095 return this; 096 } 097 098 @Override 099 public DatabaseBuilderParametersImpl setConfigurationName(final String name) 100 { 101 storeProperty(PROP_CONFIG_NAME, name); 102 return this; 103 } 104 105 @Override 106 public DatabaseBuilderParametersImpl setAutoCommit(final boolean f) 107 { 108 storeProperty(PROP_AUTO_COMMIT, Boolean.valueOf(f)); 109 return this; 110 } 111}