]> source.dussan.org Git - aspectj.git/commitdiff
231396: refactoring: removed NonLocalExit and moved StreamPrintWriter into test infra...
authoraclement <aclement>
Wed, 14 May 2008 19:34:47 +0000 (19:34 +0000)
committeraclement <aclement>
Wed, 14 May 2008 19:34:47 +0000 (19:34 +0000)
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/StreamPrintWriter.java [new file with mode: 0644]
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/ajc/AjdtCommandTestCase.java
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java

diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/StreamPrintWriter.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/StreamPrintWriter.java
new file mode 100644 (file)
index 0000000..4ead020
--- /dev/null
@@ -0,0 +1,101 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation, 
+ *               2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *     Xerox/PARC     initial implementation 
+ * ******************************************************************/
+
+package org.aspectj.ajdt;
+
+import java.io.*;
+
+/**
+ * Used for writing converting text written to an output stream into
+ * a string.  Deprecated - use StringWriter:
+ * <pre>
+ * StringWriter sw = new StringWriter();
+ * PrintWriter pw = new PrintWriter(sw, true);
+ * ... write to pw
+ * String result = sw.getBuffer().toString();
+ * </pre>
+ * @deprecated use StringWriter to construct PrintWriter
+ * @author Mik Kersten
+ */
+public class StreamPrintWriter extends PrintWriter {
+    private String contents = "";
+
+    public StreamPrintWriter(Writer out) {
+        super(out);
+    }
+
+    public String getContents() {
+        return contents;
+    }
+
+    public void flushBuffer() {
+        contents = "";
+        super.flush();
+    }
+
+    public void print(char x) {
+        contents += x + "\n";
+    }
+
+    public void print(char[] x) {
+        contents += new String( x );
+    }
+
+    public void print(int x) {
+        contents += x;
+    }
+
+    public void print(String x) {
+        contents += x;
+    }
+
+    public void println(char x) {
+        contents += x + "\n";
+    }
+
+    public void println(char[] x) {
+        contents += new String( x ) + "\n";
+    }
+
+    public void println(int x) {
+        contents += x + "\n";
+    }
+
+    public void println(String x) {
+        contents += x + "\n";
+    }
+
+    public void write( byte[] x ) {
+        contents += new String( x );
+    }
+
+    public void write( byte[] x, int i1, int i2 ) {
+        StringWriter writer = new StringWriter();
+        String s = new String( x );
+        writer.write( s.toCharArray(), i1, i2 );
+        contents += writer.getBuffer().toString();
+    }
+
+    public void write( int c ) {
+        contents += c;
+    }
+
+    public void write( String s ) {
+        contents += s;
+    }
+
+    public void write( String s, int i1, int i2 ) {
+        contents += s;
+    }
+}
index 9f1e23f7aed4133500b45c33539bfde6ccae4e28..fdc14146b9695951d19746afdbcd3a40975cd7fd 100644 (file)
@@ -14,6 +14,7 @@
 package org.aspectj.ajdt.ajc;
 
 //import org.aspectj.ajdt.internal.core.builder.AjBuildConfig;
+import org.aspectj.ajdt.StreamPrintWriter;
 import org.aspectj.bridge.*;
 import org.aspectj.util.*;
 import org.aspectj.org.eclipse.jdt.core.compiler.InvalidInputException;
index 8de9bb93bad512a11b064a5fbcd237c920299257..6cf279f49838c9b918ae17e130f4e7f1edd41988 100644 (file)
@@ -19,14 +19,13 @@ import java.io.PrintWriter;
 
 import junit.framework.TestCase;
 
+import org.aspectj.ajdt.StreamPrintWriter;
 import org.aspectj.ajdt.ajc.*;
 import org.aspectj.asm.AsmManager;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.MessageHandler;
 import org.aspectj.bridge.MessageWriter;
 import org.aspectj.tools.ajc.Ajc;
-import org.aspectj.util.StreamPrintWriter;
-//import org.eclipse.core.runtime.CoreException;
 
 public class AjBuildManagerTest extends TestCase {