|
| 1 | +package com.bufferedreader; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | +import java.io.Reader; |
| 5 | +import java.util.stream.Stream; |
| 6 | + |
| 7 | +import liquidjava.specification.ExternalRefinementsFor; |
| 8 | +import liquidjava.specification.Refinement; |
| 9 | +import liquidjava.specification.RefinementAlias; |
| 10 | +import liquidjava.specification.StateRefinement; |
| 11 | +import liquidjava.specification.StateSet; |
| 12 | + |
| 13 | +@RefinementAlias("NonNegative(int v) { v >= 0 }") |
| 14 | +@RefinementAlias("Positive(int v) { v > 0 }") |
| 15 | +@StateSet({"open", "marked", "closed"}) |
| 16 | +@ExternalRefinementsFor("java.io.BufferedReader") |
| 17 | +public interface BufferedReaderRefinements { |
| 18 | + |
| 19 | + @StateRefinement(to="open(this)") |
| 20 | + public void BufferedReader(Reader in); |
| 21 | + |
| 22 | + @StateRefinement(to="open(this)") |
| 23 | + public void BufferedReader(Reader in, @Refinement("Positive(_)") int sz); |
| 24 | + |
| 25 | + @StateRefinement(from="open(this)", to="open(this)") |
| 26 | + @StateRefinement(from="marked(this)", to="marked(this)") |
| 27 | + public int read() throws IOException; |
| 28 | + |
| 29 | + @StateRefinement(from="open(this)", to="open(this)") |
| 30 | + @StateRefinement(from="marked(this)", to="marked(this)") |
| 31 | + public int read(char[] cbuf, @Refinement("NonNegative(_)") int off, @Refinement("NonNegative(_)") int len) throws IOException; // cant write "|| len <= cbuf.length - off" |
| 32 | + |
| 33 | + @StateRefinement(from="open(this)", to="open(this)") |
| 34 | + @StateRefinement(from="marked(this)", to="marked(this)") |
| 35 | + public String readLine() throws IOException; |
| 36 | + |
| 37 | + @StateRefinement(from="open(this)", to="open(this)") |
| 38 | + @StateRefinement(from="marked(this)", to="marked(this)") |
| 39 | + public boolean ready() throws IOException; |
| 40 | + |
| 41 | + @StateRefinement(from="open(this)", to="open(this)") |
| 42 | + @StateRefinement(from="marked(this)", to="marked(this)") |
| 43 | + public boolean markSupported(); |
| 44 | + |
| 45 | + @StateRefinement(from="open(this)", to="marked(this)") |
| 46 | + @StateRefinement(from="marked(this)", to="marked(this)") |
| 47 | + public void mark(@Refinement("NonNegative(_)") int readAheadLimit) throws IOException; |
| 48 | + |
| 49 | + @StateRefinement(from="marked(this)", to="open(this)") |
| 50 | + public void reset() throws IOException; |
| 51 | + |
| 52 | + @StateRefinement(from="!closed(this)", to="closed(this)") |
| 53 | + public void close() throws IOException; |
| 54 | + |
| 55 | + @StateRefinement(from="open(this)", to="open(this)") |
| 56 | + @StateRefinement(from="marked(this)", to="marked(this)") |
| 57 | + public Stream<String> lines(); |
| 58 | +} |
0 commit comments