Example usage for java.util Properties setProperty

List of usage examples for java.util Properties setProperty

Introduction

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

Prototype

public synchronized Object setProperty(String key, String value) 

Source Link

Document

Calls the Hashtable method put .

Usage

From source file:com.rpgsheet.xcom.state.SelectLanguageState.java

private static void updateLanguageProperty(Language language) {
    Properties appProps = PimpMyXcom.loadApplicationProperties();
    appProps.setProperty("xcom.lang", language.name());
    try {/*from www.  j  ava  2s .  com*/
        PimpMyXcom.saveApplicationProperties(appProps);
    } catch (IOException e) {
        e.printStackTrace(System.err);
    }
}

From source file:com.edgenius.core.DataRoot.java

/**
 * @param root/*from  ww w . ja  v a2s  . c om*/
 * @return 
 */
public static String saveDataRoot(String root) {

    if (StringUtils.isBlank(root)) {
        log.error("Unable to save blank root:" + root);
        return root;
    }

    String sysRoot = System.getProperty(rootKey);
    if (sysRoot != null && sysRoot.trim().length() > 0) {
        log.warn("User set {} in System properties, the persisted system root won't be saved."
                + " User must ensure the consist while restarting the system", rootKey);
        return formatRoot(sysRoot);
    }

    root = formatRoot(root);
    FileOutputStream out = null;
    try {

        Properties prop = new Properties();
        prop.setProperty(rootKey, root);
        out = FileUtil.getFileOutputStream(rootResource);
        prop.store(out,
                "IMPORTANT: The directory must start with file:// and end with /. The path separator is /.");
        log.info("Classpath geniuswiki properties file is saved.");
    } catch (Exception e) {
        log.error("Save system root failed.", e);
    } finally {
        IOUtils.closeQuietly(out);
    }

    return root;
}

From source file:it.infn.ct.futuregateway.apiserver.inframanager.Utilities.java

/**
 * Convert a Params list in a properties object.
 *
 * @param params The Params to convert// w  ww.ja v  a 2s  . c  o m
 * @param properties The Properties where the parameters will be added
 * @return The Properties containing the parameters
 */
public static Properties convertParamsToProperties(final List<Params> params, final Properties properties) {
    Properties pr = properties;
    for (Params par : params) {
        Object previous = pr.setProperty(par.getName(), par.getValue());
        if (previous != null) {
            pr.setProperty(par.getName(), previous + "," + par.getValue());
        }
    }
    return pr;
}

From source file:org.pivotal.sqlfire.HibernateTransactionalBatchInsertsTest.java

protected static Properties createHibernateConfigurationSettings() {
    Properties hibernateConfigurationSettings = new Properties();

    hibernateConfigurationSettings.setProperty("hibernate.dialect",
            "com.vmware.sqlfire.hibernate.SQLFireDialect");
    hibernateConfigurationSettings.setProperty("hibernate.show_sql", "true");
    hibernateConfigurationSettings.setProperty("hibernate.cache.provider_class",
            "org.hibernate.cache.NoCacheProvider");
    //hibernateConfigurationSettings.setProperty("hibernate.connection.autocommit", "false");
    hibernateConfigurationSettings.setProperty("hibernate.connection.isolation",
            String.valueOf(Connection.TRANSACTION_READ_COMMITTED));
    hibernateConfigurationSettings.setProperty("hibernate.connection.driver_class",
            "com.vmware.sqlfire.jdbc.ClientDriver");
    hibernateConfigurationSettings.setProperty("hibernate.connection.url", "jdbc:sqlfire://localhost:1529/");
    hibernateConfigurationSettings.setProperty("hibernate.connection.username", "app");
    hibernateConfigurationSettings.setProperty("hibernate.connection.password", "app");
    hibernateConfigurationSettings.setProperty("hibernate.connection.pool_size", "1");
    hibernateConfigurationSettings.setProperty("hibernate.hbm2ddl.auto", "update");
    hibernateConfigurationSettings.setProperty("hibernate.hbm2ddl.import_files",
            "/data/source/schema/create-user-table.sqlf.ddl.sql");

    return hibernateConfigurationSettings;
}

From source file:org.apache.geode.geospatial.utils.ToolBox.java

