Example usage for java.util Properties stringPropertyNames

List of usage examples for java.util Properties stringPropertyNames

Introduction

In this page you can find the example usage for java.util Properties stringPropertyNames.

Prototype

public Set<String> stringPropertyNames() 

Source Link

Document

Returns an unmodifiable set of keys from this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.

Usage

From source file:org.dcm4che.tool.ianscp.IanSCP.java

private static void configureTransferCapability(ApplicationEntity ae, CommandLine cl) throws IOException {
    Properties p = CLIUtils.loadProperties(cl.getOptionValue("sop-classes", "resource:sop-classes.properties"),
            null);//www .j  a v  a  2s  . co m
    for (String cuid : p.stringPropertyNames()) {
        String ts = p.getProperty(cuid);
        ae.addTransferCapability(new TransferCapability(null, cuid, TransferCapability.Role.SCP,
                toUIDs(StringUtils.split(ts, ','))));
    }
}

From source file:org.apache.falcon.unit.FalconUnit.java

private static void setupOozieConfigs() throws IOException {
    sysProps = new HashMap<>();
    String oozieHomeDir = OOZIE_HOME_DIR;
    String oozieConfDir = oozieHomeDir + "/conf";
    String oozieHadoopConfDir = oozieConfDir + "/hadoop-conf";
    String oozieActionConfDir = oozieConfDir + "/action-conf";
    String oozieLogsDir = oozieHomeDir + "/logs";
    String oozieDataDir = oozieHomeDir + "/data";

    LocalFileSystem fs = new LocalFileSystem();
    fs.mkdirs(new Path(oozieHomeDir));
    fs.mkdirs(new Path(oozieConfDir));
    fs.mkdirs(new Path(oozieHadoopConfDir));
    fs.mkdirs(new Path(oozieActionConfDir));
    fs.mkdirs(new Path(oozieLogsDir));
    fs.close();//  ww  w . j  a v a2 s  .c  o m

    setSystemProperty("oozie.home.dir", oozieHomeDir);
    setSystemProperty("oozie.data.dir", oozieDataDir);
    setSystemProperty("oozie.action.conf", oozieActionConfDir);
    setSystemProperty("oozie.log.dir", oozieLogsDir);
    setSystemProperty("oozie.log4j.file", "localoozie-log4j.properties");
    setSystemProperty("oozielocal.log", "oozieLogsDir/oozielocal.log");

    Configuration oozieSiteConf = new Configuration(false);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    InputStream oozieSiteInputStream = classLoader.getResourceAsStream(OOZIE_SITE_XML);
    XConfiguration configuration = new XConfiguration(oozieSiteInputStream);
    Properties props = configuration.toProperties();
    for (String propName : props.stringPropertyNames()) {
        oozieSiteConf.set(propName, props.getProperty(propName));
    }
    oozieSiteInputStream.close();

    InputStream oozieDefaultInputStream = classLoader.getResourceAsStream(OOZIE_DEFAULT_XML);
    configuration = new XConfiguration(oozieDefaultInputStream);
    String classes = configuration.get(Services.CONF_SERVICE_CLASSES);
    oozieSiteConf.set(Services.CONF_SERVICE_CLASSES,
            classes.replaceAll("org.apache.oozie.service.ShareLibService,", ""));
    File target = new File(oozieConfDir, OOZIE_SITE_XML);
    FileOutputStream outStream = null;
    try {
        outStream = new FileOutputStream(target);
        oozieSiteConf.writeXml(outStream);
    } finally {
        if (outStream != null) {
            outStream.close();
        }
    }
    oozieDefaultInputStream.close();

    CurrentUser.authenticate(System.getProperty("user.name"));
}

From source file:gobblin.kafka.writer.KafkaDataWriter.java

private static Properties stripPrefix(Properties props, String prefix) {
    Properties strippedProps = new Properties();
    int prefixLength = prefix.length();
    for (String key : props.stringPropertyNames()) {
        if (key.startsWith(prefix)) {
            strippedProps.setProperty(key.substring(prefixLength), props.getProperty(key));
        }/*w  ww.ja v a 2  s . c o m*/
    }
    return strippedProps;
}

From source file:org.dcm4che3.tool.storescp.StoreSCP.java

private static void configureTransferCapability(ApplicationEntity ae, CommandLine cl) throws IOException {
    if (cl.hasOption("accept-unknown")) {
        ae.addTransferCapability(new TransferCapability(null, "*", TransferCapability.Role.SCP, "*"));
    } else {//from www.  j  a va  2  s  . c om
        Properties p = CLIUtils
                .loadProperties(cl.getOptionValue("sop-classes", "resource:sop-classes.properties"), null);
        for (String cuid : p.stringPropertyNames()) {
            String ts = p.getProperty(cuid);
            TransferCapability tc = new TransferCapability(null, CLIUtils.toUID(cuid),
                    TransferCapability.Role.SCP, CLIUtils.toUIDs(ts));
            ae.addTransferCapability(tc);
        }
    }
}

From source file:org.dcm4che.tool.storescp.StoreSCP.java

