Example usage for java.util Properties put

List of usage examples for java.util Properties put

Introduction

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

Prototype

@Override
    public synchronized Object put(Object key, Object value) 

Source Link

Usage

From source file:com.projity.strings.Messages.java

public static Properties getProperties(ResourceBundle bundle) {
    Properties properties = new Properties();

    for (Enumeration keys = bundle.getKeys(); keys.hasMoreElements();) {
        String key = (String) keys.nextElement();
        properties.put(key, bundle.getString(key));
    }/*from  w  w w .j  av a2s.  c o m*/
    return properties;
}

From source file:jp.co.golorp.emarf.sql.DataSources.java

/**
 * ?/*ww  w. j  a  v  a2 s. c  o  m*/
 *
 * @return DataSource
 */
public static DataSource get() {

    if (ds != null) {
        return ds;
    }

    /*
     * JNDI??
     */

    String name = BUNDLE.getString(DATA_SOURCE_NAME);
    try {
        Context context = new InitialContext();
        ds = (DataSource) context.lookup(name);
        return ds;
    } catch (NamingException e) {
        LOG.warn(e.getMessage());
    }

    /*
     * DBCP??
     */

    Properties properties = new Properties();
    Enumeration<String> keys = BUNDLE.getKeys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        String value = BUNDLE.getString(key);
        properties.put(key, value);
        // if (value.contains("mysql")) {
        // DataSources.isMySQL = true;
        // } else if (value.contains("oracle")) {
        // DataSources.isOracle = true;
        // }
    }

    try {
        ds = BasicDataSourceFactory.createDataSource(properties);
        return ds;
    } catch (Exception e) {
        throw new SystemError(e);
    }
}

From source file:info.magnolia.importexport.PropertiesImportExport.java

private static void addBooleanProeprty(Properties out, String path, boolean prop) {
    out.put(path, convertBooleanToExportString(prop));
}

From source file:com.squid.kraken.v4.auth.KrakenClientConfig.java

private static void load(InputStream in, Properties target) {
    Properties properties = new Properties();
    try {// w w w . j  av a  2s. co  m
        properties.loadFromXML(in);
        for (Object key : properties.keySet()) {
            Object value = properties.get(key);
            target.put(key, value);
            logger.debug(key + ":" + value);
        }
    } catch (Exception e) {
        logger.warn("Could not load Kraken config file for stream : " + in, e);
    }

}

From source file:gov.nih.nci.firebird.service.messages.TemplateServiceImplTest.java

private static VelocityEngine getVelocity() {
    VelocityEngine velocity = new VelocityEngine();
    Properties props = new Properties();
    props.put("resource.loader", "class");
    props.put("class.resource.loader.class", ClasspathResourceLoader.class.getName());
    props.put("class.resource.loader.cache", "true");
    props.put("class.resource.loader.modificationCheckInterval", "2");
    props.put("runtime.log", "target/test-log/velocity.log");
    velocity.init(props);//from  w ww  .j  a  va2s.  c om
    return velocity;
}

From source file:com.hypersocket.i18n.I18N.java

public static void overrideMessage(Locale locale, Message message) {

    File overrideFile = getOverrideFile(locale, message.getBundle());
    if (!overideProperties.containsKey(overrideFile)) {
        overideProperties.put(overrideFile, new Properties());

        if (overrideFile.exists()) {
            Properties p = overideProperties.get(overrideFile);
            InputStream in = null;
            try {
                in = new FileInputStream(overrideFile);
                p.load(in);/*from w ww. j  a  v  a2  s.  co  m*/
            } catch (IOException e) {
            } finally {
                IOUtils.closeQuietly(in);
            }
        }
    }

    Properties properties = overideProperties.get(overrideFile);
    properties.put(message.getId(), message.getTranslated());

}

From source file:dk.hippogrif.prettyxml.Main.java

