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:net.sf.jasperreports.engine.design.JRJdtCompiler.java

protected Map<String, String> getJdtSettings() {
    final Map<String, String> settings = new HashMap<String, String>();
    settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
    settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE);
    settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
    //      if (ctxt.getOptions().getJavaEncoding() != null) 
    //      {/*from  ww w  .  j  av a  2s .c om*/
    //         settings.put(CompilerOptions.OPTION_Encoding, ctxt.getOptions().getJavaEncoding());
    //      }
    //      if (ctxt.getOptions().getClassDebugInfo()) 
    //      {
    //         settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
    //      }

    List<JRPropertiesUtil.PropertySuffix> properties = JRPropertiesUtil.getInstance(jasperReportsContext)
            .getProperties(JDT_PROPERTIES_PREFIX);
    for (Iterator<JRPropertiesUtil.PropertySuffix> it = properties.iterator(); it.hasNext();) {
        JRPropertiesUtil.PropertySuffix property = it.next();
        String propVal = property.getValue();
        if (propVal != null && propVal.length() > 0) {
            settings.put(property.getKey(), propVal);
        }
    }

    Properties systemProps = System.getProperties();
    for (String propName : systemProps.stringPropertyNames()) {
        if (propName.startsWith(JDT_PROPERTIES_PREFIX)) {
            String propVal = systemProps.getProperty(propName);
            if (propVal != null && propVal.length() > 0) {
                settings.put(propName, propVal);
            }
        }
    }

    return settings;
}

From source file:com.qpark.maven.plugin.router.RouterXmlMojo.java

/**
 * @param p//from  www  .  j a v  a 2  s  .  c  o  m
 * @return
 */
private List<SimpleEntry<String, String>> getHeaderEnricher(final Properties p) {
    List<SimpleEntry<String, String>> list = new ArrayList<SimpleEntry<String, String>>();
    SimpleEntry<String, String> entry;
    String suffix;
    for (String key : p.stringPropertyNames()) {
        if (key != null && key.startsWith(RouterProperitesMojo.ROUTER_HEADER_ENRICHER_HEADER_NAME)) {
            entry = new SimpleEntry<String, String>(p.getProperty(key), "");
            suffix = key.substring(key.lastIndexOf('.'), key.length());
            for (String keyx : p.stringPropertyNames()) {
                if (keyx != null && keyx.startsWith(RouterProperitesMojo.ROUTER_HEADER_ENRICHER_BEAN_NAME)) {
                    if (keyx.endsWith(suffix)) {
                        entry.setValue(p.getProperty(keyx));
                        list.add(entry);
                        break;
                    }
                }
            }
        }
    }
    return list;
}

From source file:com.qpark.maven.plugin.router.RouterXmlMojo.java

/**
 * @param p//from w ww .ja v  a2  s  . co  m
 * @return
 */
private List<SimpleEntry<String, String>> getOperationProviderChannelPairs(final Properties p) {
    List<SimpleEntry<String, String>> list = new ArrayList<SimpleEntry<String, String>>();
    SimpleEntry<String, String> entry;
    String suffix;
    for (String key : p.stringPropertyNames()) {
        if (key != null
                && key.startsWith(RouterProperitesMojo.ROUTER_OPERATION_PROVIDER_OUTGOINGCHANNEL_NAME)) {
            entry = new SimpleEntry<String, String>(p.getProperty(key), "");
            suffix = key.substring(key.lastIndexOf('.'), key.length());
            for (String keyx : p.stringPropertyNames()) {
                if (keyx != null && keyx
                        .startsWith(RouterProperitesMojo.ROUTER_OPERATION_PROVIDER_INCOMINGCHANNEL_NAME)) {
                    if (keyx.endsWith(suffix)) {
                        entry.setValue(p.getProperty(keyx));
                        list.add(entry);
                        break;
                    }
                }
            }
        }
    }
    return list;
}

From source file:org.kuali.rice.core.impl.config.property.JAXBConfigImpl.java

protected void replaceVariables(String prefix, Properties properties) {
    SortedSet<String> keys = new TreeSet<String>(properties.stringPropertyNames());
    for (String key : keys) {
        String originalValue = properties.getProperty(key);
        String replacedValue = replaceVariable(key, originalValue);
        logPropertyChange("", key, null, originalValue, replacedValue);
        this.setProperty(prefix, key, replacedValue);
    }// w  w  w  .j a  v a2 s .co  m
}

From source file:gtu._work.ui.PropertyEditUI.java

void loadPropertiesToModel(Properties prop) {
    DefaultTableModel model = JTableUtil.createModel(false, "index", "key", "value");
    String value = null;//from w w w  .  j  ava 2  s.c  o m
    int index = 0;
    for (String key : prop.stringPropertyNames()) {
        value = prop.getProperty(key);
        model.addRow(new Object[] { index++, key, getChs2Big5(value) });
    }
    propTable.setModel(model);
}

From source file:org.callistasoftware.maven.plugins.propertyscanner.MyMojo.java

