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


Java Properties.stringPropertyNames方法代碼示例

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


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

示例1: verifyProperites

import java.util.Properties; //導入方法依賴的package包/類
static void verifyProperites(Properties prop) {
    try {
        for (String key : prop.stringPropertyNames()) {
            String val = prop.getProperty(key);
            if (key.equals("Key1")) {
                if (!val.equals("value1")) {
                    fail("Key:" + key + "'s value: \nExpected: value1\nFound: " + val);
                }
            } else if (key.equals("Key2")) {
                if (!val.equals("<value2>")) {
                    fail("Key:" + key + "'s value: \nExpected: <value2>\nFound: " + val);
                }
            } else if (key.equals("Key3")) {
                if (!val.equals("value3")) {
                    fail("Key:" + key + "'s value: \nExpected: value3\nFound: " + val);
                }
            }
        }
    } catch (Exception e) {
        fail(e.getMessage());
    }

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:CompatibilityTest.java

示例2: DynamicRoutingConnection

import java.util.Properties; //導入方法依賴的package包/類
DynamicRoutingConnection(
    final String routingServiceName,
    final String routingServiceGroupName,
    final Properties properties
) {
  LOGGER.info("Creating connection");

  if (LOGGER.isDebugEnabled()) {
    for (String key : properties.stringPropertyNames()) {
      LOGGER.debug(
          "key='{}', value='{}'",
          key,
          properties.getProperty(key)
      );
    }
  }

  dynamicRoutingManager = new DynamicRoutingManager(
      routingServiceName,
      routingServiceGroupName,
      "dynamic_routing_adapter.",
      properties
  );

  LOGGER.info("Connection created");
}
 
開發者ID:aguther,項目名稱:dds-examples,代碼行數:27,代碼來源:DynamicRoutingConnection.java

示例3: configureAndStartLocator

import java.util.Properties; //導入方法依賴的package包/類
private void configureAndStartLocator(final int locatorPort, final String serverHostName,
    final Properties properties) throws IOException {
  DistributedTestUtils.deleteLocatorStateFile();

  final String memberName = getUniqueName() + "-locator";
  final File workingDirectory = temporaryFolder.newFolder(memberName);

  LocatorLauncher.Builder builder = new LocatorLauncher.Builder();

  for (String propertyName : properties.stringPropertyNames()) {
    builder.set(propertyName, properties.getProperty(propertyName));
  }
  locatorLauncher = builder.setBindAddress(serverHostName).setHostnameForClients(serverHostName)
      .setMemberName(memberName).setPort(locatorPort)
      .setWorkingDirectory(workingDirectory.getCanonicalPath()).build();
  locatorLauncher.start();

}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:19,代碼來源:JMXMBeanDUnitTest.java

示例4: serializePropertiesToByteArray

import java.util.Properties; //導入方法依賴的package包/類
/**
 * Write the given properties list to a byte array and return it. Properties with
 * a key or value that is not a String is filtered out. The stream written to the byte
 * array is ISO 8859-1 encoded.
 */
private static byte[] serializePropertiesToByteArray(Properties p) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream(4096);

    Properties props = new Properties();

    // stringPropertyNames() returns a snapshot of the property keys
    Set<String> keyset = p.stringPropertyNames();
    for (String key : keyset) {
        String value = p.getProperty(key);
        props.put(key, value);
    }

    props.store(out, null);
    return out.toByteArray();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:VMSupport.java

示例5: parseProperties

import java.util.Properties; //導入方法依賴的package包/類
public void parseProperties(String resourceName, String prefix, String suffix, ClassLoader classLoader, Plugin provider)
		throws IOException {
	Properties groupProps = new Properties();
	URL resource = classLoader.getResource(resourceName);
	if (resource == null) {
		// LogService.getRoot().warning("Group properties resource '"+resourceName +
		// "' not found.");
		LogService.getRoot().log(Level.WARNING,
				"com.rapidminer.tools.ParentResolvingMap.group_properties_resource_not_found", resourceName);
	} else {
		groupProps.load(resource.openStream());
		for (String propKey : groupProps.stringPropertyNames()) {
			if (propKey.startsWith(prefix) && propKey.endsWith(suffix)) {
				String keyString = propKey.substring(prefix.length());
				keyString = keyString.substring(0, keyString.length() - suffix.length());
				K mapKey = parseKey(keyString, classLoader, provider);
				V value = parseValue(groupProps.getProperty(propKey), classLoader, provider);
				delegate.put(mapKey, value);
			}
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:23,代碼來源:ParentResolvingMap.java

示例6: generateTargetFile

import java.util.Properties; //導入方法依賴的package包/類
public void generateTargetFile(File fileOrDir) {
    File workingDir = fileOrDir.isDirectory() ? fileOrDir : fileOrDir.getParentFile();

    File templateFile = new File(workingDir,templateFileName);
    File targetFile = new File(workingDir, targetFileName);
    File valuesFile = new File(workingDir, valuesFileName);

    String[] contents = FileSupport.readContentOfFile(templateFile);

    Properties valueProperties = new Properties();
    try {
        valueProperties.load(new FileInputStream(valuesFile));
    } catch (IOException e) {
        throw new RuntimeException("Problem reading key value pairs from valuesFile " + valuesFile.getAbsolutePath());
    }
    for (String keyId: valueProperties.stringPropertyNames()) {
        String value = valueProperties.getProperty(keyId);
        TemplateKeyDefinition keyDefinition = getKeyDefinitionByKeyId(keyId);
        if (keyDefinition == null) continue;
        writeValueToContent(contents, keyDefinition, value);
    }

    FileSupport.writeContentOfFile(targetFile,contents);
}
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:25,代碼來源:BBTemplateFile.java

示例7: publishPropsToZK

import java.util.Properties; //導入方法依賴的package包/類
/**
 * 同步最終配置到ZK
 * @param properties
 */
private void publishPropsToZK(Properties properties) {
    if (zkClient == null)
        return;
    Map<String, Object> props = new HashMap<>();
    for (String key : properties.stringPropertyNames()) {
        String value = properties.getProperty(key);
        if (value != null && !"".equals(value.toString().trim())) {
            props.put(key, value);
        }
    }
    //
    zkClient.writeData("", JsonUtils.toJson(props));
}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:18,代碼來源:CCPropertyPlaceholderConfigurer.java

示例8: get

import java.util.Properties; //導入方法依賴的package包/類
/**
 * GETメソッドに対する処理.
 * @return JAS-RS Response
 */
@SuppressWarnings("unchecked")
@GET
@Produces("application/json")
public Response get() {
    StringBuilder sb = new StringBuilder();

    // プロパティ一覧
    Properties props = PersoniumUnitConfig.getProperties();
    JSONObject responseJson = new JSONObject();
    JSONObject propertiesJson = new JSONObject();
    for (String key : props.stringPropertyNames()) {
        String value = props.getProperty(key);
        propertiesJson.put(key, value);
    }
    responseJson.put("properties", propertiesJson);

    // Cell作成/削除
    //responseJson.put("service", checkServiceStatus());

    // ElasticSearch Health
    EsClient client = EsModel.client();
    JSONObject esJson = new JSONObject();
    esJson.put("health", client.checkHealth());
    responseJson.put("ElasticSearch", esJson);

    sb.append(responseJson.toJSONString());
    return Response.status(HttpStatus.SC_OK).entity(sb.toString()).build();
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:33,代碼來源:StatusResource.java

示例9: loadProfiles

import java.util.Properties; //導入方法依賴的package包/類
private void loadProfiles(Properties props) {
	for (String name : props.stringPropertyNames()) {
		String v = props.getProperty(name);
		List<String> values = Strings.splitAndTrim(v, ',', 0);
		profiles.put(name, values);
	}
}
 
開發者ID:Bibliome,項目名稱:bibliome-java-utils,代碼行數:8,代碼來源:TabularPattern.java

示例10: propertiesToMap

import java.util.Properties; //導入方法依賴的package包/類
public static Map<String, String> propertiesToMap(Properties props) {

		LinkedHashMap<String, String> convToMap = new LinkedHashMap<String, String>();
		Set<String> propertyNames = props.stringPropertyNames();

		for (String Property : propertyNames) {
			convToMap.put(Property, props.getProperty(Property));
		}
		return convToMap;
	}
 
開發者ID:pfratta,項目名稱:ParquetUtils,代碼行數:11,代碼來源:ParquetGenerator.java

示例11: configFromFile

import java.util.Properties; //導入方法依賴的package包/類
@Deprecated
private PySystemState configFromFile(Integer appId, Integer dbId, long whExecId, String configFile) {

  prop = new Properties();
  if (appId != null) {
    prop.setProperty(Constant.APP_ID_KEY, String.valueOf(appId));
  }
  if (dbId != null) {
    prop.setProperty(Constant.DB_ID_KEY, String.valueOf(dbId));
  }
  prop.setProperty(Constant.WH_EXEC_ID_KEY, String.valueOf(whExecId));

  try {
    InputStream propFile = new FileInputStream(configFile);
    prop.load(propFile);
    propFile.close();
  } catch (IOException e) {
    logger.error("property file '{}' not found", configFile);
    e.printStackTrace();
  }

  PyDictionary config = new PyDictionary();

  for (String key : prop.stringPropertyNames()) {
    String value = prop.getProperty(key);
    config.put(new PyString(key), new PyString(value));
  }

  PySystemState sys = new PySystemState();
  sys.argv.append(config);
  return sys;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:33,代碼來源:EtlJob.java

示例12: getPropertyNames

import java.util.Properties; //導入方法依賴的package包/類
@Override
public Set<String> getPropertyNames() {
  Properties properties = m_configProperties.get();
  if (properties == null) {
    return Collections.emptySet();
  }

  return properties.stringPropertyNames();
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:10,代碼來源:DefaultConfig.java

示例13: writeXml

import java.util.Properties; //導入方法依賴的package包/類
public static void writeXml(Path configDir, Path xmlFile) throws IOException, XMLStreamException {
    XMLOutputFactory output = XMLOutputFactory.newInstance();
    try (Writer writer = Files.newBufferedWriter(xmlFile, StandardCharsets.UTF_8)) {
        XMLStreamWriter xmlWriter = output.createXMLStreamWriter(writer);
        try {
            xmlWriter.writeStartDocument(StandardCharsets.UTF_8.toString(), "1.0");
            xmlWriter.writeStartElement("config");
            try (DirectoryStream<Path> ds = Files.newDirectoryStream(configDir, entry -> Files.isRegularFile(entry) && entry.getFileName().toString().endsWith(".properties"))) {
                for (Path file : ds) {
                    String fileName = file.getFileName().toString();
                    String fileNameWithoutExtension = fileName.substring(0, fileName.length() - 11);
                    xmlWriter.writeStartElement(fileNameWithoutExtension);
                    Properties properties = new Properties();
                    try (Reader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
                        properties.load(reader);
                    }
                    for (String name : properties.stringPropertyNames()) {
                        String value = properties.getProperty(name);
                        xmlWriter.writeStartElement(name);
                        xmlWriter.writeCharacters(value);
                        xmlWriter.writeEndElement();
                    }
                    xmlWriter.writeEndElement();
                }
            }
            xmlWriter.writeEndElement();
            xmlWriter.writeEndDocument();
        } finally {
            xmlWriter.close();
        }
    }
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:33,代碼來源:PropertiesPlatformConfig.java

示例14: rollbackInstanceAttributes

import java.util.Properties; //導入方法依賴的package包/類
private void rollbackInstanceAttributes(Properties backup, EntityManager em)
        throws BadResultException {
    HashMap<String, Setting> rollbackParams = new HashMap<>();

    for (String name : backup.stringPropertyNames()) {
        rollbackParams.put(name,
                new Setting(name, backup.getProperty(name)));
    }
    this.removeAttrs(rollbackParams, em);
    this.setInstanceAttributes(rollbackParams);
    this.setRollbackInstanceAttributes(null);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:13,代碼來源:ServiceInstance.java

示例15: createQueryParameters

import java.util.Properties; //導入方法依賴的package包/類
public static List<NameValuePair> createQueryParameters(Properties queryParams){
    if (queryParams == null || queryParams.size() == 0) {
        return Collections.EMPTY_LIST;
    }
    List<NameValuePair> params = new ArrayList<NameValuePair>();

    for (String propName : queryParams.stringPropertyNames()) {
        params.add(new BasicNameValuePair(propName, queryParams.getProperty(propName)));
    }
    return params;
}
 
開發者ID:bubicn,項目名稱:bubichain-sdk-java,代碼行數:12,代碼來源:RequestUtils.java


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