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


Java Properties.clear方法代碼示例

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


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

示例1: testBug24886

import java.util.Properties; //導入方法依賴的package包/類
public void testBug24886() throws Exception {
    Properties props = new Properties();
    props.setProperty("blobsAreStrings", "true");

    Connection noBlobConn = getConnectionWithProps(props);

    createTable("testBug24886", "(sepallength double, sepalwidth double, petallength double, petalwidth double, Class mediumtext, fy TIMESTAMP)");

    noBlobConn.createStatement().executeUpdate("INSERT INTO testBug24886 VALUES (1,2,3,4,'1234', now()),(5,6,7,8,'12345678', now())");
    this.rs = noBlobConn.createStatement()
            .executeQuery("SELECT concat(Class,petallength), COUNT(*) FROM `testBug24886` GROUP BY `concat(Class,petallength)`");
    this.rs.next();
    assertEquals("java.lang.String", this.rs.getObject(1).getClass().getName());

    props.clear();
    props.setProperty("functionsNeverReturnBlobs", "true");
    noBlobConn = getConnectionWithProps(props);
    this.rs = noBlobConn.createStatement()
            .executeQuery("SELECT concat(Class,petallength), COUNT(*) FROM `testBug24886` GROUP BY `concat(Class,petallength)`");
    this.rs.next();

    if (versionMeetsMinimum(4, 1)) {
        assertEquals("java.lang.String", this.rs.getObject(1).getClass().getName());

    }
}
 
開發者ID:JuanJoseFJ,項目名稱:ProyectoPacientes,代碼行數:27,代碼來源:ResultSetRegressionTest.java

示例2: prepareRollback

import java.util.Properties; //導入方法依賴的package包/類
public void prepareRollback() throws BadResultException {
    Properties actualProperties = new Properties();
    actualProperties.put(ROLLBACK_SUBSCRIPTIONID, this.getSubscriptionId());
    if (this.getReferenceId() != null) {
        actualProperties.put(ROLLBACK_SUBSCRIPTIONREF,
                this.getReferenceId());
    } else {
        actualProperties.put(ROLLBACK_SUBSCRIPTIONREF, "");
    }
    actualProperties.putAll(this.getParameterMap());
    this.setRollbackParameters(
            this.convertPropertiesToXML(actualProperties));
    actualProperties.clear();
    actualProperties.putAll(getAttributeMap());
    this.setRollbackInstanceAttributes(
            this.convertPropertiesToXML(actualProperties));
}
 
開發者ID:servicecatalog,項目名稱:oscm-app,代碼行數:18,代碼來源:ServiceInstance.java

示例3: initProperties

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Merges the given map into the target properties object. Additionally it checks if there are any given local
 * properties and whether these can override the source.
 * 
 * @return a new (Properties) object mergeing the local properties and the source
 */
