List of usage examples for org.apache.commons.lang3 StringEscapeUtils unescapeHtml3
public static final String unescapeHtml3(final String input)
Unescapes a string containing entity escapes to a string containing the actual Unicode characters corresponding to the escapes.
From source file:com.cotrino.knowledgemap.db.Question.java
public Question(Page page) { String realText = StringEscapeUtils.unescapeHtml3(page.getText()); List<String> rawSentences = Question.tokenize(realText, "en", "US"); if (rawSentences.size() >= QUESTION_SENTENCES) { //System.out.println("Asking about '" + title + "'"); generateQuestion(page, rawSentences); }//w ww. ja va 2 s. c om }
From source file:com.hit.j2ee.sshTemplate.common.encrypt.EncodeUtils.java
/** * Html ?. */ public static String htmlUnescape(String htmlEscaped) { return StringEscapeUtils.unescapeHtml3(htmlEscaped); }
From source file:es.ua.dlsi.patch.translation.LocalApertiumTranslator.java
public Map<String, Set<String>> getTranslation(final Set<String> inputset) { Map<String, Set<String>> dictionary = new HashMap<>(); if (!inputset.isEmpty()) { try {// www. j ava 2s . com StringBuilder sb = new StringBuilder(); List<String> input = new LinkedList<>(inputset); for (String s : input) { sb.append("<p>"); sb.append(s); sb.append("</p>"); } //String[] command = {"apertium", "-u", "-f html", langCmd}; ProcessBuilder probuilder = new ProcessBuilder("apertium", "-u", "-fhtml", langCmd); Process process = probuilder.start(); OutputStream stdin = process.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin)); writer.write(sb.toString()); writer.flush(); writer.close(); InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line; StringBuilder finalline = new StringBuilder(); while ((line = br.readLine()) != null) { finalline.append(line); } br.close(); String finaltranslation = StringEscapeUtils .unescapeHtml3(finalline.toString().replaceAll("\\s<", "<").replaceAll(">\\s", ">") .replaceAll("^<p>", "").replace("</p>", "")); List<String> translations = new LinkedList<>(Arrays.asList(finaltranslation.split("<p>"))); for (int i = 0; i < translations.size(); i++) { if (dictionary.containsKey(input.get(i))) { dictionary.get(input.get(i)).add(translations.get(i)); } else { Set<String> trans_set = new HashSet<>(); trans_set.add(translations.get(i)); dictionary.put(input.get(i), trans_set); } } } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); } } return dictionary; }
From source file:com.kdmanalytics.toif.assimilator.XMLNode.java
/** * Parse the node information. Note that the "Attributes" here are XML Attributes, not KDM * attributes./*from ww w. java 2 s .c o m*/ * * @param ns * @param sName * @param qName * @param attrs */ public XMLNode(String ns, String sName, String qName, Attributes attrs) { children = new ArrayList<XMLNode>(); this.sName = sName; if ("".equals(sName)) this.sName = qName; // Not namespace aware int size = attrs.getLength(); for (int i = 0; i < size; i++) { String key = attrs.getLocalName(i); // Attr name if ("".equals(key)) key = attrs.getQName(i); // Special cases // Stereotype/tag "type" is an attribute, not a reference if ("stereotype".equals(this.sName) && "type".equals(key)) addAttribute(key, attrs.getValue(key)); else if ("tag".equals(this.sName) && "type".equals(key)) addAttribute(key, attrs.getValue(key)); // Some attributes are really references else if (AttributeUtilities.isReference(key)) addReference(key, attrs.getValue(key)); // Unescape the fields which likely contain escaped HTML else if (stringFields.contains(key)) { String value = attrs.getValue(key); try { // value = StringEscapeUtils.unescapeHtml4(value); // value = StringEscapeUtils.unescapeXml(value); value = StringEscapeUtils.unescapeHtml3(value); } catch (StringIndexOutOfBoundsException e) { // String was most likely '&' which causes commons.lang3 to // throw... ignore it if (!value.contains("&")) { throw e; } } addAttribute(key, value); } // Normal attribute else { addAttribute(key, attrs.getValue(key)); } } // Use the xmiLid if it exists id = getAttribute("xmi:id"); if (id == null) id = "" + UniqueID.get(); }
From source file:com.interopbridges.tools.windowsazure.JSONHelper.java
/** * This API will decode the given HTML encoded string. * //from ww w. j a va 2 s. co m * @param str * @return */ public static String decodeHTML(String str) { String decoded = StringEscapeUtils.unescapeHtml3(str); return decoded; }
From source file:com.phone.cn.service.BaseService.java
/** *??// www . java2 s .co m * @param str * @return */ protected String doEditor(String str) { if (StringUtils.isNotEmpty(str)) { return StringEscapeUtils.unescapeHtml3(str).replace("\n", "").replace("\"", "\\\"").replace("\t", "") .replace("\r", ""); } return str; }
From source file:com.phone.cn.service.BaseService.java
/** *??/*from w ww . j a va 2 s .c o m*/ * @param str * @return */ protected String doEditorForIndex(String str) { if (StringUtils.isNotEmpty(str)) { return StringEscapeUtils.unescapeHtml3(str).replace("\n", "") // .replace("\"", "") .replace("\t", "").replace("\r", ""); } return str; }
From source file:com.rockagen.commons.util.CommUtil.java
/** * <p>/*www . j ava 2 s .c o m*/ * unescape HTML see StringEscapeUtils.unescapeHtml3(str) * </p> * <p> * Supports all known HTML 3.0 entities, including funky accents. Note that * the commonly used apostrophe escape character (&apos;) is not a legal * entity and so is not supported). * </p> * <p> * For example: * </p> * <p> * <code>&quot;bread&quot; &amp; &quot;butter&quot;</code> * </p> * becomes: * <p> * <code>"bread" & "butter"</code>. * </p> * * @param str value * @return string */ public static String unescapeHtml3(String str) { if (isBlank(str)) { return str; } return StringEscapeUtils.unescapeHtml3(str); }
From source file:com.trsst.Common.java
public static String unescapeHTML(String escapedHtml) { return StringEscapeUtils.unescapeHtml3(escapedHtml); }
From source file:cn.sinobest.jzpt.framework.utils.string.StringUtils.java
/** * HTML * * @param s * @return */ public static String unescapeHtml(String s) { return StringEscapeUtils.unescapeHtml3(s); }