當前位置: 首頁>>代碼示例>>Java>>正文


Java StringEscapeUtils.escapeXml方法代碼示例

本文整理匯總了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;
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:30,代碼來源:FeedProcessor.java

示例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;
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:29,代碼來源:FeedProcessor.java

示例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;
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:32,代碼來源:FeedProcessor.java

示例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;
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:31,代碼來源:FeedProcessor.java

示例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();
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:49,代碼來源:MetaWeblogAPI.java

示例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();
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:39,代碼來源:MetaWeblogAPI.java

示例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();
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:24,代碼來源:MetaWeblogAPI.java

示例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();
}
 
開發者ID:daima,項目名稱:solo-spring,代碼行數:53,代碼來源:MetaWeblogAPI.java

示例9: escapeXml

import org.apache.commons.lang3.StringEscapeUtils; //導入方法依賴的package包/類
/**
 * Xml 轉碼.
 */
public static String escapeXml(String xml) {
    return StringEscapeUtils.escapeXml(xml);
}
 
開發者ID:wolfboys,項目名稱:opencron,代碼行數:7,代碼來源:Encodes.java

示例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;
}
 
開發者ID:XiaoMi,項目名稱:shepher,代碼行數:6,代碼來源:ReviewUtil.java


注:本文中的org.apache.commons.lang3.StringEscapeUtils.escapeXml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。