public static Properties initProperties(Properties localMap, boolean localOverride, Map<?, ?> source,
		Properties target) {

	synchronized (target) {
		target.clear();

		// merge the local properties (upfront)
		if (localMap != null && !localOverride) {
			CollectionUtils.mergePropertiesIntoMap(localMap, target);
		}

		if (source != null) {
			target.putAll(source);
		}

		// merge local properties (if needed)
		if (localMap != null && localOverride) {
			CollectionUtils.mergePropertiesIntoMap(localMap, target);
		}

		return target;
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:30,代碼來源:PropertiesUtil.java

示例4: parseManifest

import java.util.Properties; //導入方法依賴的package包/類
private static void parseManifest() {
    if (sManifestParsed)
        return;
    sManifestParsed = true;

    try {
        Enumeration<URL> resources = Uranium.class.getClassLoader()
                .getResources("META-INF/MANIFEST.MF");
        Properties manifest = new Properties();
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            manifest.load(url.openStream());
            String version = manifest.getProperty("Uranium-Version");
            if (version != null) {
                String path = url.getPath();
                String jarFilePath = path.substring(path.indexOf(":") + 1,
                        path.indexOf("!"));
                jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8");
                sServerLocation = new File(jarFilePath);

                sCurrentVersion = version;
                sGroup = manifest.getProperty("Uranium-Group");
                sBranch = manifest.getProperty("Uranium-Branch");
                sChannel = manifest.getProperty("Uranium-Channel");
                sLegacy = Boolean.parseBoolean(manifest.getProperty("Uranium-Legacy"));
                sOfficial = Boolean.parseBoolean(manifest.getProperty("Uranium-Official"));
                break;
            }
            manifest.clear();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:35,代碼來源:Uranium.java

示例5: main

import java.util.Properties; //導入方法依賴的package包/類
public static void main(String[] args)
{
   Properties table = new Properties(); 

   // set properties
   table.setProperty("color", "blue");
   table.setProperty("width", "200");

   System.out.println("After setting properties");
   listProperties(table); 

   // replace property value
   table.setProperty("color", "red");

   System.out.println("After replacing properties");
   listProperties(table); 

   saveProperties(table);

   table.clear(); // empty table

   System.out.println("After clearing properties");
   listProperties(table); 
   
   loadProperties(table);

   // get value of property color
   Object value = table.getProperty("color");

   // check if value is in table
   if (value != null)
      System.out.printf("Property color's value is %s%n", value);
   else
      System.out.println("Property color is not in table");
}
 
開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:36,代碼來源:PropertiesTest.java

示例6: loadLanguage

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Loads a lang file, first searching for a marker to enable the 'extended' format {escape characters}
 * If the marker is not found it simply returns and let the vanilla code load things.
 * The Marker is 'PARSE_ESCAPES' by itself on a line starting with '#' as such:
 * #PARSE_ESCAPES
 *
 * @param table The Map to load each key/value pair into.
 * @param inputstream Input stream containing the lang file.
 * @return A new InputStream that vanilla uses to load normal Lang files, Null if this is a 'enhanced' file and loading is done.
 */
public InputStream loadLanguage(Map<String, String> table, InputStream inputstream) throws IOException
{
    byte[] data = IOUtils.toByteArray(inputstream);

    boolean isEnhanced = false;
    for (String line : IOUtils.readLines(new ByteArrayInputStream(data), Charsets.UTF_8))
    {
        if (!line.isEmpty() && line.charAt(0) == '#')
        {
            line = line.substring(1).trim();
            if (line.equals("PARSE_ESCAPES"))
            {
                isEnhanced = true;
                break;
            }
        }
    }

    if (!isEnhanced)
        return new ByteArrayInputStream(data);

    Properties props = new Properties();
    props.load(new InputStreamReader(new ByteArrayInputStream(data), Charsets.UTF_8));
    for (Entry<Object, Object> e : props.entrySet())
    {
        table.put((String)e.getKey(), (String)e.getValue());
    }
    props.clear();
    return null;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:41,代碼來源:FMLCommonHandler.java

示例7: testBug77171

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Tests fix for Bug#77171 - On every connect getting sql_mode from server creates unnecessary exception.
 * 
 * This fix is a refactoring on ConnectorImpl.initializePropsFromServer() to improve performance when processing the SQL_MODE value. No behavior was
 * changed. This test guarantees that nothing was broken in these matters, for the relevant MySQL versions, after this fix.
 */
public void testBug77171() throws Exception {
    String sqlMode = getMysqlVariable("sql_mode");
    sqlMode = removeSqlMode("ANSI_QUOTES", sqlMode);
    sqlMode = removeSqlMode("NO_BACKSLASH_ESCAPES", sqlMode);
    String newSqlMode = sqlMode;
    if (sqlMode.length() > 0) {
        sqlMode += ",";
    }

    Properties props = new Properties();
    props.put("sessionVariables", "sql_mode='" + newSqlMode + "'");
    Connection testConn = getConnectionWithProps(props);
    assertFalse(((MySQLConnection) testConn).useAnsiQuotedIdentifiers());
    assertFalse(((MySQLConnection) testConn).isNoBackslashEscapesSet());
    testConn.close();

    props.clear();
    newSqlMode = sqlMode + "ANSI_QUOTES";
    props.put("sessionVariables", "sql_mode='" + newSqlMode + "'");
    testConn = getConnectionWithProps(props);
    assertTrue(((MySQLConnection) testConn).useAnsiQuotedIdentifiers());
    assertFalse(((MySQLConnection) testConn).isNoBackslashEscapesSet());
    testConn.close();

    props.clear();
    newSqlMode = sqlMode + "NO_BACKSLASH_ESCAPES";
    props.put("sessionVariables", "sql_mode='" + newSqlMode + "'");
    testConn = getConnectionWithProps(props);
    assertFalse(((MySQLConnection) testConn).useAnsiQuotedIdentifiers());
    assertTrue(((MySQLConnection) testConn).isNoBackslashEscapesSet());
    testConn.close();

    props.clear();
    newSqlMode = sqlMode + "ANSI_QUOTES,NO_BACKSLASH_ESCAPES";
    props.put("sessionVariables", "sql_mode='" + newSqlMode + "'");
    testConn = getConnectionWithProps(props);
    assertTrue(((MySQLConnection) testConn).useAnsiQuotedIdentifiers());
    assertTrue(((MySQLConnection) testConn).isNoBackslashEscapesSet());
    testConn.close();
}
 
開發者ID:JuanJoseFJ,項目名稱:ProyectoPacientes,代碼行數:47,代碼來源:ConnectionRegressionTest.java

示例8: testBuildWithDirtyList

import java.util.Properties; //導入方法依賴的package包/類
public void testBuildWithDirtyList() throws Exception { // #104508
    EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    ep.put(ProjectProperties.TRACK_FILE_CHANGES, "true");
    helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
    Properties p = new Properties();
    assertEquals("[jar]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_BUILD, Lookup.EMPTY, p)));
    assertEquals("{}", p.toString());
    TestFileUtils.touch(someSource1.getPrimaryFile(), null);
    assertEquals("[jar]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_BUILD, Lookup.EMPTY, p)));
    assertEquals("{}", p.toString());
    ep = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
    ep.put(ProjectProperties.DO_JAR, "false");
    helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
    assertEquals("[compile]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_BUILD, Lookup.EMPTY, p)));
    assertEquals("{}", p.toString());
    ep.put(ProjectProperties.DO_DEPEND, "false");
    helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
    assertEquals("[compile]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_BUILD, Lookup.EMPTY, p)));
    assertEquals("{}", p.toString());
    TestFileUtils.touch(someSource1.getPrimaryFile(), null);
    assertEquals("[compile]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_BUILD, Lookup.EMPTY, p)));
    assertEquals("{includes=foo/Bar.java}", p.toString());
    p.clear();
    TestFileUtils.touch(someSource2.getPrimaryFile(), null);
    TestFileUtils.touch(someSource1.getPrimaryFile(), null);
    assertEquals("[compile]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_BUILD, Lookup.EMPTY, p)));
    assertEquals("{includes=foo/Bar.java,foo/Main.java}", p.toString());
    p.clear();
    assertEquals("[compile]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_BUILD, Lookup.EMPTY, p)));
    assertEquals("{}", p.toString());
    TestFileUtils.touch(someTest1.getPrimaryFile(), null);
    assertEquals("[compile]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_BUILD, Lookup.EMPTY, p)));
    assertEquals("{}", p.toString());
    sources.createData("x.properties");
    assertEquals("[compile]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_BUILD, Lookup.EMPTY, p)));
    assertEquals("{includes=x.properties}", p.toString());
    p.clear();
    someSource1.setModified(true);
    assertEquals("[compile]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_BUILD, Lookup.EMPTY, p)));
    assertEquals("{includes=foo/Bar.java}", p.toString());
    p.clear();
    TestFileUtils.touch(someSource1.getPrimaryFile(), null);
    assertEquals("[clean, compile]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_REBUILD, Lookup.EMPTY, p)));
    assertEquals("{}", p.toString());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:46,代碼來源:J2SEActionProviderTest.java

示例9: testTinyint1IsBit

import java.util.Properties; //導入方法依賴的package包/類
public void testTinyint1IsBit() throws Exception {
    String tableName = "testTinyint1IsBit";
    // Can't use 'BIT' or boolean
    createTable(tableName, "(field1 TINYINT(1))");
    this.stmt.executeUpdate("INSERT INTO " + tableName + " VALUES (1)");

    Properties props = new Properties();
    props.setProperty("tinyint1IsBit", "true");
    props.setProperty("transformedBitIsBoolean", "true");
    Connection boolConn = getConnectionWithProps(props);

    this.rs = boolConn.createStatement().executeQuery("SELECT field1 FROM " + tableName);
    checkBitOrBooleanType(false);

    this.rs = boolConn.prepareStatement("SELECT field1 FROM " + tableName).executeQuery();
    checkBitOrBooleanType(false);

    this.rs = boolConn.getMetaData().getColumns(boolConn.getCatalog(), null, tableName, "field1");
    assertTrue(this.rs.next());

    if (versionMeetsMinimum(4, 1)) {
        assertEquals(Types.BOOLEAN, this.rs.getInt("DATA_TYPE"));
    } else {
        assertEquals(Types.BIT, this.rs.getInt("DATA_TYPE"));
    }

    if (versionMeetsMinimum(4, 1)) {
        assertEquals("BOOLEAN", this.rs.getString("TYPE_NAME"));
    } else {
        assertEquals("BIT", this.rs.getString("TYPE_NAME"));
    }

    props.clear();
    props.setProperty("transformedBitIsBoolean", "false");
    props.setProperty("tinyint1IsBit", "true");

    Connection bitConn = getConnectionWithProps(props);

    this.rs = bitConn.createStatement().executeQuery("SELECT field1 FROM " + tableName);
    checkBitOrBooleanType(true);

    this.rs = bitConn.prepareStatement("SELECT field1 FROM " + tableName).executeQuery();
    checkBitOrBooleanType(true);

    this.rs = bitConn.getMetaData().getColumns(boolConn.getCatalog(), null, tableName, "field1");
    assertTrue(this.rs.next());

    assertEquals(Types.BIT, this.rs.getInt("DATA_TYPE"));

    assertEquals("BIT", this.rs.getString("TYPE_NAME"));
}
 
開發者ID:JuanJoseFJ,項目名稱:ProyectoPacientes,代碼行數:52,代碼來源:MetadataTest.java

示例10: testBug20685022

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Tests fix for BUG#20685022 - SSL CONNECTION TO MYSQL 5.7.6 COMMUNITY SERVER FAILS
 * 
 * This test is duplicated in testuite.regression.ConnectionRegressionTest.jdbc4.testBug20685022().
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20685022() throws Exception {
    if (!isCommunityEdition()) {
        return;
    }

    final Properties props = new Properties();

    /*
     * case 1: non verifying server certificate
     */
    props.clear();
    props.setProperty("useSSL", "true");
    props.setProperty("requireSSL", "true");
    props.setProperty("verifyServerCertificate", "false");

    getConnectionWithProps(props);

    /*
     * case 2: verifying server certificate using key store provided by connection properties
     */
    props.clear();
    props.setProperty("useSSL", "true");
    props.setProperty("requireSSL", "true");
    props.setProperty("verifyServerCertificate", "true");
    props.setProperty("trustCertificateKeyStoreUrl", "file:src/testsuite/ssl-test-certs/ca-truststore");
    props.setProperty("trustCertificateKeyStoreType", "JKS");
    props.setProperty("trustCertificateKeyStorePassword", "password");

    getConnectionWithProps(props);

    /*
     * case 3: verifying server certificate using key store provided by system properties
     */
    props.clear();
    props.setProperty("useSSL", "true");
    props.setProperty("requireSSL", "true");
    props.setProperty("verifyServerCertificate", "true");

    String trustStorePath = "src/testsuite/ssl-test-certs/ca-truststore";
    System.setProperty("javax.net.ssl.keyStore", trustStorePath);
    System.setProperty("javax.net.ssl.keyStorePassword", "password");
    System.setProperty("javax.net.ssl.trustStore", trustStorePath);
    System.setProperty("javax.net.ssl.trustStorePassword", "password");

    getConnectionWithProps(props);
}
 
開發者ID:rafallis,項目名稱:BibliotecaPS,代碼行數:55,代碼來源:ConnectionRegressionTest.java

示例11: testBug20685022

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Tests fix for BUG#20685022 - SSL CONNECTION TO MYSQL 5.7.6 COMMUNITY SERVER FAILS
 * 
 * This test is duplicated in testuite.regression.ConnectionRegressionTest.testBug20685022().
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug20685022() throws Exception {
    if (!isCommunityEdition()) {
        return;
    }

    final Properties props = new Properties();

    /*
     * case 1: non verifying server certificate
     */
    props.clear();
    props.setProperty("useSSL", "true");
    props.setProperty("requireSSL", "true");
    props.setProperty("verifyServerCertificate", "false");

    getConnectionWithProps(props);

    /*
     * case 2: verifying server certificate using key store provided by connection properties
     */
    props.clear();
    props.setProperty("useSSL", "true");
    props.setProperty("requireSSL", "true");
    props.setProperty("verifyServerCertificate", "true");
    props.setProperty("trustCertificateKeyStoreUrl", "file:src/testsuite/ssl-test-certs/ca-truststore");
    props.setProperty("trustCertificateKeyStoreType", "JKS");
    props.setProperty("trustCertificateKeyStorePassword", "password");

    getConnectionWithProps(props);

    /*
     * case 3: verifying server certificate using key store provided by system properties
     */
    props.clear();
    props.setProperty("useSSL", "true");
    props.setProperty("requireSSL", "true");
    props.setProperty("verifyServerCertificate", "true");

    String trustStorePath = "src/testsuite/ssl-test-certs/ca-truststore";
    System.setProperty("javax.net.ssl.keyStore", trustStorePath);
    System.setProperty("javax.net.ssl.keyStorePassword", "password");
    System.setProperty("javax.net.ssl.trustStore", trustStorePath);
    System.setProperty("javax.net.ssl.trustStorePassword", "password");

    getConnectionWithProps(props);
}
 
開發者ID:JuanJoseFJ,項目名稱:ProyectoPacientes,代碼行數:55,代碼來源:ConnectionRegressionTest.java

示例12: testIsMisConfigured

import java.util.Properties; //導入方法依賴的package包/類
@Test
public void testIsMisConfigured() {
  Properties clusterProps = new Properties();
  Properties serverProps = new Properties();

  // both does not have the key
  assertFalse(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));

  // cluster has the key, not the server
  clusterProps.setProperty("key", "value");
  assertFalse(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));
  clusterProps.setProperty("key", "");
  assertFalse(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));

  // server has the key, not the cluster
  clusterProps.clear();
  serverProps.clear();
  serverProps.setProperty("key", "value");
  assertTrue(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));
  serverProps.setProperty("key", "");
  assertFalse(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));

  // server has the key, not the cluster
  clusterProps.clear();
  serverProps.clear();
  clusterProps.setProperty("key", "");
  serverProps.setProperty("key", "value");
  assertTrue(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));
  serverProps.setProperty("key", "");
  assertFalse(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));

  // server and cluster has the same value
  clusterProps.clear();
  serverProps.clear();
  clusterProps.setProperty("key", "value");
  serverProps.setProperty("key", "value");
  assertFalse(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));
  clusterProps.setProperty("key", "");
  serverProps.setProperty("key", "");
  assertFalse(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));

  // server and cluster has the different value
  clusterProps.clear();
  serverProps.clear();
  clusterProps.setProperty("key", "value1");
  serverProps.setProperty("key", "value2");
  assertTrue(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));
  clusterProps.setProperty("key", "value1");
  serverProps.setProperty("key", "");
  assertFalse(GemFireCacheImpl.isMisConfigured(clusterProps, serverProps, "key"));
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:52,代碼來源:GemFireCacheImplTest.java


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