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

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

Introduction

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

Prototype

CharSequenceTranslator ESCAPE_HTML4

To view the source code for org.apache.commons.lang3 StringEscapeUtils ESCAPE_HTML4.

Click Source Link

Document

Translator object for escaping HTML version 4.0.

Usage

From source file:org.jboss.dashboard.ui.panel.navigation.treeMenu.TreeMenuFormatter.java

protected void printSection(Section section, int level) {
    TreeMenuDriver driver = (TreeMenuDriver) getPanel().getProvider().getDriver();
    String sectionPattern = driver.getPatternForPage(section, level, getPanel(),
            openedPages.contains(section.getDbid()));
    String sectionName = StringEscapeUtils.ESCAPE_HTML4.translate(getLocalizedValue(section.getTitle()));
    String sectionText = driver.performReplacementsInPattern(sectionPattern, section, sectionName);
    writeToOut(sectionText);/*ww  w.  j  a v a 2s .com*/
}

From source file:org.jboss.dashboard.ui.panel.parameters.ComboListParameter.java

public String renderHTML(HttpServletRequest req, PanelInstance instance, PanelProviderParameter param,
        String value) {// w w  w.j  av  a  2 s .c  o m
    StringBuffer buf = new StringBuffer();

    dataSupplier.init(instance);
    List values = dataSupplier.getValues();
    List keys = dataSupplier.getKeys();

    // Map choices = panel.getProvider().getDriver().getChoicesFor(param, panel);

    if (values != null && keys != null) {
        buf.append("<select class='skn-input' name='param_").append(getId()).append("'>");
        buf.append("<option value=''>").append(getDefaultValueText()).append("</option>");
        Iterator it = keys.iterator();
        Iterator itValues = values.iterator();

        while (it.hasNext() && itValues.hasNext()) {
            String key = (String) it.next();
            String val = (String) itValues.next();
            String selected = (key.equals(instance.getParameterValue(param.getId()))) ? "selected" : "";
            buf.append("<option value='").append(StringEscapeUtils.ESCAPE_HTML4.translate(key)).append("' ")
                    .append(selected).append(">").append(StringEscapeUtils.ESCAPE_HTML4.translate(val))
                    .append("</option>");
        }
        buf.append("</select>");
    }

    return buf.toString();
}

From source file:org.jboss.dashboard.ui.taglib.EncodeTag.java

/**
 * Encode a name for a given panel context, appending it to a String depending on the panel.
 *
 * @param panel Panel being rendered//from w  w w  . ja  v  a2 s . c  o m
 * @param uiBean factoryComponent
 * @param name Symbolic name to encode @return an encoded version for that name, so that different panels have different names.
 * @return A encoded name
 */
public static String encode(Panel panel, UIBeanHandler uiBean, String name) {
    StringBuffer sb = new StringBuffer();
    if (panel != null) {
        sb.append("panel_")
                .append(panel.getPanelId().longValue() < 0 ? ("NEG" + Math.abs(panel.getPanelId().longValue()))
                        : panel.getPanelId().toString());
    }
    if (uiBean != null) {
        String beanName = uiBean.getBeanName();
        if (isJavaIdentifier(beanName)) {
            sb.append("_component_").append(beanName);
        } else {
            sb.append("_component_").append(Math.abs(beanName.hashCode()));
        }
    }
    sb.append("_").append(StringEscapeUtils.ESCAPE_HTML4.translate(name));
    return sb.toString();
}

From source file:org.jboss.dashboard.ui.taglib.factory.PropertyTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport
 *//*from   w w  w .jav a 2 s . c  o  m*/
public int doEndTag() throws JspException {
    try {
        if (super.bodyContent == null) {
            Object value = getValue();
            String textValue = value == null ? "" : value.toString();
            pageContext.getOut()
                    .print(valueIsHTML ? textValue : StringEscapeUtils.ESCAPE_HTML4.translate(textValue));
        } else {
            pageContext.getOut().print(bodyContent.getString());
        }
    } catch (IOException e) {
        handleError(e);
    }
    value = null;
    return EVAL_PAGE;
}

From source file:org.jboss.dashboard.ui.taglib.LinkToSectionTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport
 *//*  w w  w .  j a v  a 2  s  .  c o  m*/
