本文整理汇总了Java中org.apache.commons.text.StringEscapeUtils.escapeHtml4方法的典型用法代码示例。如果您正苦于以下问题:Java StringEscapeUtils.escapeHtml4方法的具体用法?Java StringEscapeUtils.escapeHtml4怎么用?Java StringEscapeUtils.escapeHtml4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.text.StringEscapeUtils
的用法示例。
在下文中一共展示了StringEscapeUtils.escapeHtml4方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: print
import org.apache.commons.text.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Prints the.
*
* @param displayValue the display value
* @param out the out
* @throws JspException the jsp exception
*/
private void print(String displayValue, JspWriter out) throws JspException {
try {
if (maxLength != -1 && displayValue.length() > maxLength) {
String newValue;
if (ellipsisRight) {
newValue = displayValue.substring(0, maxLength - 3) + "...";
} else {
newValue = "..." + displayValue.substring(displayValue.length() - maxLength + 3);
}
String title = StringEscapeUtils.escapeHtml4(displayValue);
out.print("<span title=\"" + title + "\">" + newValue + "</span>");
} else {
out.print(displayValue);
}
} catch (IOException e) {
throw new JspException(e);
}
}
示例2: createMessage
import org.apache.commons.text.StringEscapeUtils; //导入方法依赖的package包/类
private static String createMessage(boolean stackTraceInWiki, String message) {
String result = message;
if (!stackTraceInWiki) {
// Until https://github.com/unclebob/fitnesse/issues/731 is fixed
if (message.contains("\n")) {
if (!message.startsWith("<") || !message.endsWith(">")) {
// it is not yet HTML, make it HTML so we can use <br/>
message = StringEscapeUtils.escapeHtml4(message);
message = String.format("<div>%s</div>", message);
}
message = message.replaceAll("(\\r)?\\n", "<br/>");
}
result = String.format("message:<<%s>>", message);
}
return result;
}
示例3: sanitizeForLog
import org.apache.commons.text.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Sanitizes string for log.
* @param msg message to sanitize
* @return sanitized message
*/
public static String sanitizeForLog(String msg) {
String clean = msg != null ? msg.replace('\n', '_').replace('\r', '_') : "";
clean = StringEscapeUtils.escapeHtml4(clean);
if (!msg.equals(clean)) {
clean += " (Encoded)";
}
return clean;
}
示例4: getTwitterAccordionPane
import org.apache.commons.text.StringEscapeUtils; //导入方法依赖的package包/类
public static String getTwitterAccordionPane(String systemId) throws ServiceException, Exception {
if ( StringUtils.isBlank(systemId) ) {
return "";
}
SysTwitterVO sysTwitter = new SysTwitterVO();
sysTwitter.setSystem( systemId );
DefaultResult<SysTwitterVO> result = sysTwitterService.findByUK(sysTwitter);
if ( result.getValue()==null ) {
return "";
}
sysTwitter = result.getValue();
if ( !YesNo.YES.equals(sysTwitter.getEnableFlag()) ) {
return "";
}
String content = new String( sysTwitter.getContent(), "utf8" );
if ( StringUtils.isBlank(content) ) {
return "";
}
StringBuilder sb = new StringBuilder();
String title = StringEscapeUtils.escapeHtml4( sysTwitter.getTitle() );
String id = "_" + systemId + "_twitter_AccordionPane";
sb.append("<div data-dojo-type=\"dijit/layout/AccordionPane\" title=\"<img src='./icons/twitter.png' border='0'/> " + title + "\" id=\"" + id + "\"> \n");
sb.append(content);
sb.append("\n");
sb.append("</div>");
return sb.toString();
}
示例5: getHtml
import org.apache.commons.text.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Formats supplied value for display as pre-formatted text in FitNesse page.
* @param formatter formatter to use to generate pre-formatted text.
* @param value value to format.
* @return HTML formatted version of value.
*/
public String getHtml(Formatter formatter, String value) {
String result = null;
if (value != null) {
if ("".equals(value)) {
result = "";
} else {
String formattedResponse = formatter.format(value);
result = "<pre>" + StringEscapeUtils.escapeHtml4(formattedResponse) + "</pre>";
}
}
return result;
}
示例6: getTreeShowName
import org.apache.commons.text.StringEscapeUtils; //导入方法依赖的package包/类
private String getTreeShowName(EmployeeVO employee) throws Exception {
if ( !super.isBlank(employee.getJobTitle()) ) {
return employee.getEmpId() + " - " + StringEscapeUtils.escapeHtml4(employee.getFullName()) + " ( " + employee.getJobTitle().trim() + " )";
}
return employee.getEmpId() + " - " + StringEscapeUtils.escapeHtml4(employee.getFullName());
}
示例7: formatExceptionMsg
import org.apache.commons.text.StringEscapeUtils; //导入方法依赖的package包/类
protected String formatExceptionMsg(String value) {
return StringEscapeUtils.escapeHtml4(value);
}
示例8: htmlEncode
import org.apache.commons.text.StringEscapeUtils; //导入方法依赖的package包/类
/**
* HTML-escapes the String representation of the given Object.
* @param object the Object.
* @return an HTML-escaped String representation.
*/
public String htmlEncode( Object object )
{
return object != null ? StringEscapeUtils.escapeHtml4( String.valueOf( object ) ) : null;
}
示例9: toString
import org.apache.commons.text.StringEscapeUtils; //导入方法依赖的package包/类
@Override public String toString() { return StringEscapeUtils.escapeHtml4(html); }