Permalink
Browse files

Simply extract the DevNull target to make it reusable for some perfor…

…mance tests.
  • Loading branch information...
1 parent 8c304c2 commit ac76be060fb9bcd76e8586e725e913b9e86ed171 @rolfl rolfl committed Mar 20, 2012
@@ -0,0 +1,78 @@
+package org.jdom2.contrib.perf;
+
+import java.io.IOException;
+import java.io.Writer;
+
+final class DevNull extends Writer {
+
+ int counter = 0;
+
+ public void reset() {
+ counter = 0;
+ }
+
+ public int getCounter() {
+ return counter;
+ }
+
+ @Override
+ public void write(final char[] cbuf, final int off, final int len) throws IOException {
+ // do nothing
+ counter++;
+ }
+
+ @Override
+ public void flush() throws IOException {
+ // do nothing
+ counter++;
+ }
+
+ @Override
+ public void close() throws IOException {
+ // do nothing
+ counter++;
+ }
+
+ @Override
+ public void write(final int c) throws IOException {
+ // do nothing
+ counter++;
+ }
+
+ @Override
+ public void write(final char[] cbuf) throws IOException {
+ // do nothing
+ counter++;
+ }
+
+ @Override
+ public void write(final String str) throws IOException {
+ // do nothing
+ counter++;
+ }
+
+ @Override
+ public void write(final String str, final int off, final int len) throws IOException {
+ // do nothing
+ counter++;
+ }
+
+ @Override
+ public Writer append(final CharSequence csq) throws IOException {
+ counter++;
+ return this;
+ }
+
+ @Override
+ public Writer append(final CharSequence csq, final int start, final int end) throws IOException {
+ counter++;
+ return this;
+ }
+
+ @Override
+ public Writer append(final char c) throws IOException {
+ counter++;
+ return this;
+ }
+
+}
@@ -4,7 +4,6 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -67,80 +66,6 @@ public void run() throws Exception {
}
}
- private static class DevNull extends Writer {
-
- int counter = 0;
-
- public void reset() {
- counter = 0;
- }
-
- public int getCounter() {
- return counter;
- }
-
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- // do nothing
- counter++;
- }
-
- @Override
- public void flush() throws IOException {
- // do nothing
- counter++;
- }
-
- @Override
- public void close() throws IOException {
- // do nothing
- counter++;
- }
-
- @Override
- public void write(int c) throws IOException {
- // do nothing
- counter++;
- }
-
- @Override
- public void write(char[] cbuf) throws IOException {
- // do nothing
- counter++;
- }
-
- @Override
- public void write(String str) throws IOException {
- // do nothing
- counter++;
- }
-
- @Override
- public void write(String str, int off, int len) throws IOException {
- // do nothing
- counter++;
- }
-
- @Override
- public Writer append(CharSequence csq) throws IOException {
- counter++;
- return this;
- }
-
- @Override
- public Writer append(CharSequence csq, int start, int end) throws IOException {
- counter++;
- return this;
- }
-
- @Override
- public Writer append(char c) throws IOException {
- counter++;
- return this;
- }
-
- }
-
private static final DevNull devnull = new DevNull();
private final File infile;

0 comments on commit ac76be0

Please sign in to comment.