org.apache.commons.lang3.StringEscapeUtils#unescapeXml ( )源码实例Demo

下面列出了org.apache.commons.lang3.StringEscapeUtils#unescapeXml ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: JVoiceXML   文件: ValueStrategy.java
/**
 * Retrieves the TTS output of this tag.
 *
 * @return Output of this tag, <code>null</code> if there is no text to
 *         output.
 *
 * @exception SemanticError
 *                Error evaluating an expression.
 */
private String getOutput() throws SemanticError {
    final Object result = getAttribute(Value.ATTRIBUTE_EXPR);
    if (result == null) {
        LOGGER.warn("ignoring empty value result");

        return null;
    }

    final String text = result.toString();
    final String cleaned = text.trim();
    if (cleaned.length() == 0) {
        LOGGER.warn("ignoring empty value node");

        return null;
    }

    return StringEscapeUtils.unescapeXml(cleaned);
}
 
源代码2 项目: JVoiceXML   文件: AbstractFormItem.java
/**
 * {@inheritDoc}
 */
@Override
public final Object evaluateExpression(final DataModel model)
        throws SemanticError {
    final String expr = node.getAttribute("expr");
    if (expr == null) {
        return null;
    }
    final String unescapedExpr = StringEscapeUtils.unescapeXml(expr);
    return model.evaluateExpression(unescapedExpr, Object.class);
}
 
源代码3 项目: uncc2014watsonsim   文件: Passage.java
/**
    * Create a new Passage
    * 
    * @param engine_name  A simple lowercase string
    * @param title
    * @param text
    * @param reference   Specific to the engine, or a URL, for later lookup
    */
public Passage(String engine_name, String title, String text, String reference) {
	super(text);
	if (engine_name == null)
		throw new NullPointerException("Engine name cannot be null.");
	if (title == null)
		throw new NullPointerException("Title cannot be null.");
	if (reference == null)
		throw new NullPointerException("Reference cannot be null.");
	
	this.reference = reference;
	this.engine_name = engine_name;
	this.title = StringEscapeUtils.unescapeXml(title);
}
 
源代码4 项目: uncc2014watsonsim   文件: Phrase.java
/**
 * Create a new NLP parsed phrase.
 * This will throw an NPE rather than take null text.
 * The memo system is lazy and phrases are cached so this is quite cheap.
 */
public Phrase(String text) {
	if (text == null)
		throw new NullPointerException("Text cannot be null.");
	Phrase cache_entry = recent.getIfPresent(text);
	if (cache_entry != null) {
		this.text = cache_entry.text;
		// Memos are mutable but private and thread-safe.
		this.memos = cache_entry.memos;
	} else {
		this.memos = new ConcurrentHashMap<>();
		this.text = StringEscapeUtils.unescapeXml(text);
		recent.put(text, this);
	}
}
 
源代码5 项目: zest-writer   文件: TestCorrect.java
@Test
public void testEscapeItalic() {
    String txt="<p>Est-ce que tu voudrais <em>pusher</em> ton code ?</p>";
    String s = StringEscapeUtils.unescapeXml(txt);
    String result = corrector.checkHtmlContent(s);
    assertEquals(result, txt);
}
 
源代码6 项目: es   文件: StaticResourceVersionController.java
private String versionedStaticResourceContent(String fileRealPath, String content, String newVersion) throws IOException {

        content = StringEscapeUtils.unescapeXml(content);
        if(newVersion != null && newVersion.equals("1")) {
            newVersion = "?" + newVersion;
        }

        File file = new File(fileRealPath);

        List<String> contents = FileUtils.readLines(file);

        for(int i = 0, l = contents.size(); i < l; i++) {
            String fileContent = contents.get(i);
            if(content.equals(fileContent)) {
                Matcher matcher = scriptPattern.matcher(content);
                if(!matcher.matches()) {
                    matcher = linkPattern.matcher(content);
                }
                if(newVersion == null) { //删除版本
                    content = matcher.replaceAll("$1$2$5");
                } else {
                    content = matcher.replaceAll("$1$2$3" + newVersion + "$5");
                }
                contents.set(i, content);
                break;
            }
        }
        FileUtils.writeLines(file, contents);

        return content;
    }
 
