Example usage for org.apache.commons.lang3 StringEscapeUtils unescapeJava

List of usage examples for org.apache.commons.lang3 StringEscapeUtils unescapeJava

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringEscapeUtils unescapeJava.

Prototype

public static final String unescapeJava(final String input) 

Source Link

Document

Unescapes any Java literals found in the String .

Usage

From source file:com.github.breadmoirai.samurai.util.SearchResult.java

private static String cleanString(String uncleanString) {
    return StringEscapeUtils.unescapeJava(StringEscapeUtils
            .unescapeHtml4(uncleanString.replaceAll("\\s+", " ").replaceAll("<.*?>", "").replaceAll("\"", "")));
}

From source file:models.service.IPBasedLocationService.java

/**
 * ?????//from   ww  w  . j  a  v  a2  s.c o  m
 * 
 * @param ip ip?
 * @return ??,null - ???
 */
public static String getSimpleAddress(String ip) {
    Promise<Response> get = WSUtil.get(baiduServiceURL, "ak", baiduServiceAK, "ip", ip);

    Response response;
    try {
        response = get.get(REQUEST_TIMEOUT);
    } catch (RuntimeException e) {
        LOGGER.error("IP?API", e);
        return null;
    }

    String body = response.getBody();
    JsonNode locationJsonNode = null;

    try {
        body = StringEscapeUtils.unescapeJava(body);
        locationJsonNode = Json.parse(body);
    } catch (RuntimeException e) {
        LOGGER.error("IP?APIJSON?JSON" + body, e);
        return null;
    }

    String simpleAddress = null;

    if (locationJsonNode.has("content") && locationJsonNode.get("content").has("address")) {
        simpleAddress = locationJsonNode.get("content").get("address").asText();
    } else {
        LOGGER.error("IP?API?JSON" + body);
    }

    return simpleAddress;
}

From source file:net.dv8tion.discord.util.SearchResult.java

private static String cleanString(String uncleanString) {
    return StringEscapeUtils.unescapeJava(StringEscapeUtils.unescapeHtml4(
            uncleanString.replaceAll("\\s+", " ").replaceAll("\\<.*?>", "").replaceAll("\"", "")));
}

From source file:de.wbuecke.codec.JavaInput.java

@Override
public String decode(String input) {
    return StringEscapeUtils.unescapeJava(input);
}

From source file:com.fecresgam.dbsd.translator.utils.ParserUtils.java

/**
 * Clean a the start and character from a given string.
 *
 * @param input such information.//from  w  w w  .j a v a 2s  .  co  m
 * @return such information.
 */
public static String cleanFakeString(final String input) {
    String result = null;

    if (input != null && input.length() > 1) {
        result = input.substring(1, input.length() - 1);
    }
    return StringEscapeUtils.unescapeJava(result);
}

From source file:de.citec.sc.index.ProcessAnchorFile.java

public static void run(String filePath) {

    try {//  ww w  .  j  av a 2 s .  c o m
        File file = new File("new.ttl");

        // if file doesnt exists, then create it
        if (file.exists()) {
            file.delete();
            file.createNewFile();
        }
        if (!file.exists()) {
            file.createNewFile();
        }
        BufferedReader wpkg = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8"));
        String line = "";

        PrintStream ps = new PrintStream("new.ttl", "UTF-8");

        while ((line = wpkg.readLine()) != null) {

            String[] data = line.split("\t");

            if (data.length == 3) {
                String label = data[0];

                label = StringEscapeUtils.unescapeJava(label);

                try {
                    label = URLDecoder.decode(label, "UTF-8");
                } catch (Exception e) {
                }

                String uri = data[1].replace("http://dbpedia.org/resource/", "");
                uri = StringEscapeUtils.unescapeJava(uri);

                try {
                    uri = URLDecoder.decode(uri, "UTF-8");
                } catch (Exception e) {
                }

                String f = data[2];

                label = label.toLowerCase();
                ps.println(label + "\t" + uri + "\t" + f);

            }

        }

        wpkg.close();
        ps.close();

        File oldFile = new File(filePath);
        oldFile.delete();
        oldFile.createNewFile();

        file.renameTo(oldFile);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:io.hawkcd.agent.utilities.ReportAppender.java

public static StringBuilder appendInfoMessage(String message, StringBuilder report) {

    //message = MessageConstants.CONSOLE_WHITE + message;
    if (!message.isEmpty()) {
        String formattedMessage = String.format("%s %s", getTimeStamp(), message);

        System.out.println(StringEscapeUtils.unescapeJava(formattedMessage));

        report.append(formattedMessage).append(System.lineSeparator());
    } else {// w w  w.  j  a  v a2s  .c  om
        report.append(message).append(System.lineSeparator());
    }
    return report;
}

From source file:com.fecresgam.dbsd.translator.dto.data.TextData.java

/**
 * Creates a new Text Data.
 *
 * @param content such information.
 */
public TextData(String content) {
    super(StringEscapeUtils.unescapeJava(content));
}

From source file:com.mirth.connect.server.attachments.regex.RegexAttachmentHandlerProvider.java

@Override
public void setProperties(Channel channel, AttachmentHandlerProperties attachmentProperties) {
    String regex = attachmentProperties.getProperties().get("regex.pattern");
    mimeType = attachmentProperties.getProperties().get("regex.mimetype");

    int count = 0;
    while (attachmentProperties.getProperties().containsKey("regex.replaceKey" + count)) {
        inboundReplacements.put(/*from  w  w w  .java  2s. c om*/
                StringEscapeUtils
                        .unescapeJava(attachmentProperties.getProperties().get("regex.replaceKey" + count)),
                StringEscapeUtils
                        .unescapeJava(attachmentProperties.getProperties().get("regex.replaceValue" + count)));
        count++;
    }

    count = 0;
    while (attachmentProperties.getProperties().containsKey("outbound.regex.replaceKey" + count)) {
        outboundReplacements.put(
                StringEscapeUtils.unescapeJava(
                        attachmentProperties.getProperties().get("outbound.regex.replaceKey" + count)),
                StringEscapeUtils.unescapeJava(
                        attachmentProperties.getProperties().get("outbound.regex.replaceValue" + count)));
        count++;
    }

    if (StringUtils.isNotEmpty(regex)) {
        pattern = Pattern.compile(regex);
    } else {
        pattern = null;
    }
}

From source file:com.fecresgam.dbsd.translator.dto.constraints.CheckConstraint.java

/**
 * Creates a new Check Constraint./*from  w  w w  .j  a v  a2s . c o m*/
 *
 * @param name such information.
 * @param column such information.
 * @param condition such information.
 */
public CheckConstraint(final String name, final String column, final String condition) {
    super(name, ConstraintType.CHECK);
    this.column = column;
    this.condition = StringEscapeUtils.unescapeJava(condition);
}