static Properties getProperties(CommandLine cmd) throws Exception {
    Properties prop = new Properties();
    if (cmd.hasOption("p")) {
        prop = PrettyPrint.loadProperties(new File(cmd.getOptionValue("p")));
    } else {//from w  w  w  . j a va 2 s.  c o m
        // default Pretty format
        prop.put("indent", "2");
        prop.put("textMode", "TRIM");
    }
    if (cmd.hasOption("n")) {
        prop.put("indent", cmd.getOptionValue("n"));
    }
    if (cmd.hasOption("a")) {
        prop.put("indentAttributes", "TRUE");
    }
    if (cmd.hasOption("s")) {
        prop.put("sortAttributes", "TRUE");
    }
    if (cmd.hasOption("t")) {
        prop.put("transform", cmd.getOptionValue("t"));
    }
    if (cmd.hasOption("i")) {
        prop.put("input", cmd.getOptionValue("i"));
    }
    if (cmd.hasOption("o")) {
        prop.put("output", cmd.getOptionValue("o"));
    }
    if (cmd.hasOption("u")) {
        prop.put("url", cmd.getOptionValue("u"));
    }
    PrettyPrint.checkProperties(prop);
    return prop;
}

From source file:com.qubole.quark.planner.test.SchemaTest.java

@BeforeClass
public static void setUpClass() throws Exception {
    Properties info = new Properties();
    info.put("unitTestMode", "true");
    info.put("schemaFactory", "com.qubole.quark.planner.test.SchemaTest$SchemaFactory");
    info.put("materializationsEnabled", "true");

    info.put("defaultSchema", QuarkTestUtil.toJson("DEFAULT"));

    log.info(info.getProperty("defaultSchema"));
    parser = new SqlQueryParser(info);
}

From source file:edu.umich.ctools.sectionsUtilityTool.Friend.java

public static void notifyCurrentUser(String instructorName, String instructorEmail, String inviteEmail) {

    M_log.debug("Friend notifyCurrentUser() called");
    String to = instructorEmail;//from   w w  w  .  ja v  a  2s.c  o m
    String from = contactEmail;
    String host = mailHost;

    M_log.info("Setting up mailProps");

    Properties properties = System.getProperties();
    properties.put(MAIL_SMTP_AUTH, "false");
    properties.put(MAIL_SMTP_STARTTLS, "true"); //Put to false, if no https is needed
    properties.put(MAIL_SMTP_HOST, host);
    properties.put(MAIL_DEBUG, "true");

    M_log.debug("Initiating Session for sendMail");
    Session session = Session.getInstance(properties);

    try {

        HashMap<String, String> map = new HashMap<String, String>();

        map.put("<instructor>", instructorName);
        map.put("<friend>", inviteEmail);

        emailMessage = Friend.readFile(requesterEmailFile, StandardCharsets.UTF_8);
        emailMessage = replacePlaceHolders(emailMessage, map);

        M_log.debug("Setting up message for sendMail");
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(from));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject(subjectLine);

        message.setText(emailMessage);

        M_log.info("Sending message");
        Transport.send(message);

        M_log.info("Message sent to " + instructorName);

    } catch (Exception e) {
        M_log.error("notifyCurrentUser exception: " + e.getMessage());
    }
}

From source file:edu.kit.dama.staging.util.TransferClientPropertiesUtils.java

/**
 * Helper method to convert TransferClientProperties object to a properties
 * object. This is needed e.g. to store the properties for later use.
 *
 * @param pProperties A TransferClientProperties object.
 *
 * @return A properties object containing all properties of pProperties.
 *//*from   w w w.  j  ava 2 s . c o m*/
public static Properties propertiesToProperties(TransferClientProperties pProperties) {
    Map<String, String> result = propertiesToMap(pProperties);

    Properties props = new Properties();

    Set<Entry<String, String>> values = result.entrySet();
    for (Entry<String, String> value : values) {
        if (value != null && value.getKey() != null && value.getValue() != null) {
            props.put(value.getKey(), value.getValue());
        }
    }
    return props;
}