blob: 3d71f522a83fcb1c96323a7afbc2311e84a6e85a (
plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
package bjc.utils.ioutils;
import java.io.Reader;
/**
* Utility methods for constructing instances of {@link BlockReader}
*
* @author bjculkin
*
*/
public class BlockReaders {
/**
* Create a new simple block reader that works off a regex.
*
* @param blockDelim
* The regex that separates blocks.
*
* @param source
* The reader to get blocks from.
*
* @return A configured simple reader.
*/
public static SimpleBlockReader simple(String blockDelim, Reader source) {
return new SimpleBlockReader(blockDelim, source);
}
/**
* Create a new pushback block reader.
*
* @param src
* The block reader to read blocks from.
*
* @return A configured pushback reader.
*/
public static PushbackBlockReader pushback(BlockReader src) {
return new PushbackBlockReader(src);
}
/**
* Create a new triggered block reader.
*
* @param source
* The block reader to read blocks from.
*
* @param action
* The action to execute before reading a block.
*
* @return A configured triggered block reader.
*/
public static BlockReader trigger(BlockReader source, Runnable action) {
return new TriggeredBlockReader(source, action);
}
/**
* Create a new layered block reader.
*
* @param primary
* The first source to read blocks from.
*
* @param secondary
* The second source to read blocks from.
*
* @return A configured layered block reader.
*/
public static BlockReader layered(BlockReader primary, BlockReader secondary) {
return new LayeredBlockReader(primary, secondary);
}
/**
* Create a new serial block reader.
*
* @param readers
* The readers to pull from, in the order to pull from
* them.
*
* @return A configured serial block reader.
*/
public static BlockReader serial(BlockReader... readers) {
return new SerialBlockReader(readers);
}
}
|