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.anjlab.sat3.Program.java

private static void writeToStatistics(ITabularFormula formula, Properties statistics, int varName,
        boolean varValue) {
    String stringValue = String.valueOf(varValue);
    statistics.put("_" + varName, stringValue);

    int originalVarName = formula.getOriginalVarName(varName);
    if (originalVarName > 0) {
        statistics.put(String.valueOf(originalVarName), stringValue);
    }/*from   ww w . j a va  2s. c om*/
}

From source file:mx.itesm.imb.ImbOperationsImpl.java

public static Template getVelocityTemplate() throws Exception {
    Template returnValue;/*from w  w w . ja va 2s  .co  m*/
    Properties velocityProperties;

    // TODO: Change to class-path search:.
    velocityProperties = new Properties();
    velocityProperties.put("resource.loader", "file");
    velocityProperties.put("file.resource.loader.class",
            "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
    velocityProperties.put("file.resource.loader.path",
            "/Users/jccastrejon/java/workspace_IMB/InstanceModelBus.Roo/src/main/resources");
    velocityProperties.put("file.resource.loader.cache", "true");
    Velocity.init(velocityProperties);

    returnValue = Velocity.getTemplate("ImbAspect.vml");
    return returnValue;
}

From source file:edu.ku.brc.util.XMLChecksumUtil.java

/**
 * Fills in the properties with a relative path name and the checksum.
 * @param checksumProps the properties that will hold all the checksums
 * @param files the files to be checksumed
 * @throws IOException//  w  w  w . j  a va  2s  .co  m
 */
protected static void createChecksumProps(final Properties checksumProps, final File[] files)
        throws IOException {
    for (File file : files) {
        String relativeName = getRelativeName(file);
        if (StringUtils.isNotEmpty(relativeName)) {
            String checksumStr = checksumProps.getProperty(relativeName);
            if (StringUtils.isEmpty(checksumStr)) {
                checksumProps.put(relativeName, Long.toString(checksumCRC32(file)));

            } else {
                throw new RuntimeException("Duplicate checksum name [" + relativeName + "]");
            }
        } else {
            throw new RuntimeException(
                    "The file isn't in the config directory [" + file.getAbsolutePath() + "]");
        }
    }
}

From source file:com.streamsets.pipeline.kafka.common.KafkaTestUtil.java

public static Producer<String, String> createProducer(String metadataBrokerURI, boolean setPartitioner) {
    Properties props = new Properties();
    props.put("metadata.broker.list", metadataBrokerURI);
    props.put("serializer.class", "kafka.serializer.StringEncoder");
    if (setPartitioner) {
        props.put("partitioner.class", "com.streamsets.pipeline.kafka.impl.ExpressionPartitioner");
    }//ww  w .  j ava  2 s  . co m
    props.put("request.required.acks", "1");
    ProducerConfig config = new ProducerConfig(props);

    Producer<String, String> producer = new Producer<>(config);
    return producer;
}

From source file:com.streamsets.pipeline.lib.KafkaTestUtil.java

public static Producer<String, String> createProducer(String metadataBrokerURI, boolean setPartitioner) {
    Properties props = new Properties();
    props.put("metadata.broker.list", metadataBrokerURI);
    props.put("serializer.class", "kafka.serializer.StringEncoder");
    if (setPartitioner) {
        props.put("partitioner.class", "com.streamsets.pipeline.lib.ExpressionPartitioner");
    }/*from  w w w.  j  ava2  s.c  o m*/
    props.put("request.required.acks", "1");
    ProducerConfig config = new ProducerConfig(props);

    Producer<String, String> producer = new Producer<>(config);
    return producer;
}

From source file:jp.mamesoft.mailsocketchat.Mail.java

public static void Send(String to, int mode) {
    //mode 0 = ?, 1 = ?, 2 = ?, 3 = ??, 4 = , 5 = 
    System.out.println("???");
    String from = Mailsocketchat.mail_user;
    String host = "smtp.gmail.com";
    String port = "465";
    String text = "";
    String subject = "";
    if (mode == 0) {
        text = logprint(text);/* w  w w. j  av a2  s .c o m*/
        subject = " - MailSocketChat";
        if (Mailsocketchat.newver) {
            text = text + "\n\n??????????\n";
        }
    }
    if (mode == 1) {
        if (Mailsocketchat.subjectname) {
            subject = Mailsocketchat.logs.get(0).get("name");
        } else {
            subject = "?? - MailSocketChat";
        }
        text = logprint(text);
    }
    if (mode == 8) {
        text = logprint(text);
        subject = "?? - MailSocketChat";
    }
    if (mode == 2) {

        if (!Mailsocketchat.push) {
            subject = "????? - MailSocketChat";
            text = "???????????????????\n\n??????\n";
            text = logprint(text);
        } else {
            subject = "??? - MailSocketChat";
            text = "?????????????????\n(???????????)\n\n";
        }
        if (Mailsocketchat.newver) {
            text = text + "\n\n??????????\n";
        }
    }
    if (mode == 3) {

        if (!Mailsocketchat.push && !Mailsocketchat.repeat) {
            subject = "???? - MailSocketChat";
            text = "????\n\n??????\n";
            text = logprint(text);
        } else {
            subject = "?????? - MailSocketChat";
            text = "?????????????????\n\n";
            if (Mailsocketchat.repeat) {
                text = text + "??????\n";
                text = logprint(text);
            }
        }
        if (Mailsocketchat.newver) {
            text = text + "\n\n??????????\n";
        }
    }

    if (mode == 7) {

        if (!Mailsocketchat.repeat) {
            subject = "????? - MailSocketChat";
            text = "?????30????????????\n\n";
            if (!Mailsocketchat.push) {
                text = text + "??????\n";
                text = logprint(text);
            }
        } else {
            subject = "??? - MailSocketChat";
            text = "???\n\n";
        }
        if (Mailsocketchat.newver) {
            text = text + "\n\n??????????\n";
        }
    }

    if (mode == 4) {
        subject = " - MailSocketChat";

        int userint = Mailsocketchat.users.size();
        int romint = Mailsocketchat.roms.size();
        text = ": " + userint + " ROM: " + romint + "\n\n\n";

        for (Integer id : Mailsocketchat.users.keySet()) {
            HashMap<String, String> data = Mailsocketchat.users.get(id);
            text = text + data.get("name") + "\n";
            text = text + " (" + data.get("ip") + ")\n";
        }

        text = text + "\n\nROM\n";
        for (Integer id : Mailsocketchat.roms.keySet()) {
            HashMap<String, String> data = Mailsocketchat.roms.get(id);
            text = text + data.get("ip") + "\n";
        }
        if (Mailsocketchat.newver) {
            text = text + "\n\n??????????\n";
        }
    }
    if (mode == 5) {
        subject = " - MailSocketChat";
        if (Mailsocketchat.push) {
            text = "??: \n\n";
        } else if (Mailsocketchat.repeat) {
            text = "??: \n\n";
        } else {
            text = "??: ?\n\n";
        }
        text = text + "?\n";
        text = text + "?(fetch): ?????\n";
        text = text + "(push): ????\n";
        text = text + "(repeat): ????\n";
        text = text + "(list): ???\n";
        text = text + "#: ?????\n";
        text = text + "#hoge: ??hoge????\n";
        text = text + "(help): ?????\n\n";

        text = text + "\nMailSocketChat Ver." + Mailsocketchat.version + "\n";
        if (Mailsocketchat.newver) {
            text = text + "??????????\n";
        }
    }
    if (mode == 6) {
        subject = "????????? - MailSocketChat";
        text = text
                + "MailSocketChat??????????????????\n";
    }

    // create some properties and get the default Session
    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.transport.protocol", "smtps");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.socketFactory.fallback", "false");
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.port", port);

    Session sendsession = Session.getInstance(props,
            new PlainAuthenticator(Mailsocketchat.mail_user, Mailsocketchat.mail_pass));

    try {
        // create a message
        MimeMessage msg = new MimeMessage(sendsession);
        msg.setFrom(new InternetAddress(from));
        InternetAddress[] sendaddress = { new InternetAddress(to) };
        msg.setRecipients(Message.RecipientType.TO, sendaddress);
        msg.setSubject(subject);
        msg.setSentDate(new Date());
        // If the desired charset is known, you can use
        // setText(text, charset)
        msg.setText(text);

        Transport.send(msg);
        System.out.println("?????");
    } catch (MessagingException mex) {
        System.out.println("??????");
    }
}

