Example usage for org.apache.commons.text StringEscapeUtils escapeXml11

List of usage examples for org.apache.commons.text StringEscapeUtils escapeXml11

Introduction

In this page you can find the example usage for org.apache.commons.text StringEscapeUtils escapeXml11.

Prototype

public static String escapeXml11(final String input) 

Source Link

Document

Escapes the characters in a String using XML entities.

For example: "bread" & "butter" => "bread" & "butter" .

Usage

From source file:com.jwebmp.core.utilities.EscapeChars.java

/**
 * Escape characters for text appearing as XML data, between tags.
 *
 * @param aText//from w w w.  j av  a  2  s  .c o m
 *
 * @return
 */
public static String forXML(String aText) {
    return StringEscapeUtils.escapeXml11(aText);
}

From source file:fr.inrialpes.exmo.align.service.msg.Message.java

public String getXMLContent() {
    return StringEscapeUtils.escapeXml11(content);
}

From source file:com.seleniumtests.util.StringUtility.java

/**
 * Encode string according to provided format
 * @param message      message to encode
 * @param format      'xml', 'csv', 'html', 'json', 'text'. the later does not change anything
 * @return/*w  w w .  ja  va 2  s. c o  m*/
 */
public static String encodeString(String message, String format) {
    String newMessage;
    switch (format) {
    case "xml":
        newMessage = StringEscapeUtils.escapeXml11(message);
        break;
    case "csv":
        newMessage = StringEscapeUtils.escapeCsv(message);
        break;
    case "html":
        newMessage = StringEscapeUtils.escapeHtml4(message);
        break;
    case "json":
        newMessage = StringEscapeUtils.escapeJson(message);
        break;
    case "text":
        newMessage = message;
        break;
    default:
        throw new CustomSeleniumTestsException("only escaping of 'xml', 'html', 'csv', 'json' is allowed");
    }
    return newMessage;
}

From source file:de.viaboxx.nlstools.formats.BundleWriterFlexClass.java

/**
 * Write the constants to the interface file.
 *
 * @param pw      writer to write to/* ww w. ja v  a2s .  c  o m*/
 * @param aBundle to read from
 */
void writeConstants(PrintWriter pw, MBBundle aBundle) {
    for (MBEntry mbEntry : aBundle.getEntries()) {
        String keyName = mbEntry.getKey();
        Iterator<MBText> texts = mbEntry.getTexts().iterator();
        pw.print("  /** ");
        while (texts.hasNext()) {
            MBText theText = texts.next();
            String lang = theText.getLocale();
            pw.print("{");
            pw.print(lang);
            pw.print("} ");
        }
        MBText xmpl = mbEntry.findExampleText(getExampleLocale());
        if (xmpl != null) {
            pw.print(" | ");
            pw.print(xmpl.getLocale());
            pw.print(" = ");
            pw.print(StringEscapeUtils.escapeXml11(xmpl.getValue()));
        }
        pw.println(" */");
        pw.print("  public static const ");
        String theKey = keyName.replace('.', '_');
        pw.print(theKey);
        pw.print(":String = \"");
        pw.print(keyName);
        pw.println("\";");
    }
}

From source file:de.viaboxx.nlstools.formats.BundleWriterJavaInterface.java

protected void printEntryComment(PrintWriter pw, MBEntry eachEntry, Iterator<MBText> texts) {
    printIndent(pw).print("/** ");
    if (eachEntry.getDescription() != null && eachEntry.getDescription().length() > 0) {
        pw.print(eachEntry.getDescription());
        pw.print("\n  ");//from   w ww .j  a  v  a2s .  co m
    }
    if (eachEntry.getAliases() != null && !eachEntry.getAliases().isEmpty()) {
        pw.print(eachEntry.getAliases());
        pw.print("\n  ");
    }
    while (texts.hasNext()) {
        MBText theText = texts.next();
        String lang = theText.getLocale();
        pw.print("{");
        pw.print(lang);
        pw.print("} ");
    }
    MBText xmpl = eachEntry.findExampleText(getExampleLocale());
    if (xmpl != null) {
        pw.print(" | ");
        pw.print(xmpl.getLocale());
        pw.print(" = ");
        pw.print(StringEscapeUtils.escapeXml11(xmpl.getValue()));
    }
    pw.println(" */");
}

From source file:nl.knaw.huc.di.tag.tagml.xml.exporter.XMLBuilder.java

@Override
public void exitText(final String text, final boolean inVariation) {
    String xmlEscapedText = StringEscapeUtils.escapeXml11(text);
    xmlBuilder.append(xmlEscapedText);//from   w  w w .j a va  2s  . co  m
}

From source file:nl.knaw.huc.di.tag.tagml.xml.exporter.XMLBuilder.java

@Override
public String serializeStringAnnotationValue(String stringValue) {
    return "\"" + StringEscapeUtils.escapeXml11(stringValue) + "\"";
}