I don't know why we declared new escape(StringWriter, String) methods. I've removed these and inlined their code into the escape(String, String) type methods

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@504319 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2007-02-06 22:04:01 +00:00
parent aa5356645e
commit f011627264
1 changed files with 14 additions and 53 deletions

View File

@ -795,7 +795,13 @@ class Entities {
*/ */
public String escape(String str) { public String escape(String str) {
StringWriter stringWriter = createStringWriter(str); StringWriter stringWriter = createStringWriter(str);
this.escape(stringWriter, str); try {
this.escape(stringWriter, str);
} catch (IOException e) {
// This should never happen because ALL the StringWriter methods called by #escape(Writer, String) do not
// throw IOExceptions.
throw new UnhandledException(e);
}
return stringWriter.toString(); return stringWriter.toString();
} }
@ -837,32 +843,6 @@ class Entities {
} }
} }
/**
* <p>
* Escapes the characters in the <code>String</code> passed and writes the result to the <code>StringWriter</code>
* passed.
* </p>
*
* @param writer
* The <code>StringWriter</code> to write the results of the escaping to. Assumed to be a non-null
* value.
* @param str
* The <code>String</code> to escape. Assumed to be a non-null value.
*
* @see #escape(String)
* @see Writer
* @since 2.3
*/
public void escape(StringWriter writer, String str) {
try {
this.escape((Writer) writer, str);
} catch (IOException e) {
// This should never happen because ALL the StringWriter methods called by #escape(Writer, String) do not
// throw IOExceptions.
throw new UnhandledException(e);
}
}
/** /**
* <p> * <p>
* Unescapes the entities in a <code>String</code>. * Unescapes the entities in a <code>String</code>.
@ -879,7 +859,13 @@ class Entities {
*/ */
public String unescape(String str) { public String unescape(String str) {
StringWriter stringWriter = createStringWriter(str); StringWriter stringWriter = createStringWriter(str);
this.unescape(stringWriter, str); try {
this.unescape(stringWriter, str);
} catch (IOException e) {
// This should never happen because ALL the StringWriter methods called by #escape(Writer, String) do not
// throw IOExceptions.
throw new UnhandledException(e);
}
return stringWriter.toString(); return stringWriter.toString();
} }
@ -888,31 +874,6 @@ class Entities {
return new StringWriter((int) (str.length() + (str.length() * 0.1))); return new StringWriter((int) (str.length() + (str.length() * 0.1)));
} }
/**
* <p>
* Unescapes the escaped entities in the <code>String</code> passed and writes the result to the
* <code>StringWriter</code> passed.
* </p>
*
* @param writer
* The <code>StringWriter</code> to write the results to; assumed to be non-null.
* @param string
* The <code>String</code> to write the results to; assumed to be non-null.
*
* @see #escape(String)
* @see Writer
* @since 2.3
*/
public void unescape(StringWriter writer, String string) {
try {
this.unescape((Writer) writer, string);
} catch (IOException e) {
// This should never happen because ALL the StringWriter methods called by #escape(Writer, String) do not
// throw IOExceptions.
throw new UnhandledException(e);
}
}
/** /**
* <p> * <p>
* Unescapes the escaped entities in the <code>String</code> passed and writes the result to the * Unescapes the escaped entities in the <code>String</code> passed and writes the result to the