From source file:com.jkoolcloud.tnt4j.streams.custom.kafka.interceptors.reporters.trace.MsgTraceReporter.java

protected static Properties extractKafkaProperties(Properties kafkaProperties) {
    Properties props = new Properties();
    for (String key : kafkaProperties.stringPropertyNames()) {
        if (key.startsWith(TRACER_PROPERTY_PREFIX)) {
            props.put(key.substring(TRACER_PROPERTY_PREFIX.length()), kafkaProperties.getProperty(key));
        }/*from  w  w w . j  a v a2s. c o m*/
    }
    return props;
}

From source file:org.apache.lens.regression.util.Util.java

public static void remoteFile(String function, String remotePath, String localPath)
        throws JSchException, SftpException {

    String serverUrl = getProperty("lens.remote.host");
    String serverUname = getProperty("lens.remote.username");
    String serverPass = getProperty("lens.remote.password");

    JSch jsch = new JSch();
    Session session = jsch.getSession(serverUname, serverUrl);

    UserInfo ui = null;//from  w  ww. j av a  2  s. c  om
    session.setUserInfo(ui);
    session.setPassword(serverPass);

    Properties config = new Properties();
    config.put("StrictHostKeyChecking", "no");
    session.setConfig(config);
    session.connect();

    Channel channel = session.openChannel("sftp");
    channel.connect();

    ChannelSftp sftpChannel = (ChannelSftp) channel;
    if (function.equals("get")) {
        sftpChannel.get(remotePath, localPath);
    } else if (function.equals("put")) {
        sftpChannel.put(localPath, remotePath);
    }
    sftpChannel.exit();
    session.disconnect();

}

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

