Java Code Examples for org.apache.commons.text.StringEscapeUtils#escapeXml10()
The following examples show how to use
org.apache.commons.text.StringEscapeUtils#escapeXml10() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLPropertiesConfiguration.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Write a property. * * @param out the output stream * @param key the key of the property * @param value the value of the property */ private void writeProperty(final PrintWriter out, final String key, final Object value) { // escape the key final String k = StringEscapeUtils.escapeXml10(key); if (value != null) { final String v = escapeValue(value); out.println(" <entry key=\"" + k + "\">" + v + "</entry>"); } else { out.println(" <entry key=\"" + k + "\"/>"); } }
Example 2
Source File: SplitXml.java From nifi with Apache License 2.0 | 5 votes |
@Override public void startElement(final String uri, final String localName, final String qName, final Attributes atts) throws SAXException { // Increment the current depth because start a new XML element. int newDepth = ++depth; // Output the element and its attributes if it is // not the root element. if (newDepth > splitDepth) { sb.append("<"); sb.append(qName); final Set<String> attributeNames = new HashSet<>(); int attCount = atts.getLength(); for (int i = 0; i < attCount; i++) { String attName = atts.getQName(i); attributeNames.add(attName); String attValue = StringEscapeUtils.escapeXml10(atts.getValue(i)); sb.append(" ").append(attName).append("=").append("\"").append(attValue).append("\""); } // If this is the first node we're outputting write out // any additional namespace declarations that are required if (splitDepth == newDepth - 1) { for (Entry<String, String> entry : prefixMap.entrySet()) { // If we've already added this namespace as an attribute then continue if (attributeNames.contains(entry.getKey())) { continue; } sb.append(" "); sb.append(entry.getKey()); sb.append("=\""); sb.append(entry.getValue()); sb.append("\""); } } sb.append(">"); } }
Example 3
Source File: XMLPropertiesConfiguration.java From commons-configuration with Apache License 2.0 | 5 votes |
private void writeProperty(final Document document, final Node properties, final String key, final Object value) { final Element entry = document.createElement("entry"); properties.appendChild(entry); // escape the key final String k = StringEscapeUtils.escapeXml10(key); entry.setAttribute("key", k); if (value != null) { final String v = escapeValue(value); entry.setTextContent(v); } }
Example 4
Source File: XMLPropertiesConfiguration.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Escapes a property value before it is written to disk. * * @param value the value to be escaped * @return the escaped value */ private String escapeValue(final Object value) { final String v = StringEscapeUtils.escapeXml10(String.valueOf(value)); return String.valueOf(getListDelimiterHandler().escape(v, ListDelimiterHandler.NOOP_TRANSFORMER)); }
Example 5
Source File: ChatPanel.java From btdex with GNU General Public License v3.0 | 4 votes |
private String prepareHtmlString(String rawContent) { return StringEscapeUtils.escapeXml10(rawContent); }
Example 6
Source File: ChatWindow.java From chat-socket with MIT License | 4 votes |
private String prepareHtmlString(String rawContent) { return StringEscapeUtils.escapeXml10(rawContent); }
Example 7
Source File: BasicStreamIDFactory.java From Openfire with Apache License 2.0 | 4 votes |
public BasicStreamID(String id) { if ( id == null || id.isEmpty() ) { throw new IllegalArgumentException( "Argument 'id' cannot be null." ); } this.id = StringEscapeUtils.escapeXml10( id ); }
Example 8
Source File: JUnitXMLPerPageListener.java From hsac-fitnesse-fixtures with Apache License 2.0 | 4 votes |
protected String getMessage(Throwable exception) { String errorMessage = exception.getMessage(); return StringEscapeUtils.escapeXml10(errorMessage); }
Example 9
Source File: XmlUtility.java From jstarcraft-core with Apache License 2.0 | 2 votes |
/** * 对字符串执行XML1.0加密 * * @param string * @return */ public static final String escapeXml10(String string) { return StringEscapeUtils.escapeXml10(string); }
Example 10
Source File: ASIBaseClass.java From sakai with Educational Community License v2.0 | 2 votes |
/** * Simple wrapper over commons lang util method, but we may add additional * logic in the future for special QTI export purposes. * @param s * @return escaped string e.g. * < \u04D0rnesen & Jones > becomes <Ӑrnesen & Jones > */ public static String escapeXml(String s) { if (s==null) return ""; return StringEscapeUtils.escapeXml10(s); }
Example 11
Source File: ASIBaseClass.java From sakai with Educational Community License v2.0 | 2 votes |
/** * Simple wrapper over commons lang util method, but we may add additional * logic in the future for special QTI export purposes. * @param s * @return escaped string e.g. * < \u04D0rnesen & Jones > becomes <Ӑrnesen & Jones > */ public static String escapeXml(String s) { if (s==null) return ""; return StringEscapeUtils.escapeXml10(s); }