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

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

Introduction

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

Prototype

public static final String escapeHtml3(final String input) 

Source Link

Document

Escapes the characters in a String using HTML entities.

Supports only the HTML 3.0 entities.

Usage

From source file:com.fizzed.rocker.runtime.HtmlStringify.java

@Override
public String s(String str) {
    return StringEscapeUtils.escapeHtml3(str);
}

From source file:fi.elfcloud.client.HTMLEscapedJLabel.java

@Override
public void setText(String text) {
    super.setText("<html>" + StringEscapeUtils.escapeHtml3(text) + "</html>");
}

From source file:com.igormaznitsa.jcp.expression.functions.FunctionSTR2WEB.java

@Override
@Nonnull/*from   w  w w.  j  a  v a2s .c om*/
public Value executeStr(@Nonnull final PreprocessorContext context, @Nonnull final Value value) {
    final String escaped = StringEscapeUtils.escapeHtml3(value.asString());

    final StringBuilder result = new StringBuilder(escaped.length() * 2);
    for (int i = 0; i < escaped.length(); i++) {
        final char ch = escaped.charAt(i);
        if (CharUtils.isAscii(ch)) {
            result.append(ch);
        } else {
            result.append("&#").append(Integer.toString(Character.codePointAt(escaped, i))).append(';');
        }
    }

    return Value.valueOf(result.toString());
}

From source file:com.hit.j2ee.sshTemplate.common.encrypt.EncodeUtils.java

/**
 * Html ?.
 */
public static String htmlEscape(String html) {
    return StringEscapeUtils.escapeHtml3(html);
}

From source file:fi.elfcloud.client.tree.DataItemNode.java

@Override
public String toString() {
    String displayName = "<html>";
    displayName += StringEscapeUtils.escapeHtml3(object.getName());
    displayName += " (" + Utils.humanReadableByteCount(object.getKeyLength(), true) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
    displayName += (metaMap.get("DSC") != null && metaMap.get("DSC").length() > 0 //$NON-NLS-1$//$NON-NLS-2$
            ? " - " + StringEscapeUtils.escapeHtml3(metaMap.get("DSC")) //$NON-NLS-1$//$NON-NLS-2$
            : ""); //$NON-NLS-1$
    if (metaMap.get("TGS") != null && metaMap.get("TGS").length() > 0) { //$NON-NLS-1$ //$NON-NLS-2$
        String tags[] = metaMap.get("TGS").split(","); //$NON-NLS-1$ //$NON-NLS-2$
        displayName += " ["; //$NON-NLS-1$
        for (int i = 0; i < tags.length; i++) {
            displayName += (i > 0 ? ", " + StringEscapeUtils.escapeHtml3(tags[i]) //$NON-NLS-1$
                    : StringEscapeUtils.escapeHtml3(tags[i]));
        }/*from  w  ww .j a va2 s . c o  m*/
        displayName += "]"; //$NON-NLS-1$
    }
    displayName += "</html>";
    return displayName;
}

From source file:fi.elfcloud.client.tree.ClusterNode.java

@Override
public String toString() {
    String name = "<html>";
    if (object == null) {
        return ""; //$NON-NLS-1$
    }//from   www .  ja  v  a  2s . co m
    name += StringEscapeUtils.escapeHtml3(object.getName());
    ClusterNode rootNode;
    if (getPath().length > 1) {
        rootNode = (ClusterNode) getPath()[1];
        if (rootNode.getElement() instanceof Vault) {
            Vault vault = (Vault) rootNode.getElement(); // Vault
            if (vault != null) {
                name += "<font color='#717171'>";
                name += StringEscapeUtils.escapeHtml3(createOwnerInfo(vault));
                name += "</font>";
            }
        }
    }
    name += "</html>";
    return name;
}

From source file:net.beaconcontroller.web.view.json.OFFlowStatisticsReplyDataTableFormatCallback.java

