当前位置: 首页>>代码示例>>Java>>正文


Java StringEscapeUtils.unescapeHtml4方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.StringEscapeUtils.unescapeHtml4方法的典型用法代码示例。如果您正苦于以下问题:Java StringEscapeUtils.unescapeHtml4方法的具体用法?Java StringEscapeUtils.unescapeHtml4怎么用?Java StringEscapeUtils.unescapeHtml4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.StringEscapeUtils的用法示例。


在下文中一共展示了StringEscapeUtils.unescapeHtml4方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createInstance

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
 * Creates a new chat instance.
 * 
 * @return The unique id that identifies the created instance
 */
public String createInstance() {
	final String query = this.mServiceUrl + CREATE_REQUEST;
	try {
		final List<String> content = getWebContent(query);
		// If the answer is empty there was some error
		if (content.isEmpty()) {
			return null;
		}

		// The first line contains the id
		final String firstLine = content.iterator().next();
		if (firstLine.trim().isEmpty()) {
			return null;
		}
		return StringEscapeUtils.unescapeHtml4(firstLine);
	} catch (final IOException e) {
		// Ignore the exception and return null
		return null;
	}
}
 
开发者ID:ZabuzaW,项目名称:BrainBridge,代码行数:26,代码来源:BrainBridgeAPI.java

示例2: getTitle

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public final String getTitle(String s) {
  int start = s.indexOf(XML_START_TAG_TITLE);
  int end = s.indexOf(XML_END_TAG_TITLE, start);
  if (start < 0 || end < 0) {
    return "";
  }
  return StringEscapeUtils.unescapeHtml4(s.substring(start + 7, end));
}
 
开发者ID:asmehra95,项目名称:wiseowl,代码行数:9,代码来源:WikiClean.java

示例3: clean

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public String clean(String content) {
  //String content = getWikiMarkup(page);
  content = removeRefs(content);
  content = removeInterWikiLinks(content);
  content = removeParentheticals(content);
  content = fixUnitConversion(content);
  content = ImageCaptionsRemover.remove(content);
  content = DoubleBracesRemover.remove(content);
  content = removeHtmlComments(content);
  content = removeEmphasis(content);
  content = removeHeadings(content);
  content = removeCategoryLinks(content);
  content = removeLinks(content);
  content = removeMath(content);
  content = removeGallery(content);
  content = removeNoToc(content);
  content = removeIndentation(content);

  content = TableRemover.remove(content);

  // For some reason, some HTML entities are doubly encoded.
  content = StringEscapeUtils.unescapeHtml4(StringEscapeUtils.unescapeHtml4(content));
  content = removeHtmlTags(content);

  // Finally, fold multiple newlines.
  content = compressMultipleNewlines(content);
  return content.trim().replaceAll("\\n+", " ");
}
 
开发者ID:asmehra95,项目名称:wiseowl,代码行数:29,代码来源:WikiClean.java

示例4: getLastMessage

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
 * Gets the last answer of the chat bot for the instance with the given id.
 * 
 * @param id
 *            The id of the instance
 * @return The last answer of the chat bot for the given instance or
 *         <tt>null</tt> if there was no or the server experienced an error
 */
public String getLastMessage(final String id) {
	final String query = this.mServiceUrl + GET_MESSAGE_REQUEST + ID_PARAMETER + id;
	try {
		final List<String> content = getWebContent(query);
		// If the answer is empty there was some error
		if (content.isEmpty()) {
			return null;
		}

		// The first line contains the message
		final String firstLine = content.iterator().next();
		if (firstLine.trim().isEmpty()) {
			return null;
		}
		return StringEscapeUtils.unescapeHtml4(firstLine);
	} catch (final IOException e) {
		// Ignore the exception and return null
		return null;
	}
}
 
开发者ID:ZabuzaW,项目名称:BrainBridge,代码行数:29,代码来源:BrainBridgeAPI.java