public void execute() throws MojoExecutionException {
    logger = getLog();/*ww w.  ja  v a2  s .c  om*/

    //load all properties
    Properties properties = loadProperties(logger);

    Set<String> allTokens = new HashSet<String>();
    //read all jsp files
    allTokens.addAll(scanJspFiles(logger));

    //read all java files
    allTokens.addAll(scanJavaFiles(logger));

    //verify that all tokens are present in properties files
    for (String token : allTokens) {
        if (!properties.containsKey(token)) {
            logger.warn("could not find translation for key: " + token);
        } else {
            properties.setProperty(token, PROPERTY_FOUND_FLAG);
        }
    }

    for (String key : properties.stringPropertyNames()) {
        if (properties.getProperty(key) != PROPERTY_FOUND_FLAG) {
            logger.warn("Unused property found, key:" + key + " and value:" + properties.getProperty(key));
        }
    }
}

From source file:org.opencastproject.capture.impl.ConfigurationManager.java

/**
 * Merges the given Properties with the ConfigurationManager's properties. Will not overwrite the ConfigurationManager
 * if specified./*w  ww. j ava2s.c om*/
 * 
 * @param p
 *          Properties object to be merged with ConfigurationManager.
 * @param overwrite
 *          true if this should overwrite the ConfigurationManager's properties, false if not.
 * @return the merged properties.
 */
public XProperties merge(Properties p, boolean overwrite) {
    // if no properties are specified, just return current configuration
    if (p == null) {
        return getAllProperties();
    }
    // overwrite the current properties in the ConfigurationManager
    if (overwrite) {
        for (String key : p.stringPropertyNames()) {
            properties.setProperty(key, p.getProperty(key));
        }
        return getAllProperties();
    }
    // do not overwrite the ConfigurationManager, but merge the properties
    else {
        XProperties merged = getAllProperties();
        for (String key : p.stringPropertyNames()) {
            String property = p.getProperty(key);
            if (property != null) {
                merged.setProperty(key, property);
            } else {
                logger.error("Unable to merge properties!");
                return null;
            }
        }
        return merged;
    }

}

From source file:org.polymap.core.security.DummyLoginModule.java

@SuppressWarnings("hiding")
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
    this.subject = subject;
    this.callbackHandler = callbackHandler;

    // default Authorization: DummyAuthorization
    this.authModule = new DummyAuthorizationModule();
    this.authModule.init(this);

    // check option for other Autorization
    AuthorizationModuleExtension authExt = AuthorizationModuleExtension.forOptions(options);
    if (authExt != null) {
        authModule = authExt.initialize(this, subject, callbackHandler, sharedState, options);
    }/*ww  w.  j  a  v  a  2  s .  co m*/

    // check user/passwd settings in options
    for (Object elm : options.entrySet()) {
        Map.Entry<String, String> option = (Map.Entry) elm;
        log.debug("option: key=" + option.getKey() + " = " + option.getValue());

        if (option.getKey().equals(OPTIONS_PROPS_FILE)) {
            // absolute path or in the workspace
            configFile = option.getValue().startsWith(File.pathSeparator) ? new File(option.getValue())
                    : new File(Polymap.getWorkspacePath().toFile(), option.getValue());
        } else if (option.getKey().equals("dialogTitle")) {
            dialogTitle = option.getValue();
        } else {
            String user = option.getKey();
            users.put(user, new DummyUserPrincipal(user, option.getValue()));
        }
    }

    // check loginConfig file
    if (configFile != null) {
        try {
            Properties props = new Properties();
            if (!configFile.exists()) {
                log.info("Creating default login config: " + configFile.getAbsolutePath());
                props.put("admin", "admin");
                props.store(new FileOutputStream(configFile), "DummyLoginModule config file.");
            } else {
                log.info("Loading login config: " + configFile.getAbsolutePath());
                props.load(new FileInputStream(configFile));
            }
            for (String user : props.stringPropertyNames()) {
                users.put(user, new DummyUserPrincipal(user, props.getProperty(user)));
            }
        } catch (Exception e) {
            throw new RuntimeException("Fehler beim Lesen/Schreiben: " + configFile.getAbsolutePath(), e);
        }
    }
}

From source file:org.teiid.jboss.rest.RestASMBasedWebArchiveBuilder.java

private String replaceTemplates(String orig, Properties replacements) {
    for (String key : replacements.stringPropertyNames()) {
        orig = StringUtil.replace(orig, key, replacements.getProperty(key));
    }/*from w  w w . jav  a 2 s  .c o m*/
    return orig;
}

From source file:com.facebook.LinkBench.LinkBenchDriverInj.java

LinkBenchDriverInj(String configfile, Properties overrideProps, String logFile)
        throws java.io.FileNotFoundException, IOException, LinkBenchConfigError {
    // which link store to use
    props = new Properties();
    props.load(new FileInputStream(configfile));
    for (String key : overrideProps.stringPropertyNames()) {
        props.setProperty(key, overrideProps.getProperty(key));
    }//from w ww  .j  a va 2 s  . co m

    loadWorkloadProps();

    ConfigUtil.setupLogging(props, logFile);

    logger.info("Config file: " + configfile);
    logger.info("Workload config file: " + workloadConfigFile);
}