本文整理汇总了Java中org.apache.commons.lang3.StringEscapeUtils.escapeXml方法的典型用法代码示例。如果您正苦于以下问题:Java StringEscapeUtils.escapeXml方法的具体用法?Java StringEscapeUtils.escapeXml怎么用?Java StringEscapeUtils.escapeXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringEscapeUtils
的用法示例。
在下文中一共展示了StringEscapeUtils.escapeXml方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEntry
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
private Entry getEntry(final boolean hasMultipleUsers, String authorName, final JSONArray articles,
final boolean isFullContent, int i) throws org.json.JSONException, org.b3log.solo.service.ServiceException {
final JSONObject article = articles.getJSONObject(i);
final Entry ret = new Entry();
final String title = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
ret.setTitle(title);
final String summary = isFullContent ? StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT))
: StringEscapeUtils.escapeXml(article.optString(Article.ARTICLE_ABSTRACT));
ret.setSummary(summary);
final Date updated = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
ret.setUpdated(updated);
final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
ret.setLink(link);
ret.setId(link);
if (hasMultipleUsers) {
authorName = StringEscapeUtils.escapeXml(articleQueryService.getAuthor(article).getString(User.USER_NAME));
}
ret.setAuthor(authorName);
final String tagsString = article.getString(Article.ARTICLE_TAGS_REF);
final String[] tagStrings = tagsString.split(",");
for (final String tagString : tagStrings) {
final Category catetory = new Category();
ret.addCatetory(catetory);
final String tag = tagString;
catetory.setTerm(tag);
}
return ret;
}
示例2: getEntryForArticle
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
private Entry getEntryForArticle(final List<JSONObject> articles, final boolean hasMultipleUsers, String authorName,
final boolean isFullContent, int i) throws org.json.JSONException, org.b3log.solo.service.ServiceException {
final JSONObject article = articles.get(i);
final Entry ret = new Entry();
final String title = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
ret.setTitle(title);
final String summary = isFullContent ? StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT))
: StringEscapeUtils.escapeXml(article.optString(Article.ARTICLE_ABSTRACT));
ret.setSummary(summary);
final Date updated = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
ret.setUpdated(updated);
final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
ret.setLink(link);
ret.setId(link);
if (hasMultipleUsers) {
authorName = StringEscapeUtils.escapeXml(articleQueryService.getAuthor(article).getString(User.USER_NAME));
}
ret.setAuthor(authorName);
final String tagsString = article.getString(Article.ARTICLE_TAGS_REF);
final String[] tagStrings = tagsString.split(",");
for (final String tagString : tagStrings) {
final Category catetory = new Category();
ret.addCatetory(catetory);
catetory.setTerm(tagString);
}
return ret;
}
示例3: getItem
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
private Item getItem(final JSONArray articles, final boolean hasMultipleUsers, String authorName,
final boolean isFullContent, int i) throws org.json.JSONException, org.b3log.solo.service.ServiceException {
final JSONObject article = articles.getJSONObject(i);
final Item ret = new Item();
final String title = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
ret.setTitle(title);
final String description = isFullContent
? StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT))
: StringEscapeUtils.escapeXml(article.optString(Article.ARTICLE_ABSTRACT));
ret.setDescription(description);
final Date pubDate = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
ret.setPubDate(pubDate);
final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
ret.setLink(link);
ret.setGUID(link);
final String authorEmail = article.getString(Article.ARTICLE_AUTHOR_EMAIL);
if (hasMultipleUsers) {
authorName = StringEscapeUtils.escapeXml(articleQueryService.getAuthor(article).getString(User.USER_NAME));
}
ret.setAuthor(authorEmail + "(" + authorName + ")");
final String tagsString = article.getString(Article.ARTICLE_TAGS_REF);
final String[] tagStrings = tagsString.split(",");
for (final String tagString : tagStrings) {
final org.b3log.solo.model.feed.rss.Category catetory = new org.b3log.solo.model.feed.rss.Category();
ret.addCatetory(catetory);
final String tag = tagString;
catetory.setTerm(tag);
}
return ret;
}
示例4: getItemForArticles
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
private Item getItemForArticles(final List<JSONObject> articles, final boolean hasMultipleUsers, String authorName,
final boolean isFullContent, int i) throws org.json.JSONException, org.b3log.solo.service.ServiceException {
final JSONObject article = articles.get(i);
final Item ret = new Item();
final String title = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
ret.setTitle(title);
final String description = isFullContent
? StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT))
: StringEscapeUtils.escapeXml(article.optString(Article.ARTICLE_ABSTRACT));
ret.setDescription(description);
final Date pubDate = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
ret.setPubDate(pubDate);
final String link = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
ret.setLink(link);
ret.setGUID(link);
final String authorEmail = article.getString(Article.ARTICLE_AUTHOR_EMAIL);
if (hasMultipleUsers) {
authorName = StringEscapeUtils.escapeXml(articleQueryService.getAuthor(article).getString(User.USER_NAME));
}
ret.setAuthor(authorEmail + "(" + authorName + ")");
final String tagsString = article.getString(Article.ARTICLE_TAGS_REF);
final String[] tagStrings = tagsString.split(",");
for (final String tagString : tagStrings) {
final org.b3log.solo.model.feed.rss.Category catetory = new org.b3log.solo.model.feed.rss.Category();
ret.addCatetory(catetory);
catetory.setTerm(tagString);
}
return ret;
}
示例5: buildPost
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Builds a post (post struct) with the specified post id.
*
* @param postId
* the specified post id
* @return blog info XML
* @throws Exception
* exception
*/
private String buildPost(final String postId) throws Exception {
final StringBuilder stringBuilder = new StringBuilder();
final JSONObject result = articleQueryService.getArticle(postId);
if (null == result) {
throw new Exception("Not found article[id=" + postId + "]");
}
final JSONObject article = result.getJSONObject(Article.ARTICLE);
final Date createDate = (Date) article.get(Article.ARTICLE_CREATE_DATE);
final String articleTitle = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
stringBuilder.append("<struct>");
stringBuilder.append("<member><name>dateCreated</name>").append("<value><dateTime.iso8601>")
.append(DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(createDate))
.append("</dateTime.iso8601></value></member>");
stringBuilder.append("<member><name>description</name>").append("<value>")
.append(StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT)))
.append("</value></member>");
stringBuilder.append("<member><name>title</name>").append("<value>").append(articleTitle)
.append("</value></member>");
stringBuilder.append("<member><name>categories</name>").append("<value><array><data>");
final JSONArray tags = article.getJSONArray(Article.ARTICLE_TAGS_REF);
for (int i = 0; i < tags.length(); i++) {
final String tagTitle = tags.getJSONObject(i).getString(Tag.TAG_TITLE);
stringBuilder.append("<value>").append(tagTitle).append("</value>");
}
stringBuilder.append("</data></array></value></member></struct>");
return stringBuilder.toString();
}
示例6: buildCategories
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Builds categories (array of category info structs) with the specified
* preference.
*
* @return blog info XML
* @throws Exception
* exception
*/
private String buildCategories() throws Exception {
final StringBuilder stringBuilder = new StringBuilder();
final List<JSONObject> tags = tagQueryService.getTags();
for (final JSONObject tag : tags) {
final String tagTitle = StringEscapeUtils.escapeXml(tag.getString(Tag.TAG_TITLE));
final String tagId = tag.getString(Keys.OBJECT_ID);
stringBuilder.append("<value><struct>");
stringBuilder.append("<member><name>description</name>").append("<value>").append(tagTitle)
.append("</value></member>");
stringBuilder.append("<member><name>title</name>").append("<value>").append(tagTitle)
.append("</value></member>");
stringBuilder.append("<member><name>categoryid</name>").append("<value>").append(tagId)
.append("</value></member>");
stringBuilder.append("<member><name>htmlUrl</name>").append("<value>").append(Latkes.getServePath())
.append("/tags/").append(tagTitle).append("</value></member>");
stringBuilder.append("<member><name>rsslUrl</name>").append("<value>").append(Latkes.getServePath())
.append("/tag-articles-rss.do?oId=").append(tagId).append("</value></member>");
stringBuilder.append("</struct></value>");
}
return stringBuilder.toString();
}
示例7: buildBlogInfo
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Builds blog info struct with the specified preference.
*
* @param preference
* the specified preference
* @return blog info XML
* @throws JSONException
* json exception
*/
private String buildBlogInfo(final JSONObject preference) throws JSONException {
final String blogId = preference.getString(Keys.OBJECT_ID);
final String blogTitle = StringEscapeUtils.escapeXml(preference.getString(Option.ID_C_BLOG_TITLE));
final StringBuilder stringBuilder = new StringBuilder("<member><name>blogid</name><value>").append(blogId)
.append("</value></member>");
stringBuilder.append("<member><name>url</name><value>").append(Latkes.getServePath())
.append("</value></member>");
stringBuilder.append("<member><name>blogName</name><value>").append(blogTitle).append("</value></member>");
return stringBuilder.toString();
}
示例8: buildRecentPosts
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Builds recent posts (array of post structs) with the specified fetch
* size.
*
* @param fetchSize
* the specified fetch size
* @return blog info XML
* @throws Exception
* exception
*/
private String buildRecentPosts(final int fetchSize) throws Exception {
final StringBuilder stringBuilder = new StringBuilder();
final List<JSONObject> recentArticles = articleQueryService.getRecentArticles(fetchSize);
for (final JSONObject article : recentArticles) {
final Date createDate = (Date) article.get(Article.ARTICLE_CREATE_DATE);
final String articleTitle = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE));
stringBuilder.append("<value><struct>");
stringBuilder.append("<member><name>dateCreated</name>").append("<value><dateTime.iso8601>")
.append(DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(createDate))
.append("</dateTime.iso8601></value></member>");
stringBuilder.append("<member><name>description</name>").append("<value>")
.append(StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT)))
.append("</value></member>");
stringBuilder.append("<member><name>title</name>").append("<value>").append(articleTitle)
.append("</value></member>");
stringBuilder.append("<member><name>postid</name>").append("<value>")
.append(article.getString(Keys.OBJECT_ID)).append("</value></member>");
stringBuilder.append("<member><name>categories</name>").append("<value><array><data>");
final String tagTitles = article.getString(Article.ARTICLE_TAGS_REF);
final String[] tagTitleArray = tagTitles.split(",");
for (int i = 0; i < tagTitleArray.length; i++) {
final String tagTitle = tagTitleArray[i];
stringBuilder.append("<value>").append(tagTitle).append("</value>");
}
stringBuilder.append("</data></array></value></member>");
stringBuilder.append("</struct></value>");
}
return stringBuilder.toString();
}
示例9: escapeXml
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Xml 转码.
*/
public static String escapeXml(String xml) {
return StringEscapeUtils.escapeXml(xml);
}
示例10: generateSummary
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public static String generateSummary(String content) {
String summary = StringEscapeUtils.escapeXml(content);
summary = StringUtils.substring(summary, 0, 50);
return summary;
}