示例5: defaultShareText

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public static void defaultShareText(String title, String url, Context c) {
    url = StringEscapeUtils.unescapeHtml4(Html.fromHtml(url).toString());
    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    /* Decode html entities */
    title = StringEscapeUtils.unescapeHtml4(title);
    sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, url);
    c.startActivity(Intent.createChooser(sharingIntent, c.getString(R.string.title_share)));
}
 
开发者ID:ccrama,项目名称:Slide-RSS,代码行数:11,代码来源:MainActivity.java

示例6: defaultShare

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public static void defaultShare(String url, Context c) {
    url = StringEscapeUtils.unescapeHtml4(Html.fromHtml(url).toString());
    Uri webpage = LinkUtil.formatURL(url);
    Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
    if (intent.resolveActivity(c.getPackageManager()) != null) {
        c.startActivity(intent);
    }
}
 
开发者ID:ccrama,项目名称:Slide-RSS,代码行数:9,代码来源:MainActivity.java

示例7: pushFlashNotification

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public void pushFlashNotification(Flash flash) throws JSONException, IOException {
    if (!prefs.getBoolean("notifications_enabled", true)) {
        return;
    }
    Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(flash.getLink()));
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
    String text = StringEscapeUtils.unescapeHtml4(flash.getText());
    NotificationManager mNotificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
        Notification.Builder oBuilder = new Notification.Builder(context, getNotificationChannel(context).getId());
        oBuilder.setContentTitle(flash.getChannel() + " • " + flash.getSource())
                .setStyle(new Notification.BigTextStyle()
                        .bigText(text))
                .setContentText(text)
                .setAutoCancel(true)
                .setSound(Uri.parse(prefs.getString("notification_sound", "DEFAULT")))
                .setContentIntent(pendingIntent)
                .setSmallIcon(R.drawable.ic_alert);
        mNotificationManager.notify(flash.getIdAsInteger(), oBuilder.build());
    }else{
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                .setContentTitle(flash.getChannel() + " • " + flash.getSource())
                .setStyle(new NotificationCompat.BigTextStyle()
                        .bigText(text))
                .setContentText(text)
                .setAutoCancel(true)
                .setSound(Uri.parse(prefs.getString("notification_sound", "DEFAULT")))
                .setContentIntent(pendingIntent);
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            mBuilder.setSmallIcon(R.drawable.ic_alert);
        } else {
            mBuilder.setSmallIcon(R.drawable.ic_alert_compat);
        }
        mNotificationManager.notify(flash.getIdAsInteger(), mBuilder.build());
    }
}
 
开发者ID:milesmcc,项目名称:LibreNews-Android,代码行数:38,代码来源:FlashManager.java