@Override
public void format(OFFlowStatisticsReply data, JsonGenerator jg) throws IOException {
    jg.writeNumber(U16.f(data.getMatch().getInputPort()));
    jg.writeString(HexString.toHexString(data.getMatch().getDataLayerSource()));
    jg.writeString(HexString.toHexString(data.getMatch().getDataLayerDestination()));
    jg.writeNumber(U16.f(data.getMatch().getDataLayerType()));
    jg.writeString(IPv4.fromIPv4Address(data.getMatch().getNetworkSource()));
    jg.writeString(IPv4.fromIPv4Address(data.getMatch().getNetworkDestination()));
    jg.writeNumber(U8.f(data.getMatch().getNetworkProtocol()));
    jg.writeNumber(U16.f(data.getMatch().getTransportSource()));
    jg.writeNumber(U16.f(data.getMatch().getTransportDestination()));
    jg.writeNumber(U32.f(data.getMatch().getWildcards()));
    jg.writeNumber(U64.f(data.getByteCount()));
    jg.writeNumber(U64.f(data.getPacketCount()));
    jg.writeNumber(((double) U32.f(data.getDurationSeconds()))
            + ((double) data.getDurationNanoseconds()) / 1000000000d);
    jg.writeNumber(U16.f(data.getIdleTimeout()));
    jg.writeNumber(U16.f(data.getHardTimeout()));
    jg.writeNumber(U64.f(data.getCookie()));
    StringBuffer outPorts = new StringBuffer();
    for (OFAction action : data.getActions()) {
        if (action instanceof OFActionOutput) {
            OFActionOutput ao = (OFActionOutput) action;
            if (outPorts.length() > 0)
                outPorts.append(" ");
            outPorts.append(U16.f(ao.getPort()));
        }/*from w w  w.  jav a  2  s. c o m*/
    }
    jg.writeString(outPorts.toString());
    String url = StringEscapeUtils
            .escapeHtml3("/wm/core/switch/" + switchId + "/flow/" + data.getMatch().toString() + "/del");
    jg.writeString("<a href=\"" + url + "\">del</a>");
}

From source file:com.interopbridges.tools.windowsazure.JSONHelper.java

/**
 * This API will encode the given string in HTML.
 * //from  w  w  w. j  a va  2 s.  c o  m
 * @param str
 * @return
 */
public static String encodeHTML(String str) {
    String encoded = StringEscapeUtils.escapeHtml3(str);
    return encoded;
}

From source file:com.thejustdo.util.Utils.java

/**
 * Formats a string to avoid any injection exploit by escaping the special
 * characters.// ww w  .  j ava 2s.  c  om
 *
 * @param s String to be modified.
 * @return Modified string.
 */
public static String escapeString(String s) {
    String answer;
    answer = StringEscapeUtils.escapeCsv(s);
    answer = StringEscapeUtils.escapeEcmaScript(answer);
    answer = StringEscapeUtils.escapeHtml3(answer);
    answer = StringEscapeUtils.escapeHtml4(answer);
    answer = StringEscapeUtils.escapeJava(answer);
    answer = StringEscapeUtils.escapeXml(answer);
    return answer;
}

From source file:com.chirp.api.ChirpAPIResource.java

@POST
@Path("/search")
public Response getSettings(InputStream incomingData) {
    try {//from   ww w .  java 2s. c o  m
        HashMap<String, String> parameters = objectMapper.readValue(getInputString(incomingData),
                HashMap.class);
        String name = parameters.get("name");
        String query = parameters.get("query");
        String rules = parameters.get("rule");

        String path = rdfMap.get(name);
        if (path == null) {
            return Response.status(200).build();
        }

        // Create an empty in-memory model
        Model model = ModelFactory.createDefaultModel(); // default model this will be changed if there is a rule

        // use the FileManager to open the bloggers RDF graph from the filesystem
        InputStream in = FileManager.get().open(path);
        if (in == null) {
            throw new IllegalArgumentException("File: " + path + " not found");
        }

        // read the RDF/XML file
        model.read(in, "");
        InfModel infModel = null;
        QueryExecution qe = null;
        if (rules != null && !rules.isEmpty()) {
            Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
            infModel = ModelFactory.createInfModel(reasoner, model);
        }
        Query queryObj = QueryFactory.create(query);

        // Execute the query and obtain results
        if (infModel != null) {
            qe = QueryExecutionFactory.create(queryObj, infModel);
        } else {
            qe = QueryExecutionFactory.create(queryObj, model);
        }
        ResultSet results = qe.execSelect();
        String s = ResultSetFormatter.asText(results);
        s = StringEscapeUtils.escapeHtml3(s);
        return Response.status(200).entity(s).build();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return Response.status(400).entity(e.getMessage()).build();
    }
}