Remove StringPrintWriter (package scoped) as performed no useful purpose

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@234019 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2005-08-20 11:16:54 +00:00
parent 554b667e9f
commit 885f92cfa7
3 changed files with 19 additions and 86 deletions

View File

@ -16,6 +16,7 @@
package org.apache.commons.lang;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import org.apache.commons.lang.exception.NestableRuntimeException;
@ -150,9 +151,9 @@ public class StringEscapeUtils {
return null;
}
try {
StringPrintWriter writer = new StringPrintWriter(str.length() * 2);
StringWriter writer = new StringWriter(str.length() * 2);
escapeJavaStyleString(writer, str, escapeSingleQuotes);
return writer.getString();
return writer.toString();
} catch (IOException ioe) {
// this should never ever happen while writing to a StringWriter
ioe.printStackTrace();
@ -266,9 +267,9 @@ public class StringEscapeUtils {
return null;
}
try {
StringPrintWriter writer = new StringPrintWriter(str.length());
StringWriter writer = new StringWriter(str.length());
unescapeJava(writer, str);
return writer.getString();
return writer.toString();
} catch (IOException ioe) {
// this should never ever happen while writing to a StringWriter
ioe.printStackTrace();
@ -442,9 +443,9 @@ public class StringEscapeUtils {
}
try {
StringPrintWriter writer = new StringPrintWriter ((int)(str.length() * 1.5));
StringWriter writer = new StringWriter ((int)(str.length() * 1.5));
escapeHtml(writer, str);
return writer.getString();
return writer.toString();
} catch (IOException e) {
//assert false;
//should be impossible
@ -514,9 +515,9 @@ public class StringEscapeUtils {
}
try {
StringPrintWriter writer = new StringPrintWriter ((int)(str.length() * 1.5));
StringWriter writer = new StringWriter ((int)(str.length() * 1.5));
unescapeHtml(writer, str);
return writer.getString();
return writer.toString();
} catch (IOException e) {
//assert false;
//should be impossible

View File

@ -1,69 +0,0 @@
/*
* Copyright 2002-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.lang;
import java.io.PrintWriter;
import java.io.StringWriter;
/**
* <p>A PrintWriter that maintains a String as its backing store.</p>
*
* <p>Usage:
* <pre>
* StringPrintWriter out = new StringPrintWriter();
* printTo(out);
* System.out.println( out.getString() );
* </pre>
* </p>
*
* @author Alex Chaffee
* @author Scott Stanchfield
* @author Gary D. Gregory
* @since 2.0
*/
class StringPrintWriter extends PrintWriter {
/**
* Constructs a new instance.
*/
public StringPrintWriter() {
super(new StringWriter());
}
/**
* Constructs a new instance using the specified initial string-buffer
* size.
*
* @param initialSize an int specifying the initial size of the buffer.
*/
public StringPrintWriter(int initialSize) {
super(new StringWriter(initialSize));
}
/**
* <p>Since toString() returns information *about* this object, we
* want a separate method to extract just the contents of the
* internal buffer as a String.</p>
*
* @return the contents of the internal string buffer
*/
public String getString() {
flush();
return ((StringWriter) this.out).toString();
}
}

View File

@ -16,6 +16,7 @@
package org.apache.commons.lang;
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
@ -105,9 +106,9 @@ public class StringEscapeUtilsTest extends TestCase {
message = "escapeJava(String) failed" + (message == null ? "" : (": " + message));
assertEquals(message, expected, converted);
StringPrintWriter writer = new StringPrintWriter();
StringWriter writer = new StringWriter();
StringEscapeUtils.escapeJava(writer, original);
assertEquals(expected, writer.getString());
assertEquals(expected, writer.toString());
}
public void testUnescapeJava() throws IOException {
@ -127,7 +128,7 @@ public class StringEscapeUtilsTest extends TestCase {
} catch (IllegalArgumentException ex) {
}
try {
String str = StringEscapeUtils.unescapeJava("\\u02-3");
StringEscapeUtils.unescapeJava("\\u02-3");
fail();
} catch (RuntimeException ex) {
}
@ -159,9 +160,9 @@ public class StringEscapeUtilsTest extends TestCase {
"' actual '" + StringEscapeUtils.escapeJava(actual) + "'",
expected, actual);
StringPrintWriter writer = new StringPrintWriter();
StringWriter writer = new StringWriter();
StringEscapeUtils.unescapeJava(writer, original);
assertEquals(unescaped, writer.getString());
assertEquals(unescaped, writer.toString());
}
@ -210,12 +211,12 @@ public class StringEscapeUtilsTest extends TestCase {
String expected = htmlEscapes[i][1];
String original = htmlEscapes[i][2];
assertEquals(message, expected, StringEscapeUtils.escapeHtml(original));
StringPrintWriter sw = new StringPrintWriter();
StringWriter sw = new StringWriter();
try {
StringEscapeUtils.escapeHtml(sw, original);
} catch (IOException e) {
}
String actual = original == null ? null : sw.getString();
String actual = original == null ? null : sw.toString();
assertEquals(message, expected, actual);
}
}
@ -227,12 +228,12 @@ public class StringEscapeUtilsTest extends TestCase {
String original = htmlEscapes[i][1];
assertEquals(message, expected, StringEscapeUtils.unescapeHtml(original));
StringPrintWriter sw = new StringPrintWriter();
StringWriter sw = new StringWriter();
try {
StringEscapeUtils.unescapeHtml(sw, original);
} catch (IOException e) {
}
String actual = original == null ? null : sw.getString();
String actual = original == null ? null : sw.toString();
assertEquals(message, expected, actual);
}
// \u00E7 is a cedilla (c with wiggle under)