public static Properties testAndSetProperty(Properties properties, String property, String value) {
    if (properties != null && StringUtils.hasText(value)) {
        properties.setProperty(property, value);
    }//from   w ww . ja  v  a 2  s  .  c  o m
    return properties;
}

From source file:com.smartitengineering.dao.hbase.ddl.TableGenerationTest.java

@BeforeClass
public static void globalSetup() throws Exception {
    /*/*from  ww w.  j  av a  2  s.  c o  m*/
     * Start HBase and initialize tables
     */
    //-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
            "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
    try {
        TEST_UTIL.startMiniCluster();
    } catch (Exception ex) {
        LOGGER.error(ex.getMessage(), ex);
    }

    Properties properties = new Properties();
    properties.setProperty(GuiceUtil.CONTEXT_NAME_PROP, "com.smartitengineering.dao.impl.hbase");
    properties.setProperty(GuiceUtil.IGNORE_MISSING_DEP_PROP, Boolean.TRUE.toString());
    properties.setProperty(GuiceUtil.MODULES_LIST_PROP, TestModule.class.getName());
    GuiceUtil.getInstance(properties).register();
}

From source file:Main.java

/**
 * Creates an Properties object initialized with the value from the given Map.
 * <p>//from   w w w. j a  v  a2s.  c  o  m
 * @param map the Map supply the keys and value for the Properties object.
 * @return a Properties object initialized with the key and value from the Map.
 * @see java.util.Map
 * @see java.util.Properties
 */
public static Properties createProperties(final Map<String, String> map) {
    Properties properties = new Properties();

    if (!(map == null || map.isEmpty())) {
        for (Entry<String, String> entry : map.entrySet()) {
            properties.setProperty(entry.getKey(), entry.getValue());
        }
    }

    return properties;
}

From source file:com.cloudera.recordservice.hcatalog.common.HCatRSUtil.java

public static Map<String, String> getInputJobProperties(HiveStorageHandler storageHandler,
        InputJobInfo inputJobInfo) {//  w ww  .  j a  v  a2  s . c o m
    Properties props = inputJobInfo.getTableInfo().getStorerInfo().getProperties();
    props.put(serdeConstants.SERIALIZATION_LIB, storageHandler.getSerDeClass().getName());
    TableDesc tableDesc = new TableDesc(storageHandler.getInputFormatClass(),
            storageHandler.getOutputFormatClass(), props);
    if (tableDesc.getJobProperties() == null) {
        tableDesc.setJobProperties(new HashMap<String, String>());
    }

    Properties mytableProperties = tableDesc.getProperties();
    mytableProperties.setProperty(org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.META_TABLE_NAME,
            inputJobInfo.getDatabaseName() + "." + inputJobInfo.getTableName());

    Map<String, String> jobProperties = new HashMap<String, String>();
    try {
        tableDesc.getJobProperties().put(HCatConstants.HCAT_KEY_JOB_INFO, HCatRSUtil.serialize(inputJobInfo));

        storageHandler.configureInputJobProperties(tableDesc, jobProperties);
    } catch (IOException e) {
        throw new IllegalStateException("Failed to configure StorageHandler", e);
    }

    return jobProperties;
}

From source file:Main.java

public static Properties toProperties(Iterable<Map.Entry<String, String>> propSrc) {
    Properties props = new Properties();
    for (Map.Entry<String, String> entry : propSrc) {
        String name = entry.getKey();
        String val = entry.getValue();
        props.setProperty(name, val);
    }/*w  w w  .j  a  v  a2  s.  co m*/
    return props;
}

From source file:Main.java

/**
 * return a properties with the values passed as params
 * /*from  w w w.  j a va2s  .c om*/
 * @param strKeys the keys to insert into the pr
 * @param strValues the values to insert into the pr
 * @return
 */
public static Properties loadProperties(String[] strKeys, String[] strValues) {

    // checks the params
    if (strKeys == null || strValues == null)
        return null;

    // inits the PR
    Properties pr = new Properties();

    // cycles on keys
    for (int j = 0; j < strKeys.length; j++) {

        // insert the j-th key into the properties
        pr.setProperty(strKeys[j], strValues[j]);
    }

    // and returns it
    return pr;
}