public int doEndTag() throws JspTagException {

    WorkspaceImpl workspace = NavigationManager.lookup().getCurrentWorkspace();

    if (workspace != null) {
        Section section = workspace.getSection(getSection());

        if (section != null) {
            String linkStr = getLink((HttpServletRequest) pageContext.getRequest(),
                    (HttpServletResponse) pageContext.getResponse(), section);
            try {
                pageContext.getOut().print(StringEscapeUtils.ESCAPE_HTML4.translate(linkStr));
            } catch (java.io.IOException e) {
                handleError(e);
            }
        } else {
            log.error("Section '" + getSection() + "' not found");
        }
    } else {
        log.error("Current workspace not found");
    }

    return EVAL_PAGE;
}

From source file:org.jboss.dashboard.ui.taglib.LocalizeTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport
 *///from ww  w  . jav a 2  s.  c  o  m
public int doEndTag() throws JspTagException {
    String locale = getLocaleManager().getCurrentLang();
    String result = getLocalizedValue(locale);

    if (useDefaults) {
        if (result == null || result.trim().length() == 0) {
            locale = getLocaleManager().getDefaultLang();
            result = getLocalizedValue(locale);
        }
    }

    try {
        pageContext.getOut().print(valueIsHTML ? result : StringEscapeUtils.ESCAPE_HTML4.translate(result));
    } catch (IOException e) {
        handleError(e);
    }

    setData(null);
    setLocale(null);
    setUseDefaults(true);

    return EVAL_PAGE;
}

From source file:org.jboss.dashboard.ui.taglib.PropertyReadTag.java

protected Object getPropertyValue() {
    log.debug("Getting property " + property + " from " + object);
    Object subjectOfTheGetter = null;
    if ("workspace".equalsIgnoreCase(object)) {
        subjectOfTheGetter = NavigationManager.lookup().getCurrentWorkspace();
    } else if ("section".equalsIgnoreCase(object)) {
        subjectOfTheGetter = NavigationManager.lookup().getCurrentSection();
    } else if ("panel".equalsIgnoreCase(object)) {
        subjectOfTheGetter = RequestContext.lookup().getActivePanel();
    } else if ("request".equalsIgnoreCase(object)) {
        subjectOfTheGetter = RequestContext.lookup().getRequest();
    } else if ("session".equalsIgnoreCase(object)) {
        subjectOfTheGetter = RequestContext.lookup().getRequest().getSessionObject();
    } else {//from  ww  w  .  ja  v  a2  s  . c om
        log.warn("Invalid object to get property from: " + object);
    }
    if (subjectOfTheGetter == null) {
        log.debug("Cannot get current " + object);
        return null;
    }
    try {
        Object val = JXPathContext.newContext(subjectOfTheGetter).getValue(property);
        if (localize != null && localize.booleanValue() && val instanceof Map) {
            return StringEscapeUtils.ESCAPE_ECMASCRIPT
                    .translate(StringEscapeUtils.ESCAPE_HTML4.translate((String) (localize((Map) val))));
        }
        return StringEscapeUtils.ESCAPE_ECMASCRIPT
                .translate(StringEscapeUtils.ESCAPE_HTML4.translate((String) val));
    } catch (Exception e) {
        log.warn("Error accessing property " + property + " in " + object + "." + e);
        return null;
    }
}

From source file:org.jboss.dashboard.ui.utils.javascriptUtils.JavascriptTree.java

public static String HTMLfilter(String str) {
    return StringEscapeUtils.ESCAPE_HTML4.translate(str);
}

From source file:org.jboss.dashboard.ui.utils.javascriptUtils.JavascriptTree.java

/**
 * @param s/*from  w  w w.  j a  va2s. c om*/
 * @return
 * @deprecated Use StringEscapeUtils.ESCAPE_HTML4.translate(s)
 */
public static String replaceTildes(String s) {
    return StringEscapeUtils.ESCAPE_HTML4.translate(s);
}

From source file:org.jboss.dashboard.workspace.PanelProviderParameter.java

/**
 * Escapes given string for including in a JSP page
 *
 * @param value value to scape//www .j  a  v  a  2 s.c om
 * @return the scaped value
 */
protected static String escapeParameterValue(String value) {
    return StringEscapeUtils.ESCAPE_HTML4.translate(value);
}