本文整理汇总了Java中org.apache.commons.lang.StringEscapeUtils.escapeXml方法的典型用法代码示例。如果您正苦于以下问题:Java StringEscapeUtils.escapeXml方法的具体用法?Java StringEscapeUtils.escapeXml怎么用?Java StringEscapeUtils.escapeXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.StringEscapeUtils
的用法示例。
在下文中一共展示了StringEscapeUtils.escapeXml方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContent
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
* @see ch.dvbern.lib.doctemplate.common.BasicMergeElement#getContent(ch.dvbern.lib.doctemplate.common.MergeContext,
* ch.dvbern.lib.doctemplate.common.MergeSource, java.io.OutputStream)
*/
@Override
public void getContent(MergeContext ctx, MergeSource mergeSource, OutputStream output) throws DocTemplateException {
// Format-Suffix aus key extrahieren
String keyWithoutFormatSuffix = this.key, formatSuffix = null;
int i = this.key.indexOf(FORMAT_SUFFIX);
if (i > 0) {
formatSuffix = this.key.substring(i + FORMAT_SUFFIX.length());
keyWithoutFormatSuffix = this.key.substring(0, i);
}
Object data = mergeSource.getData(ctx, keyWithoutFormatSuffix);
if (data instanceof Image) {
addImage((T) data, formatSuffix, output);
} else if (data != null) {
String dataAsString = FormatHelper.getDataAsString(data, StringUtils.isEmpty(formatSuffix) ? getDefaultFormatter(data) : formatSuffix);
dataAsString = StringEscapeUtils.escapeXml(dataAsString);
writeText(output, dataAsString);
} else {
log.warn(this.name + ": no template source with key " + this.key);
}
}
示例2: escapeXML
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/** Replaces angle brackets by html entities. */
public static String escapeXML(String string) {
if (string == null) {
return "null";
}
return StringEscapeUtils.escapeXml(string);
}
示例3: getCDataXml
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
public static String getCDataXml(String s) {
return StringEscapeUtils.escapeXml(getCDataText(s));
}
示例4: generateXsdRequestData
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
@Override
public String generateXsdRequestData() throws Exception {
String prefix = getXsdTypePrefix();
String xsdRequestData = null;
RequestableVariable variable = null;
xsdRequestData = " <xsd:complexType name=\""+ prefix + getName() + "RequestData\">\n";
//xsdRequestData += " <xsd:annotation>\n";
//xsdRequestData += " <xsd:documentation>"+ XMLUtils.getCDataXml(getComment()) +"</xsd:documentation>\n";
//xsdRequestData += " </xsd:annotation>\n";
xsdRequestData += " <xsd:sequence>\n";
for (int i=0; i<numberOfVariables(); i++) {
variable = (RequestableVariable)getVariable(i);
if (variable.isWsdl()) {
if (variable.isMultiValued()) {
xsdRequestData += " <xsd:element minOccurs=\"1\" maxOccurs=\"1\" name=\""+variable.getName()+"\" >\n";
xsdRequestData += " <xsd:annotation>\n";
xsdRequestData += " <xsd:documentation>"+ XMLUtils.getCDataXml(variable.getComment()) +"</xsd:documentation>\n";
xsdRequestData += " <xsd:appinfo>"+ StringEscapeUtils.escapeXml(variable.getDescription()) +"</xsd:appinfo>\n";
xsdRequestData += " </xsd:annotation>\n";
xsdRequestData += " <xsd:complexType>\n";
xsdRequestData += " <xsd:sequence>\n";
xsdRequestData += " <xsd:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"item\" type=\""+variable.getSchemaType()+"\" />\n";
xsdRequestData += " </xsd:sequence>\n";
xsdRequestData += " </xsd:complexType>\n";
xsdRequestData += " </xsd:element>\n";
}
else {
xsdRequestData += " <xsd:element minOccurs=\"1\" maxOccurs=\"1\" name=\""+variable.getName()+"\" type=\""+variable.getSchemaType()+"\">\n";
xsdRequestData += " <xsd:annotation>\n";
xsdRequestData += " <xsd:documentation>"+ XMLUtils.getCDataXml(variable.getComment()) +"</xsd:documentation>\n";
xsdRequestData += " <xsd:appinfo>"+ StringEscapeUtils.escapeXml(variable.getDescription()) +"</xsd:appinfo>\n";
xsdRequestData += " </xsd:annotation>\n";
xsdRequestData += " </xsd:element>\n";
}
}
}
xsdRequestData += " </xsd:sequence>\n";
xsdRequestData += " </xsd:complexType>\n";
return xsdRequestData;
}
示例5: getNotifications
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
private void getNotifications(Integer userId, HttpServletRequest request, HttpServletResponse response)
throws IOException {
Document doc = NotificationServlet.docBuilder.newDocument();
Element notificationsElement = doc.createElement("Notifications");
doc.appendChild(notificationsElement);
Long lessonId = WebUtil.readLongParam(request, CentralConstants.PARAM_LESSON_ID, true);
Integer limit = WebUtil.readIntParam(request, "limit", true);
Integer offset = WebUtil.readIntParam(request, "offset", true);
Boolean pendingOnly = WebUtil.readBooleanParam(request, "pendingOnly", true);
List<Subscription> subscriptions = NotificationServlet.eventNotificationService
.getNotificationSubscriptions(lessonId, userId, pendingOnly, limit, offset);
for (Subscription subscription : subscriptions) {
Element notificationElement = doc.createElement("Notification");
notificationElement.setAttribute("id", subscription.getUid().toString());
Boolean pending = !DeliveryMethodNotification.LAST_OPERATION_SEEN
.equals(subscription.getLastOperationMessage());
notificationElement.setAttribute("pending", pending.toString());
Long notificationLessonId = subscription.getEvent().getEventSessionId();
if (notificationLessonId != null) {
notificationElement.setAttribute("lessonId", notificationLessonId.toString());
}
String message = subscription.getEvent().getMessage();
Matcher matcher = NotificationServlet.anchorPattern.matcher(message);
if (matcher.find()) {
String href = StringEscapeUtils.escapeXml(matcher.group(2));
notificationElement.setAttribute("href", href);
message = matcher.group(3);
}
notificationElement.appendChild(doc.createCDATASection(message));
notificationsElement.appendChild(notificationElement);
}
response.setContentType("text/xml");
response.setCharacterEncoding("UTF-8");
DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
LSSerializer lsSerializer = domImplementation.createLSSerializer();
LSOutput lsOutput = domImplementation.createLSOutput();
lsOutput.setEncoding("UTF-8");
lsOutput.setByteStream(response.getOutputStream());
lsSerializer.write(doc, lsOutput);
}
示例6: xmlEscape
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Xml 转码.
*/
public static String xmlEscape(String xml) {
return StringEscapeUtils.escapeXml(xml);
}
示例7: xmlEscape
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Xml 转码.
*/
public static String xmlEscape(String xml) {
return StringEscapeUtils.escapeXml(xml);
}
示例8: unescape
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
protected String unescape(String str){
if(StringUtils.isEmpty(str))return str;
str=StringEscapeUtils.escapeXml(str);
return StringEscapeUtils.unescapeXml(str);
}
示例9: escapeXml
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Escapes the characters in a String using XML entities.
*
* @param xml The String to escape, may be null
* @return A new escaped String, null if null string input
*/
public final static String escapeXml(String xml) {
return StringEscapeUtils.escapeXml(xml);
}