当前位置: 首页>>代码示例>>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;未经允许,请勿转载。