Example usage for java.lang String toString

List of usage examples for java.lang String toString

Introduction

In this page you can find the example usage for java.lang String toString.

Prototype

public String toString() 

Source Link

Document

This object (which is already a string!) is itself returned.

Usage

From source file:com.noterik.bart.fs.fscommand.dynamic.presentation.playout.cache.java

public static void signal(String adr, String method, String msg) {
    if (multicast) {
        switch (methods.valueOf(method)) {
        case POST:
            CacheMulticastSender.send(adr.toString(), method, msg);
            break;
        case PUT:
            CacheMulticastSender.send(adr.toString(), method, msg);
            break;
        case DELETE:
            CacheMulticastSender.send(adr.toString(), method, msg);
            break;
        case TRACE:
            break;
        case LINK:
            CacheMulticastSender.send(adr.toString(), method, msg);
            break;
        }/* ww  w . j  ava2s  . c  o  m*/
    } else {
        switch (methods.valueOf(method)) {
        case POST:
            signalPost(adr, msg);
            break;
        case PUT:
            signalPut(adr, msg);
            break;
        case DELETE:
            signalDelete(adr, msg);
            break;
        case TRACE:
            break;
        }
    }
}

From source file:jp.primecloud.auto.tool.management.main.ZabbixMain.java

public static void updateExecute(CommandLine commandLine) {
    String username = commandLine.getOptionValue("username");
    String password = commandLine.getOptionValue("password");

    //Zabbix?API/*from   w  ww .j a v  a 2s  . c o m*/
    try {
        ZabbixScriptService zabbixScriptService = new ZabbixScriptService();
        List<User> users = zabbixScriptService.getUsers();
        String userid = "";
        for (User user : users) {
            if (user.getAlias().equals(username.toString())) {
                userid = user.getUserid();
            }
        }
        if (StringUtils.isEmpty(userid)) {
            System.out.println(username + "?Zabbix????");
            log.error(username + "?Zabbix????");
            return;
        } else {
            zabbixScriptService.updateUser(userid, password);
        }
        log.info(username + " ?????");

    } catch (Exception e) {
        log.error(username + " ??????", e);
        System.out.println(username + " ??????");
    }

}

From source file:com.memetix.gun4j.expand.UrlExpander.java

public static String expand(final String shortUrl) throws Exception {
    if (shortUrl != null) {
        final StringBuilder sb = new StringBuilder();
        sb.append(PARAM_NAME);//from  w ww .  j a  v  a  2s  .  com
        sb.append(EQUALS);
        sb.append(URLEncoder.encode(shortUrl, ENCODING));

        Map<String, String> results = parseResponse(post(SERVICE_URL, sb.toString()));

        if (results.containsKey(shortUrl))
            return results.get(shortUrl);
        else
            return shortUrl.toString();
    } else {
        return null;
    }
}

From source file:com.me.edu.Servlet.ElasticSearch_Backup.java

public static String getSentence(String input) {
    String paragraph = input;/*from   w ww.ja v  a 2 s  . c  o  m*/
    Reader reader = new StringReader(paragraph);
    DocumentPreprocessor dp = new DocumentPreprocessor(reader);
    List<String> sentenceList = new ArrayList<String>();

    for (List<HasWord> sentence : dp) {
        String sentenceString = Sentence.listToString(sentence);
        sentenceList.add(sentenceString.toString());
    }
    String sent = "";
    for (String sentence : sentenceList) {
        System.out.println(sentence);
        sent = sent + " " + sentence + "\n";
    }
    try {

        FileWriter file = new FileWriter("Sentences.txt");
        file.write(sent.toString());
        file.flush();
        file.close();

    } catch (IOException e) {
        e.printStackTrace();
    }
    return sent;
}

From source file:edu.gmu.csiss.automation.pacs.utils.BaseTool.java

/**
 * send a HTTP POST request//from   w  w w . jav  a  2s .co  m
 * @param param
 * @param input_url
 * @return
 */
