From f011627264d7d47b3cd99317cc35d74760606ad8 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Tue, 6 Feb 2007 22:04:01 +0000 Subject: [PATCH] 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 --- .../org/apache/commons/lang/Entities.java | 67 ++++--------------- 1 file changed, 14 insertions(+), 53 deletions(-) diff --git a/src/java/org/apache/commons/lang/Entities.java b/src/java/org/apache/commons/lang/Entities.java index 69b5195eb..9a6c8ff5c 100644 --- a/src/java/org/apache/commons/lang/Entities.java +++ b/src/java/org/apache/commons/lang/Entities.java @@ -795,7 +795,13 @@ class Entities { */ public String escape(String 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(); } @@ -837,32 +843,6 @@ class Entities { } } - /** - *

- * Escapes the characters in the String passed and writes the result to the StringWriter - * passed. - *

- * - * @param writer - * The StringWriter to write the results of the escaping to. Assumed to be a non-null - * value. - * @param str - * The String 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); - } - } - /** *

* Unescapes the entities in a String. @@ -879,7 +859,13 @@ class Entities { */ public String unescape(String 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(); } @@ -888,31 +874,6 @@ class Entities { return new StringWriter((int) (str.length() + (str.length() * 0.1))); } - /** - *

- * Unescapes the escaped entities in the String passed and writes the result to the - * StringWriter passed. - *

- * - * @param writer - * The StringWriter to write the results to; assumed to be non-null. - * @param string - * The String 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); - } - } - /** *

* Unescapes the escaped entities in the String passed and writes the result to the