本文整理匯總了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);
}