當前位置: 首頁>>代碼示例>>Java>>正文


Java Properties.clone方法代碼示例

本文整理匯總了Java中java.util.Properties.clone方法的典型用法代碼示例。如果您正苦於以下問題:Java Properties.clone方法的具體用法?Java Properties.clone怎麽用?Java Properties.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Properties的用法示例。


在下文中一共展示了Properties.clone方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setProperties

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Sets connection properties. If user / password / loginTimeout has been
 * set with one of the setXXX() methods it will be added to the Properties
 * object.
 *
 * @param props properties.  If null, then existing properties will be
 *                           cleared/replaced.
 */
public void setProperties(Properties props) {

    connectionProps = (props == null) ? new Properties()
                                      : (Properties) props.clone();

    if (user != null) {
        connectionProps.setProperty("user", user);
    }

    if (password != null) {
        connectionProps.setProperty("password", password);
    }

    if (loginTimeout != 0) {
        connectionProps.setProperty("loginTimeout", Integer.toString(loginTimeout));
    }
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:26,代碼來源:JDBCCommonDataSource.java

示例2: initializeHostsSpecs

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Initializes the hosts lists and makes a "clean" local copy of the given connection properties so that it can be later used to create standard
 * connections.
 * 
 * @param hosts
 *            The list of hosts for this multi-host connection.
 * @param props
 *            Connection properties from where to get initial settings and to be used in new connections.
 * @return
 *         The number of hosts found in the hosts list.
 */
int initializeHostsSpecs(List<String> hosts, Properties props) {
    this.autoReconnect = "true".equalsIgnoreCase(props.getProperty("autoReconnect")) || "true".equalsIgnoreCase(props.getProperty("autoReconnectForPools"));

    this.hostList = hosts;
    int numHosts = this.hostList.size();

    this.localProps = (Properties) props.clone();
    this.localProps.remove(NonRegisteringDriver.HOST_PROPERTY_KEY);
    this.localProps.remove(NonRegisteringDriver.PORT_PROPERTY_KEY);

    for (int i = 0; i < numHosts; i++) {
        this.localProps.remove(NonRegisteringDriver.HOST_PROPERTY_KEY + "." + (i + 1));
        this.localProps.remove(NonRegisteringDriver.PORT_PROPERTY_KEY + "." + (i + 1));
    }

    this.localProps.remove(NonRegisteringDriver.NUM_HOSTS_PROPERTY_KEY);
    this.localProps.setProperty("useLocalSessionState", "true");

    return numHosts;
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:32,代碼來源:MultiHostConnectionProxy.java

示例3: setProperties

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Sets connection properties. If user / password / logginTimeout has been
 * set with one of the setXXX() methods it will be added to the Properties
 * object.
 *
 * @param props properties.  If null, then existing properties will be
 *                           cleared/replaced.
 */
public void setProperties(Properties props) {

    connectionProps = (props == null) ? new Properties()
                                      : (Properties) props.clone();

    if (user != null) {
        props.setProperty("user", user);
    }

    if (password != null) {
        props.setProperty("password", password);
    }

    if (loginTimeout != 0) {
        props.setProperty("loginTimeout", Integer.toString(loginTimeout));
    }
}
 
開發者ID:Julien35,項目名稱:dev-courses,代碼行數:26,代碼來源:JDBCCommonDataSource.java

示例4: initializeProperties

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Initializes driver properties that come from URL or properties passed to
 * the driver manager.
 * 
 * @param info
 * @throws SQLException
 */
protected void initializeProperties(Properties info) throws SQLException {
    if (info != null) {
        // For backwards-compatibility
        String profileSqlLc = info.getProperty("profileSql");

        if (profileSqlLc != null) {
            info.put("profileSQL", profileSqlLc);
        }

        Properties infoCopy = (Properties) info.clone();

        infoCopy.remove(NonRegisteringDriver.HOST_PROPERTY_KEY);
        infoCopy.remove(NonRegisteringDriver.USER_PROPERTY_KEY);
        infoCopy.remove(NonRegisteringDriver.PASSWORD_PROPERTY_KEY);
        infoCopy.remove(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
        infoCopy.remove(NonRegisteringDriver.PORT_PROPERTY_KEY);
        infoCopy.remove("profileSql");

        int numPropertiesToSet = PROPERTY_LIST.size();

        for (int i = 0; i < numPropertiesToSet; i++) {
            java.lang.reflect.Field propertyField = PROPERTY_LIST.get(i);

            try {
                ConnectionProperty propToSet = (ConnectionProperty) propertyField.get(this);

                propToSet.initializeFrom(infoCopy, getExceptionInterceptor());
            } catch (IllegalAccessException iae) {
                throw SQLError.createSQLException(Messages.getString("ConnectionProperties.unableToInitDriverProperties") + iae.toString(),
                        SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
            }
        }

        postInitialization();
    }
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:44,代碼來源:ConnectionPropertiesImpl.java

示例5: testDriverProperties

import java.util.Properties; //導入方法依賴的package包/類
@Test public void testDriverProperties() throws Exception {
  final Properties props = new Properties();
  props.setProperty("foo", "bar");
  final Properties originalProps = (Properties) props.clone();
  try (final Connection conn = DriverManager.getConnection(url, props)) {
    // The contents of the two properties objects should not have changed after connecting.
    assertEquals(props, originalProps);
  }
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:10,代碼來源:RemoteMetaTest.java

示例6: setProperties

import java.util.Properties; //導入方法依賴的package包/類
/** Set properties of Ant script execution.
 * @param p a set of name/value pairs passed to Ant (will be cloned)
 */
public synchronized void setProperties(Properties p) {
    properties = (Properties) p.clone();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:AntTargetExecutor.java

示例7: connectReplicationConnection

import java.util.Properties; //導入方法依賴的package包/類
protected java.sql.Connection connectReplicationConnection(String url, Properties info) throws SQLException {
    Properties parsedProps = parseURL(url, info);

    if (parsedProps == null) {
        return null;
    }

    Properties masterProps = (Properties) parsedProps.clone();
    Properties slavesProps = (Properties) parsedProps.clone();

    // Marker used for further testing later on, also when
    // debugging
    slavesProps.setProperty("com.mysql.jdbc.ReplicationConnection.isSlave", "true");

    int numHosts = Integer.parseInt(parsedProps.getProperty(NUM_HOSTS_PROPERTY_KEY));

    if (numHosts < 2) {
        throw SQLError.createSQLException("Must specify at least one slave host to connect to for master/slave replication load-balancing functionality",
                SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE, null);
    }
    List<String> slaveHostList = new ArrayList<String>();
    List<String> masterHostList = new ArrayList<String>();

    String firstHost = masterProps.getProperty(HOST_PROPERTY_KEY + ".1") + ":" + masterProps.getProperty(PORT_PROPERTY_KEY + ".1");

    boolean usesExplicitServerType = NonRegisteringDriver.isHostPropertiesList(firstHost);

    for (int i = 0; i < numHosts; i++) {
        int index = i + 1;

        masterProps.remove(HOST_PROPERTY_KEY + "." + index);
        masterProps.remove(PORT_PROPERTY_KEY + "." + index);
        slavesProps.remove(HOST_PROPERTY_KEY + "." + index);
        slavesProps.remove(PORT_PROPERTY_KEY + "." + index);

        String host = parsedProps.getProperty(HOST_PROPERTY_KEY + "." + index);
        String port = parsedProps.getProperty(PORT_PROPERTY_KEY + "." + index);
        if (usesExplicitServerType) {
            if (isHostMaster(host)) {
                masterHostList.add(host);
            } else {
                slaveHostList.add(host);
            }
        } else {
            if (i == 0) {
                masterHostList.add(host + ":" + port);
            } else {
                slaveHostList.add(host + ":" + port);
            }
        }
    }

    slavesProps.remove(NUM_HOSTS_PROPERTY_KEY);
    masterProps.remove(NUM_HOSTS_PROPERTY_KEY);
    masterProps.remove(HOST_PROPERTY_KEY);
    masterProps.remove(PORT_PROPERTY_KEY);
    slavesProps.remove(HOST_PROPERTY_KEY);
    slavesProps.remove(PORT_PROPERTY_KEY);

    return ReplicationConnectionProxy.createProxyInstance(masterHostList, masterProps, slaveHostList, slavesProps);
}
 
開發者ID:Jugendhackt,項目名稱:OpenVertretung,代碼行數:62,代碼來源:NonRegisteringDriver.java

示例8: a

import java.util.Properties; //導入方法依賴的package包/類
public void a(Properties properties) {
    if (properties != null) {
        this.a.c = (Properties) properties.clone();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:6,代碼來源:b.java

示例9: maskOut

import java.util.Properties; //導入方法依賴的package包/類
/**
 * replace a property by a starred version
 *
 * @param props properties to check
 * @param key proeprty to mask
 *
 * @return cloned and masked properties
 */
public static Properties maskOut(Properties props, String key) {
	Properties clone = ( Properties ) props.clone();
	if ( clone.get( key ) != null ) {
		clone.setProperty( key, "****" );
	}
	return clone;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:16,代碼來源:ConfigurationHelper.java


注:本文中的java.util.Properties.clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。