源代码7 项目: base-framework   文件: EncodeUtils.java
/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
	return StringEscapeUtils.unescapeXml(xmlEscaped);
}
 
源代码8 项目: frpMgr   文件: EncodeUtils.java
/**
 * Xml 解码.
 */
public static String decodeXml(String xmlEscaped) {
	return StringEscapeUtils.unescapeXml(xmlEscaped);
}
 
源代码9 项目: super-cloudops   文件: Encodes.java
/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
	return StringEscapeUtils.unescapeXml(xmlEscaped);
}
 
源代码10 项目: MLib   文件: Functions.java
private static void unescapeTitel(DatenFilm film) {
    // Titel
    film.arr[DatenFilm.FILM_TITEL] = StringEscapeUtils.unescapeXml(film.arr[DatenFilm.FILM_TITEL]);
    film.arr[DatenFilm.FILM_TITEL] = StringEscapeUtils.unescapeHtml4(film.arr[DatenFilm.FILM_TITEL]);
    film.arr[DatenFilm.FILM_TITEL] = StringEscapeUtils.unescapeJava(film.arr[DatenFilm.FILM_TITEL]);
}
 
源代码11 项目: gerbil   文件: WikipediaXMLParser.java
/**
 * <p>
 * Extracts the value of the <code>to</code> attribute of the first redirect
 * that it can find inside the given XML string.
 * </p>
 * 
 * <p>
 * It is assumed that the given String looks like this: <code>
 * ...
 * &lt;redirects&gt;
 * ...
 * &lt;r from="title" to="redirected title"/&gt;
 * ...
 * &lt;/redirects&gt;
 * ...
 * </code>
 * </p>
 * 
 * @param xmlString
 *            XML string from which the redirect should be parsed.
 * @return The title to which the given title is redirected or null, if such
 *         a title couldn't be found.
 */
public String extractRedirect(String xmlString) {
    if (xmlString == null) {
        return null;
    }
    int startPos = xmlString.indexOf(XML_REDIRECTS_START_TAG);
    if (startPos < 0) {
        // couldn't find redirects tag
        return null;
    }

    startPos += XML_REDIRECTS_START_TAG.length();
    int redirectsEnd = xmlString.indexOf(XML_REDIRECTS_END_TAG, startPos);
    if (redirectsEnd < 0) {
        // couldn't find redirects end tag (no valid XML)
        return null;
    }

    startPos = xmlString.indexOf(XML_REDIRECT_TAG_START, startPos);
    if ((startPos < 0) || (startPos >= redirectsEnd)) {
        // couldn't find redirect tag
        return null;
    }
    startPos += XML_REDIRECT_TAG_START.length();

    int tagEndPos = xmlString.indexOf(XML_REDIRECT_TAG_END, startPos);
    if ((tagEndPos < 0) || (tagEndPos >= redirectsEnd)) {
        // couldn't find the end of the redirect tag (no valid XML)
        return null;
    }

    startPos = xmlString.indexOf(XML_REDIRECT_TO_ATTRIBUTE_START, startPos);
    if ((startPos < 0) || (startPos >= tagEndPos)) {
        // couldn't find the 'to' attribute
        return null;
    }
    startPos += XML_REDIRECT_TO_ATTRIBUTE_START.length();

    int endPos = xmlString.indexOf(XML_REDIRECT_TO_ATTRIBUTE_END, startPos);
    if ((endPos < 0) || (endPos >= tagEndPos)) {
        // couldn't find the end of the 'to' attribute value (no valid XML)
        return null;
    }
    return StringEscapeUtils.unescapeXml(xmlString.substring(startPos, endPos));
}
 
源代码12 项目: easyweb   文件: Encodes.java
/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
	return StringEscapeUtils.unescapeXml(xmlEscaped);
}
 
