-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathNonOutputBuffer.java
More file actions
60 lines (49 loc) · 1.46 KB
/
NonOutputBuffer.java
File metadata and controls
60 lines (49 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.utplsql.api.outputBuffer;
import org.utplsql.api.reporter.Reporter;
import java.io.PrintStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
/**
* An OutputBuffer replacement which just returns nothing at all. Suitable for Reporters without any output
*
* @author pesse
*/
class NonOutputBuffer implements OutputBuffer {
private final Reporter reporter;
NonOutputBuffer(Reporter reporter) {
this.reporter = reporter;
}
@Override
public Reporter getReporter() {
return reporter;
}
@Override
public OutputBuffer setFetchSize(int fetchSize) {
return this;
}
@Override
public void printAvailable(Connection conn, PrintStream ps) throws SQLException {
List<PrintStream> printStreams = new ArrayList<>(1);
printStreams.add(ps);
printAvailable(conn, printStreams);
}
@Override
public void printAvailable(Connection conn, List<PrintStream> printStreams) throws SQLException {
fetchAvailable(conn, s -> {
for (PrintStream ps : printStreams) {
ps.println(s);
}
});
}
@Override
public void fetchAvailable(Connection conn, Consumer<String> onLineFetched) {
onLineFetched.accept(null);
}
@Override
public List<String> fetchAll(Connection conn) {
return new ArrayList<>();
}
}