|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| package org.sat4j.reader; |
|
8 |
| |
|
9 |
| import java.io.FileInputStream; |
|
10 |
| import java.io.FileNotFoundException; |
|
11 |
| import java.io.IOException; |
|
12 |
| import java.io.InputStream; |
|
13 |
| import java.io.InputStreamReader; |
|
14 |
| import java.net.URL; |
|
15 |
| import java.util.zip.GZIPInputStream; |
|
16 |
| |
|
17 |
| import org.sat4j.specs.ContradictionException; |
|
18 |
| import org.sat4j.specs.IProblem; |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| public abstract class Reader { |
|
27 |
| |
|
28 |
2491
| public IProblem parseInstance(final String filename)
|
|
29 |
| throws FileNotFoundException, ParseFormatException, IOException, |
|
30 |
| ContradictionException { |
|
31 |
2491
| InputStream in;
|
|
32 |
2491
| if (filename.startsWith("http://")) {
|
|
33 |
0
| in = (new URL(filename)).openStream();
|
|
34 |
| } else { |
|
35 |
2491
| in = new FileInputStream(filename);
|
|
36 |
| } |
|
37 |
2491
| if (filename.endsWith(".gz")) {
|
|
38 |
0
| in = new GZIPInputStream(in);
|
|
39 |
| } |
|
40 |
2491
| return parseInstance(in);
|
|
41 |
| } |
|
42 |
| |
|
43 |
828
| public IProblem parseInstance(final InputStream in)
|
|
44 |
| throws ParseFormatException, ContradictionException, IOException { |
|
45 |
828
| return parseInstance(new InputStreamReader(in));
|
|
46 |
| } |
|
47 |
| |
|
48 |
| public abstract IProblem parseInstance(final java.io.Reader in) |
|
49 |
| throws ParseFormatException, ContradictionException, IOException; |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| public abstract String decode(int[] model); |
|
59 |
| } |