Add escape methods.

This commit is contained in:
Christian P. MOMON 2013-09-09 00:57:35 +02:00
parent 6d7db8b7ef
commit 6ed1e3b20b

View file

@ -16,6 +16,8 @@ import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@ -28,6 +30,51 @@ import org.xml.sax.SAXException;
*/
public class XMLTools
{
/**
*
* @param source
* @return
*/
public String escapeXMLNull(final String source)
{
String result;
if (StringUtils.isBlank(source))
{
result = "";
}
else
{
result = StringEscapeUtils.escapeXml(source);
}
//
return result;
}
/**
*
* @param source
* @return
*/
public String unescapeXMLNull(final String source)
{
String result;
if (StringUtils.isBlank(source))
{
result = null;
}
else
{
result = StringEscapeUtils.unescapeXml(source);
}
//
return result;
}
/**
*
*