Example usage for org.apache.commons.lang StringEscapeUtils escapeHtml

List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml

Introduction

In this page you can find the example usage for org.apache.commons.lang StringEscapeUtils escapeHtml.

Prototype

public static String escapeHtml(String input) 

Source Link

Usage

From source file:com.redhat.rhn.domain.action.script.ScriptRunAction.java

/**
 * {@inheritDoc}/*from   ww w  . j  a va  2s.co m*/
 */
@Override
public String getHistoryDetails(Server server) {
    LocalizationService ls = LocalizationService.getInstance();
    StringBuilder retval = new StringBuilder();
    retval.append("</br>");
    retval.append(ls.getMessage("system.event.runAs",
            StringEscapeUtils.escapeHtml(getScriptActionDetails().getUsername()),
            StringEscapeUtils.escapeHtml(getScriptActionDetails().getGroupname())));
    retval.append("</br>");
    retval.append(ls.getMessage("system.event.timeout", getScriptActionDetails().getTimeout()));
    retval.append("</br>");
    retval.append(ls.getMessage("system.event.scriptContents"));
    retval.append("</br><pre>");
    retval.append(StringEscapeUtils.escapeHtml(getScriptActionDetails().getScriptContents()));
    retval.append("</pre></br>");
    for (ScriptResult sr : getScriptActionDetails().getResults()) {
        if (sr.getServerId().equals(server.getId())) {
            retval.append(ls.getMessage("system.event.scriptStart", sr.getStartDate()));
            retval.append("</br>");
            retval.append(ls.getMessage("system.event.scriptEnd", sr.getStopDate()));
            retval.append("</br>");
            retval.append(ls.getMessage("system.event.scriptReturnCode", sr.getReturnCode().toString()));
            retval.append("</br>");
            retval.append(ls.getMessage("system.event.scriptRawOutput"));
            retval.append("<a href=\"/network/systems/details/history/" + "raw_script_output.txt?hid="
                    + this.getId() + "&sid=" + server.getId() + "\">");
            retval.append(ls.getMessage("system.event.downloadRawOutput"));
            retval.append("</a>");
            retval.append("</br>");
            retval.append(ls.getMessage("system.event.scriptFilteredOutput"));
            retval.append("</br>");
            retval.append("<pre>");
            retval.append(StringEscapeUtils.escapeHtml(sr.getOutputContents()));
            retval.append("</pre>");
        }
    }
    return retval.toString();
}

From source file:com.dgq.utils.EncodeUtils.java

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

From source file:edu.cornell.mannlib.vedit.tags.ValueTag.java

public int doEndTag() throws JspException {
    try {/*w  w  w. j  ava  2 s  .co m*/
        JspWriter out = pageContext.getOut();

        HashMap values = null;
        try {
            // FormObject foo = (FormObject) pageContext.getSession().getAttribute("FormObject");
            // FormObject foo = TagUtils.getFormObject(pageContext);
            FormObject foo = getFormObject();
            values = foo.getValues();
        } catch (Exception e) {
            System.out.println("Could not get the form object from which to build an option list");
        }

        if (values != null) {
            String value = (String) values.get(name);
            if (value != null)
                out.print(StringEscapeUtils.escapeHtml(value));
        } else {
            System.out.println("ValueTag unable to get HashMap of form values");
        }

    } catch (Exception ex) {
        throw new JspException(ex.getMessage());
    }
    return SKIP_BODY;
}

From source file:de.thischwa.pmcms.view.context.object.Utils.java

/**
 * @return Html escaped 'string', or '', if string is empty.
 *///from w  w  w .j  ava 2s  .  c o  m
public static String escape(final String string) {
    return StringUtils.defaultString(StringEscapeUtils.escapeHtml(string));
}

From source file:com.samebug.clients.idea.ui.component.ExceptionMessageLabel.java

public ExceptionMessageLabel(@Nullable String message) {
    {//from   www  . j a  va2 s .co  m
        final String escapedText;
        if (message == null) {
            escapedText = String.format("<html><i>%s</i></html>",
                    SamebugBundle.message("samebug.exception.noMessage"));
        } else {
            // Escape html, but keep line breaks
            String broken = StringEscapeUtils.escapeHtml(message).replaceAll("\\n", "<br>");
            escapedText = String.format("<html>%s</html>", broken);
        }

        setFont(UIManager.getFont("TextArea.font"));
        setText(escapedText);
        setVerticalAlignment(SwingConstants.TOP);
    }

}