示例8: format

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public static String format(String content, Map<String, String> props) {
    Matcher m = PATTERN.matcher(Pattern.quote(content));
    String result = content;
    while (m.find()) {
        String found = m.group(1);
        String newVal = props.getOrDefault(found.trim(), "null");

        String escaped = StringEscapeUtils.escapeHtml4(newVal);
        result = result.replaceFirst(REGEX, Matcher.quoteReplacement(escaped));
    }
    return StringEscapeUtils.unescapeHtml4(result);
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:13,代码来源:CreateContent.java

示例9: unescapeHtml

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
 * Html 解码.
 */
public static String unescapeHtml(String htmlEscaped) {
	return StringEscapeUtils.unescapeHtml4(htmlEscaped);
}
 
开发者ID:funtl,项目名称:framework,代码行数:7,代码来源:Encodes.java

示例10: unescapeHtml

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
 * Html 解码.
 */
public static String unescapeHtml(String htmlEscaped) {
    return StringEscapeUtils.unescapeHtml4(htmlEscaped);
}
 
开发者ID:NeilRen,项目名称:NEILREN4J,代码行数:7,代码来源:Encodes.java

示例11: parse

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public static JsonLdArticle parse(List<String> jsons) {
    try {
        for (String jsonLd : jsons) {
            if (!Strings.isNullOrEmpty(jsonLd)) {
                jsonLd = jsonLd.replaceAll("http://www\\.schema\\.org", "http://schema.org");
                jsonLd = jsonLd.replaceAll("\"http://schema\\.org\"", "\"http://schema.org/\"");
                Object jsonObject = JsonUtils.fromString(jsonLd);
                Map<String, Object> data = JsonLdProcessor.compact(jsonObject, new HashMap(), new JsonLdOptions());
                String type = Objects.toString(data.get("@type"), null);
                if (type == null && data.get(SCHEMA_ATTR_ARTICLE) instanceof Map) {
                    data = (Map<String, Object>) data.get(SCHEMA_ATTR_ARTICLE);
                    type = Objects.toString(data.get("@type"), null);
                }
                if (SCHEMA_CLASS_ARTICLE.equalsIgnoreCase(type) || SCHEMA_CLASS_NEWS_ARTICLE.equalsIgnoreCase(type)) {
                    JsonLdArticle article = new JsonLdArticle();
                    String headline = Objects.toString(data.get(SCHEMA_ATTR_HEADLINE), null);
                    if (!Strings.isNullOrEmpty(headline)) {
                        headline = StringEscapeUtils.unescapeHtml4(headline);
                    }
                    article.setHeadline(headline);
                    String articleBody = Objects.toString(data.get(SCHEMA_ATTR_ARTICLE_BODY), null);
                    if (!Strings.isNullOrEmpty(articleBody)) {
                        articleBody = StringEscapeUtils.unescapeHtml4(articleBody);
                    }
                    article.setArticleBody(articleBody);
                    Object publishedObject = data.get(SCHEMA_ATTR_PUBLISHED);
                    String datePublished = null;
                    if (publishedObject instanceof String) {
                        datePublished = (String) publishedObject;
                    } else if (publishedObject instanceof Map) {
                        datePublished = Objects.toString(((Map) publishedObject).get("@value"), null);
                    }
                    article.setDatePublished(datePublished);
                    return article;
                }
            }
        }
    } catch (Exception e) {
        LOG.warn("Failed to parse ld+json", e);
    }
    return null;
}
 
开发者ID:tokenmill,项目名称:crawling-framework,代码行数:43,代码来源:JsonLdParser.java

示例12: unescapeHtml

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public static String unescapeHtml(String text) {
    return StringEscapeUtils.unescapeHtml4(text);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:4,代码来源:StringUtils.java

示例13: unEscapeString

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public static String unEscapeString(String stringToUnEscape) {
    return StringEscapeUtils.unescapeHtml4(stringToUnEscape);
}
 
开发者ID:klask-io,项目名称:klask-io,代码行数:4,代码来源:EncodingUtil.java

示例14: fromHtml

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
    * 
    * Converts special HTML values of characters to their original values. <br>
    * Example : <code>"&amp;eacute;"</code>"is converted to "�"
    * <p>
    * 
    * @param string
    *            A String to convert from HTML to original
    *            <p>
    * @return A String of char converted to original values
    * 
    */

   public static String fromHtml(String string) {

if (DO_NOTHING) return string;

if (string == null) return string;
    
if (string.contains("&")) {
    return StringEscapeUtils.unescapeHtml4(string);
} else {
    return string;
}

   }
 
开发者ID:kawansoft,项目名称:aceql-http,代码行数:27,代码来源:HtmlConverter.java

示例15: unescapeHtml

import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
 * Html解码,将HTML4格式的字符串转码解码为普通字符串.
 * 
 * 比如 &quot;bread&quot; &amp; &quot;butter&quot;转化为"bread" & "butter"
 */
public static String unescapeHtml(String html) {
	return StringEscapeUtils.unescapeHtml4(html);
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:9,代码来源:EscapeUtil.java


注:本文中的org.apache.commons.lang3.StringEscapeUtils.unescapeHtml4方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。