源代码13 项目: Knowage-Server   文件: ScriptDetail.java
public String convertSpecialChars(String script) {
	script = StringEscapeUtils.unescapeHtml4(script);
	script = StringEscapeUtils.unescapeXml(script);
	return script;
}
 
源代码14 项目: opencron   文件: Encodes.java
/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
    return StringEscapeUtils.unescapeXml(xmlEscaped);
}
 
源代码15 项目: MLib   文件: Functions.java
private static void unescapeThema(DatenFilm film) {
    // Thema
    film.arr[DatenFilm.FILM_THEMA] = StringEscapeUtils.unescapeXml(film.arr[DatenFilm.FILM_THEMA]);
    film.arr[DatenFilm.FILM_THEMA] = StringEscapeUtils.unescapeHtml4(film.arr[DatenFilm.FILM_THEMA]);
    film.arr[DatenFilm.FILM_THEMA] = StringEscapeUtils.unescapeJava(film.arr[DatenFilm.FILM_THEMA]);
}
 
源代码16 项目: Shop-for-JavaWeb   文件: Encodes.java
/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
	return StringEscapeUtils.unescapeXml(xmlEscaped);
}
 
源代码17 项目: MultimediaDesktop   文件: Encodes.java
/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
	return StringEscapeUtils.unescapeXml(xmlEscaped);
}
 
源代码18 项目: JVoiceXML   文件: LogStrategy.java
/**
 * {@inheritDoc}
 *
 * Logs the containing text as a message.
 */
public void execute(final VoiceXmlInterpreterContext context,
        final VoiceXmlInterpreter interpreter,
        final FormInterpretationAlgorithm fia, final FormItem item,
        final VoiceXmlNode node) throws JVoiceXMLEvent {
    final NodeList list = node.getChildNodes();
    final StringBuilder outputText = new StringBuilder();

    // get and write the label attribute
    final String label = (String) getAttribute(Log.ATTRIBUTE_LABEL);
    if (label != null) {
        outputText.append(label);
        outputText.append(": ");
    }

    final String expr = (String) getAttribute(Log.ATTRIBUTE_EXPR);
    if (expr != null) {
        outputText.append(expr);
    }

    // process children
    final DataModel model = context.getDataModel();
    for (int i = 0; i < list.getLength(); i++) {
        final VoiceXmlNode current = (VoiceXmlNode) list.item(i);
        if (current instanceof Text) {
            // text node handling
            final Text text = (Text) current;
            final String msg = text.getNodeValue();
            if (msg == null) {
                LOGGER.warn("ignoring empty log node");
            } else {
                outputText.append(msg.trim());
            }
        }

        if (current instanceof Value) {
            // value node handling
            final Value value = (Value) current;
            String currentExpr = value.getExpr();
            if (currentExpr != null) {
                final String unescapedCurrentExpr = StringEscapeUtils
                        .unescapeXml(currentExpr);
                if (!currentExpr.endsWith(";")) {
                    currentExpr += ";";
                }
                final Object eval = model.evaluateExpression(
                        unescapedCurrentExpr, Object.class);
                final String evalReadable = model.toString(eval);
                outputText.append(evalReadable);
            }
        }
    }

    // write the eventual tag-value to the class-logger,
    // priority Level.INFO
    if (outputText.length() > 0) {
        LOGGER.info(outputText.toString());
    }
}
 
源代码19 项目: jee-universal-bms   文件: Encodes.java
/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
	return StringEscapeUtils.unescapeXml(xmlEscaped);
}
 
源代码20 项目: j360-dubbo-app-all   文件: EscapeUtil.java
/**
 * Xml转码,XML格式的字符串解码为普通字符串.
 * 
 * 比如 &quot;bread&quot; &amp; &quot;butter&quot; 转化为"bread" & "butter"
 */
public static String unescapeXml(String xml) {
	return StringEscapeUtils.unescapeXml(xml);
}