public static String POST(String param, String input_url) {
    try {
        URL url = new URL(input_url);
        HttpURLConnection con = (HttpURLConnection) url.openConnection();
        con.setDoOutput(true);
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type", "application/xml");
        con.setDoOutput(true);
        con.setDoInput(true);
        con.setUseCaches(false);

        PrintWriter xmlOut = new PrintWriter(con.getOutputStream());
        xmlOut.write(param);
        xmlOut.flush();
        BufferedReader response = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String result = "";
        String line;
        while ((line = response.readLine()) != null) {
            result += "\n" + line;
        }
        return result.toString();
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static String getValuePhoto(String value, int heightImage, int widthImage) {
    if (value != null) {
        if (!value.equals("")) {
            int indexHeight = value.indexOf("height");
            int indexWidth = value.indexOf("width");
            if (indexHeight < 0 && indexWidth < 0) {
                return value.replaceAll(">",
                        " height=\"" + heightImage + "\"" + " width=\"" + widthImage + "\"" + " >");
            } else {
                if (indexHeight < indexWidth) {
                    return value.toString().replace(
                            value.toString().substring(value.toString().indexOf("height"),
                                    value.toString().indexOf(">")),
                            " height=\"" + heightImage + "\"" + " width=\"" + widthImage + "\"" + " ");
                } else {
                    return value.toString().replace(
                            value.toString().substring(value.toString().indexOf("width"),
                                    value.toString().indexOf(">")),
                            " height=\"" + heightImage + "\"" + " width=\"" + widthImage + "\"" + " ");
                }//from ww w .  java  2s .co  m
            }
        } else {
            return "";
        }
    } else {
        return "";
    }
}

From source file:com.espertech.esper.core.deploy.EPLModuleUtil.java

public static Module parseInternal(String buffer, String resourceName) throws IOException, ParseException {

    List<EPLModuleParseItem> semicolonSegments = EPLModuleUtil.parse(buffer.toString());
    List<ParseNode> nodes = new ArrayList<ParseNode>();
    for (EPLModuleParseItem segment : semicolonSegments) {
        nodes.add(EPLModuleUtil.getModule(segment, resourceName));
    }/*ww  w . j a va2 s . c o m*/

    String moduleName = null;
    int count = 0;
    for (ParseNode node : nodes) {
        if (node instanceof ParseNodeComment) {
            continue;
        }
        if (node instanceof ParseNodeModule) {
            if (moduleName != null) {
                throw new ParseException(
                        "Duplicate use of the 'module' keyword for resource '" + resourceName + "'");
            }
            if (count > 0) {
                throw new ParseException(
                        "The 'module' keyword must be the first declaration in the module file for resource '"
                                + resourceName + "'");
            }
            moduleName = ((ParseNodeModule) node).getModuleName();
        }
        count++;
    }

    Set<String> uses = new LinkedHashSet<String>();
    Set<String> imports = new LinkedHashSet<String>();
    count = 0;
    for (ParseNode node : nodes) {
        if ((node instanceof ParseNodeComment) || (node instanceof ParseNodeModule)) {
            continue;
        }
        String message = "The 'uses' and 'import' keywords must be the first declaration in the module file or follow the 'module' declaration";
        if (node instanceof ParseNodeUses) {
            if (count > 0) {
                throw new ParseException(message);
            }
            uses.add(((ParseNodeUses) node).getUses());
            continue;
        }
        if (node instanceof ParseNodeImport) {
            if (count > 0) {
                throw new ParseException(message);
            }
            imports.add(((ParseNodeImport) node).getImported());
            continue;
        }
        count++;
    }

    List<ModuleItem> items = new ArrayList<ModuleItem>();
    for (ParseNode node : nodes) {
        if ((node instanceof ParseNodeComment) || (node instanceof ParseNodeExpression)) {
            boolean isComments = (node instanceof ParseNodeComment);
            items.add(new ModuleItem(node.getItem().getExpression(), isComments, node.getItem().getLineNum(),
                    node.getItem().getStartChar(), node.getItem().getEndChar()));
        }
    }

    return new Module(moduleName, resourceName, uses, imports, items, buffer);
}

From source file:eu.musesproject.server.contextdatareceiver.formatting.EventFormatter.java

public static FileObserverEvent convertToFileObserverEvent(ContextEvent contextEvent, String action) {
    FileObserverEvent cepFileEvent = new FileObserverEvent();
    Map<String, String> properties = contextEvent.getProperties();

    cepFileEvent.setEvent(action.toString());
    if (properties.get("id") != null) {//TODO Changes for System test
        cepFileEvent.setId(Integer.valueOf(properties.get("id")));
    }//from w w  w  . j a  v  a  2  s.c  o  m
    cepFileEvent.setType(EventTypes.FILEOBSERVER);
    cepFileEvent.setPath(properties.get("path"));
    cepFileEvent.setTimestamp(contextEvent.getTimestamp());
    cepFileEvent.setUid(properties.get("id"));
    return cepFileEvent;
}

From source file:com.vaadin.tools.ReportUsage.java

private static String makeUserAgent() {
    String userAgent = USER_AGENT_BASE;
    StringBuilder extra = new StringBuilder();
    appendUserAgentProperty(extra, "java.vendor");
    appendUserAgentProperty(extra, "java.version");
    appendUserAgentProperty(extra, "os.arch");
    appendUserAgentProperty(extra, "os.name");
    appendUserAgentProperty(extra, "os.version");

    if (extra.length() > 0) {
        userAgent += " (" + extra.toString() + ")";
    }/*from w  ww  .j a  v a  2 s .com*/

    return userAgent.toString();
}

From source file:com.world.watch.worldwatchcron.util.PushToUser.java

public static void push(List<String> data, String userId) {
    try {/*w  w w  . j  a  v  a  2  s.  co  m*/
        InputStream jsonStream = PushToUser.class.getResourceAsStream("/parsePush.json");
        ObjectMapper mapper = new ObjectMapper();
        PushData push = mapper.readValue(jsonStream, PushData.class);
        push.getWhere().setUsername(userId);
        push.getData().setKeywords(data);
        String json = mapper.writeValueAsString(push);

        HttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(RequestConfig.custom().build())
                .build();
        HttpPost post = new HttpPost(URL);
        post.setHeader("X-Parse-Application-Id", "WhqWj009luOxOtIH3rM9iWJICLdf0NKbgqdaui8Q");
        post.setHeader("X-Parse-REST-API-Key", "lThhKObAz1Tkt092Cl1HeZv4KLUsdATvscOaGN2y");
        post.setHeader("Content-Type", "application/json");
        logger.debug("JSON to push {}", json.toString());
        StringEntity strEntity = new StringEntity(json);
        post.setEntity(strEntity);
        httpClient.execute(post);
        logger.debug("Pushed {} to userId {}", data.toString(), userId);
    } catch (Exception ex) {
        logger.error("Push Failed for {} ", userId, ex);
    }

}