From source file:info.magnolia.cms.taglibs.util.Xmp.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *///  w w w.  j  a  v a  2s.c  o m
public int doEndTag() {
    JspWriter out = pageContext.getOut();
    String xmpString = getBodyContent().getString();
    try {
        out.print(StringEscapeUtils.escapeHtml(xmpString));
    } catch (IOException e) {
        // should never happen
        throw new NestableRuntimeException(e);
    }
    return EVAL_PAGE;
}

From source file:de.hackerspacebremen.format.MessageFormat.java

public static void htmlEncode(final SpaceStatus status) {
    if (status.getMessage() != null && status.getMessage().getValue() != null) {
        status.setMessage(new Text(StringEscapeUtils.escapeHtml(status.getMessage().getValue())));
    }//  www  .j av  a 2 s  .c  om
}

From source file:ch.systemsx.cisd.openbis.generic.shared.translator.PropertyTypeTranslator.java

public final static PropertyType translate(final PropertyTypePE propertyType, MaterialType materialType,
        Map<PropertyTypePE, PropertyType> cacheOrNull) {
    final PropertyType cachedOrNull = (cacheOrNull == null) ? null : cacheOrNull.get(propertyType);
    if (cachedOrNull != null) {
        return cachedOrNull;
    }/*from w ww.j av  a2  s.com*/
    final PropertyType result = new PropertyType();
    if (cacheOrNull != null) {
        cacheOrNull.put(propertyType, result);
    }
    result.setId(HibernateUtils.getId(propertyType));
    result.setCode(StringEscapeUtils.escapeHtml(propertyType.getCode()));
    result.setSimpleCode(StringEscapeUtils.escapeHtml(propertyType.getSimpleCode()));
    result.setInternalNamespace(propertyType.isInternalNamespace());
    result.setManagedInternally(propertyType.isManagedInternally());
    result.setLabel(StringEscapeUtils.escapeHtml(propertyType.getLabel()));
    result.setDataType(DataTypeTranslator.translate(propertyType.getType()));
    result.setVocabulary(VocabularyTranslator.translate(propertyType.getVocabulary()));
    result.setMaterialType(
            MaterialTypeTranslator.translate(propertyType.getMaterialType(), false, cacheOrNull));
    result.setDescription(StringEscapeUtils.escapeHtml(propertyType.getDescription()));
    result.setSampleTypePropertyTypes(SampleTypePropertyTypeTranslator
            .translate(propertyType.getSampleTypePropertyTypes(), result, cacheOrNull));
    result.setMaterialTypePropertyTypes(MaterialTypePropertyTypeTranslator
            .translate(propertyType.getMaterialTypePropertyTypes(), result, cacheOrNull));
    result.setExperimentTypePropertyTypes(ExperimentTypePropertyTypeTranslator
            .translate(propertyType.getExperimentTypePropertyTypes(), result));
    result.setDataSetTypePropertyTypes(DataSetTypePropertyTypeTranslator
            .translate(propertyType.getDataSetTypePropertyTypes(), result, cacheOrNull));
    return result;
}

From source file:ch.systemsx.cisd.openbis.generic.shared.translator.AttachmentTranslator.java

public final static AttachmentWithContent translateWithContent(final AttachmentPE attachment) {
    if (attachment == null) {
        return null;
    }//w  w  w  .  j a  v a 2  s . c  o  m
    final AttachmentWithContent result = new AttachmentWithContent();
    result.setFileName(StringEscapeUtils.escapeHtml(attachment.getFileName()));
    result.setTitle(StringEscapeUtils.escapeHtml(attachment.getTitle()));
    result.setDescription(StringEscapeUtils.escapeHtml(attachment.getDescription()));
    result.setRegistrator(PersonTranslator.translate(attachment.getRegistrator()));
    result.setRegistrationDate(attachment.getRegistrationDate());
    result.setVersion(attachment.getVersion());
    result.setContent(attachment.getAttachmentContent().getValue());
    return result;
}

From source file:com.github.dbourdette.glass.tools.FormatTool.java

public String html(Object object) {
    if (object == null) {
        return null;
    }

    return StringEscapeUtils.escapeHtml(object.toString());
}