【Java开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了Java开源代码-ConnectionProperties.java的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
/*
Copyright (C) 2002-2004 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
There are special exceptions to the terms and conditions of the GPL
as it is applied to this software. View the full text of the
exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
software distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.mysql.jdbc;
import com.mysql.jdbc.log.Jdk14Logger;
import com.mysql.jdbc.log.Log;
import com.mysql.jdbc.log.StandardLogger;
import java.io.UnsupportedEncodingException;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import javax.naming.RefAddr;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
/**
* Represents configurable properties for Connections and DataSources. Can also
* expose properties as JDBC DriverPropertyInfo if required as well.
*
* @author Mark Matthews
* @version $Id: ConnectionProperties.java,v 1.1.2.2 2005/05/17 14:58:56
* mmatthews Exp $
*/
public class ConnectionProperties {
class BooleanConnectionProperty extends ConnectionProperty {
/**
* DOCUMENT ME!
*
* @param propertyNameToSet
* @param defaultValueToSet
* @param descriptionToSet
* DOCUMENT ME!
* @param sinceVersionToSet
* DOCUMENT ME!
*/
BooleanConnectionProperty(String propertyNameToSet,
boolean defaultValueToSet, String descriptionToSet,
String sinceVersionToSet, String category, int orderInCategory) {
super(propertyNameToSet, new Boolean(defaultValueToSet), null, 0,
0, descriptionToSet, sinceVersionToSet, category,
orderInCategory);
}
/**
* @see com.mysql.jdbc.ConnectionProperties.ConnectionProperty#getAllowableValues()
*/
String[] getAllowableValues() {
return new String[] { "true", "false", "yes", "no" };
}
boolean getValueAsBoolean() {
return ((Boolean) this.valueAsObject).booleanValue();
}
/**
* @see com.mysql.jdbc.ConnectionProperties.ConnectionProperty#hasValueConstraints()
*/
boolean hasValueConstraints() {
return true;
}
/**
* @see com.mysql.jdbc.ConnectionProperties.ConnectionProperty#initializeFrom(java.util.Properties)
*/
void initializeFrom(String extractedValue) throws SQLException {
if (extractedValue != null) {
validateStringValues(extractedValue);
this.valueAsObject = new Boolean(extractedValue
.equalsIgnoreCase("TRUE")
|| extractedValue.equalsIgnoreCase("YES"));
} else {
this.valueAsObject = this.defaultValue;
}
}
/**
* @see com.mysql.jdbc.ConnectionProperties.ConnectionProperty#isRangeBased()
*/
boolean isRangeBased() {
return false;
}
void setValue(boolean valueFlag) {
this.valueAsObject = new Boolean(valueFlag);
}
}
abstract class ConnectionProperty extends DriverPropertyInfo {
String[] allowableValues;
String categoryName;
Object defaultValue;
int lowerBound;
int order;
String propertyName;
Strin