static Properties getProperties(CommandLine cmd) throws Exception {
    Properties prop = new Properties();
    if (cmd.hasOption("p")) {
        String pname = cmd.getOptionValue("p");
        prop = PrettyPrint.getSetting(pname);
        if (prop == null) {
            prop = PrettyPrint.loadProperties(new File(pname));
        }// w w  w .  j  a  va 2 s .  c  om
    } else {
        // default Pretty format
        prop.put(PrettyPrint.INDENT, "2");
        prop.put(PrettyPrint.TEXT_MODE, "TRIM");
    }
    if (cmd.hasOption("n")) {
        prop.put(PrettyPrint.INDENT, cmd.getOptionValue("n"));
    }
    if (cmd.hasOption("a")) {
        prop.put(PrettyPrint.INDENT_ATTRIBUTES, "TRUE");
    }
    if (cmd.hasOption("s")) {
        prop.put(PrettyPrint.SORT_ATTRIBUTES, "TRUE");
    }
    if (cmd.hasOption("t")) {
        prop.put(PrettyPrint.TRANSFORM, cmd.getOptionValue("t"));
    }
    if (cmd.hasOption("i")) {
        prop.put(PrettyPrint.INPUT, cmd.getOptionValue("i"));
    }
    if (cmd.hasOption("o")) {
        prop.put(PrettyPrint.OUTPUT, cmd.getOptionValue("o"));
    }
    if (cmd.hasOption("u")) {
        prop.put(PrettyPrint.URL, cmd.getOptionValue("u"));
    }
    PrettyPrint.checkProperties(prop, true);
    return prop;
}

From source file:it.geosolutions.geobatch.destination.common.utils.RemoteBrowserUtils.java

/**
 * SFTP protocol ls/* w  ww.  j a v a2  s  . c  o m*/
 * 
 * @param userName
 * @param password
 * @param host
 * @param port
 * @param path
 * @param timeout
 * @param pattern
 * @return name of files or directories inside the remote folder
 * @throws IOException
 * @throws FTPException
 * @throws ParseException
 */
private static List<String> sftpLS(String userName, String password, String host, int port, String path,
        int timeout, Pattern pattern) throws IOException {

    //TODO: use pattern
    Session session = null;
    Channel channel = null;
    ChannelSftp sftpChannel = null;
    List<String> names = new LinkedList<String>();

    try {
        JSch jsch = new JSch();
        session = jsch.getSession(userName, host, port);
        session.setPassword(password);
        java.util.Properties config = new java.util.Properties();
        config.put("StrictHostKeyChecking", "no");
        session.setConfig(config);
        session.connect();
        channel = session.openChannel(RemoteBrowserProtocol.sftp.name());
        channel.connect();
        sftpChannel = (ChannelSftp) channel;
        sftpChannel.cd(path);
        @SuppressWarnings("unchecked")
        Vector<LsEntry> filelist = sftpChannel.ls(path);
        for (int i = 0; i < filelist.size(); i++) {
            String fileName = filelist.get(i).getFilename();
            if (pattern != null) {
                Matcher m = pattern.matcher(fileName);
                if (m.matches()) {
                    names.add(fileName);
                }
            } else {
                if (!fileName.equals(".") && !fileName.equals("..")) {
                    names.add(fileName);
                }
            }
        }

    } catch (Exception e) {
        throw new IOException("Error on ls", e);
    } finally {
        if (sftpChannel != null) {
            sftpChannel.exit();
        }
        if (session != null) {
            session.disconnect();
        }
    }

    return names;
}