private static void configureTransferCapability(ApplicationEntity ae, CommandLine cl) throws IOException {
    if (cl.hasOption("accept-unknown")) {
        ae.addTransferCapability(new TransferCapability(null, "*", TransferCapability.Role.SCP, "*"));
    } else {/*from   ww w  .ja v  a  2  s.c o m*/
        Properties p = CLIUtils
                .loadProperties(cl.getOptionValue("sop-classes", "resource:sop-classes.properties"), null);
        for (String cuid : p.stringPropertyNames()) {
            String ts = p.getProperty(cuid);
            ae.addTransferCapability(
                    ts.equals("*") ? new TransferCapability(null, cuid, TransferCapability.Role.SCP, "*")
                            : new TransferCapability(null, cuid, TransferCapability.Role.SCP,
                                    StringUtils.split(ts, ',')));
        }
    }
}

From source file:org.apache.jackrabbit.oak.plugins.tika.TextExtractorMain.java

private static Map<String, ?> toMap(Properties properties) {
    Map<String, String> map = Maps.newHashMap();
    for (final String name : properties.stringPropertyNames()) {
        map.put(name, properties.getProperty(name));
    }/*w  w  w .j a v a 2 s.com*/
    return map;
}

From source file:org.evosuite.CommandLineParameters.java

public static void handleClassPath(CommandLine line) {

    String DCP = null;//w w w. ja va 2s .co  m
    java.util.Properties properties = line.getOptionProperties("D");
    for (String propertyName : properties.stringPropertyNames()) {
        if (propertyName.equals("CP")) {
            DCP = properties.getProperty(propertyName);
        }
    }

    if (line.hasOption("projectCP") && DCP != null) {
        throw new IllegalArgumentException("Ambiguous classpath: both -projectCP and -DCP are defined");
    }

    String[] cpEntries = null;

    if (line.hasOption("projectCP")) {
        cpEntries = line.getOptionValue("projectCP").split(File.pathSeparator);
    } else if (DCP != null) {
        cpEntries = DCP.split(File.pathSeparator);
    }

    if (cpEntries != null) {
        ClassPathHandler.getInstance().changeTargetClassPath(cpEntries);
    }

    if (line.hasOption("target")) {
        String target = line.getOptionValue("target");

        /* 
         * let's just add the target automatically to the classpath.
         * This is useful for when we do not want to specify the classpath,
         * and so just typing '-target' on command line
         * 
         */
        ClassPathHandler.getInstance().addElementToTargetProjectClassPath(target);
    }

    if (line.hasOption("evosuiteCP")) {
        String entry = line.getOptionValue("evosuiteCP");
        String[] entries = entry.split(File.pathSeparator);
        ClassPathHandler.getInstance().setEvoSuiteClassPath(entries);
    }
}

From source file:com.seovic.config.Configuration.java

private static Map<String, String> loadConfiguration() {
    Map<String, String> props = new HashMap<String, String>();
    props.put(EXPRESSION_TYPE, DEFAULT_EXPRESSION_TYPE);
    props.put(EXTRACTOR_TYPE, DEFAULT_EXTRACTOR_TYPE);
    props.put(UPDATER_TYPE, DEFAULT_UPDATER_TYPE);
    props.put(CONDITION_TYPE, DEFAULT_CONDITION_TYPE);
    props.put(SCRIPT_LANGUAGE, DEFAULT_SCRIPT_LANGUAGE);

    props.put(SEQUENCE_GENERATOR_TYPE, DEFAULT_SEQUENCE_GENERATOR_TYPE);
    props.put(SEQUENCE_CACHE_NAME, DEFAULT_SEQUENCE_CACHE_NAME);

    try {//from   www .ja v a 2 s . co m
        Properties config = new Properties();
        config.load(Configuration.class.getClassLoader().getResourceAsStream("coherence-tools.properties"));
        for (String propertyName : config.stringPropertyNames()) {
            props.put(propertyName, config.getProperty(propertyName));
        }
    } catch (Exception e) {
        // should never happen, as default file is embedded within JAR
        s_log.warn("Configuration file coherence-tools.properties" + " is missing. Using hardcoded defaults: \n"
                + props);
    }
    return props;
}

From source file:org.apache.crunch.kafka.record.KafkaInputFormat.java

/**
 * Writes the Kafka connection properties to the {@code bundle}. The connection properties are prefixed with
 * "org.apache.crunch.kafka.connection.properties" to allow for suppression of unused {@code ConsumerConfig} warnings
 * generated by unused Hadoop properties.
 *
 * @param connectionProperties The Kafka connection properties to be prefixed for later
 *                             {@link #filterConnectionProperties(Properties props) filtering}.
 * @param bundle               The bundle into which the information should be persisted.
 *///from  w w w  . j  a  va2  s  .c o m
public static void writeConnectionPropertiesToBundle(Properties connectionProperties, FormatBundle bundle) {
    for (final String name : connectionProperties.stringPropertyNames()) {
        bundle.set(generateConnectionPropertyKey(name), connectionProperties.getProperty(name));
    }
}

From source file:org.apache.crunch.kafka.KafkaUtils.java

/**
 * Adds the {@code properties} to the provided {@code config} instance.
 * @param properties the properties to add to the config.
 * @param config the configuration instance to be modified.
 * @return the config instance with the populated properties
 *///from w w w. j av a2s .c  om
public static Configuration addKafkaConnectionProperties(Properties properties, Configuration config) {
    for (String name : properties.stringPropertyNames()) {
        config.set(name, properties.getProperty(name));
    }
    return config;
}