@Override default void writeModel(OutputStream os, InputModelData<I, M> model) throws IOException { writeModel(os, model.model, model.alphabet); } }
private AutomatonType readHeader() throws IOException { final int headerSize = 4; byte[] header = new byte[headerSize]; in.readFully(header); if (header[0] != 'S' || header[1] != 'A' || header[2] != 'F') { throw new AutomatonSerializationException(); } byte type = header[3]; if (type < 0 || type >= TYPES.length) { throw new AutomatonSerializationException(); } return TYPES[type]; }
default M readModel(URL url) throws IOException { try (InputStream is = url.openStream()) { return readModel(is); } }
@Override public InputModelData<Integer, DFA<Integer, Integer>> readModel(InputStream is) throws IOException { final CompactDFA<Integer> automaton = readGenericDFA(is); return new InputModelData<>(automaton, automaton.getInputAlphabet()); }
@Override public InputModelData<String, MealyMachine<?, String, ?, String>> readModel(InputStream is) throws IOException { final CompactMealy<String, String> automaton = TAFParser.parseMealy(is, PrintStreamDiagnosticListener.getStderrDiagnosticListener()); return new InputModelData<>(automaton, automaton.getInputAlphabet()); } }
@Override public InputModelData<String, DFA<Integer, String>> readModel(InputStream is) throws IOException { final CompactDFA<String> automaton = TAFParser.parseDFA(is, PrintStreamDiagnosticListener.getStderrDiagnosticListener()); return new InputModelData<>(automaton, automaton.getInputAlphabet()); } }
@Override public InputModelData<Integer, DFA<Integer, Integer>> readModel(InputStream is) throws IOException { final InputStream uncompressedStream = IOUtil.asUncompressedInputStream(is); SAFInput in = new SAFInput(uncompressedStream); final CompactDFA<Integer> automaton = in.readNativeDFA(); return new InputModelData<>(automaton, automaton.getInputAlphabet()); }
@Override public InputModelData<Integer, NFA<Integer, Integer>> readModel(InputStream is) throws IOException { final InputStream uncompressedStream = IOUtil.asUncompressedInputStream(is); SAFInput in = new SAFInput(uncompressedStream); final CompactNFA<Integer> automaton = in.readNativeNFA(); return new InputModelData<>(automaton, automaton.getInputAlphabet()); }
default void writeModel(File f, M model) throws IOException { try (FileOutputStream os = new FileOutputStream(f)) { writeModel(os, model); } }
@Override public InputModelData<Integer, DFA<Integer, Integer>> readModel(InputStream is) throws IOException { final CompactDFA<Integer> automaton = readGenericDFA(is); return new InputModelData<>(automaton, automaton.getInputAlphabet()); }
default M readModel(URL url) throws IOException { try (InputStream is = url.openStream()) { return readModel(is); } }
@Override default void writeModel(OutputStream os, InputModelData<I, M> model) throws IOException { writeModel(os, model.model, model.alphabet); } }
default void writeModel(File f, M model) throws IOException { try (OutputStream os = IOUtil.asBufferedOutputStream(f)) { writeModel(os, model); } }
private AutomatonType readHeader() throws IOException { final int headerSize = 4; byte[] header = new byte[headerSize]; in.readFully(header); if (header[0] != 'S' || header[1] != 'A' || header[2] != 'F') { throw new AutomatonSerializationException(); } byte type = header[3]; if (type < 0 || type >= TYPES.length) { throw new AutomatonSerializationException(); } return TYPES[type]; }
default M readModel(File f) throws IOException { try (FileInputStream is = new FileInputStream(f)) { return readModel(is); } }
default void writeModel(File f, M model, Alphabet<I> alphabet) throws IOException { try (FileOutputStream os = new FileOutputStream(f)) { writeModel(os, model, alphabet); } }
default M readModel(byte[] buf) throws IOException { try (ByteArrayInputStream is = new ByteArrayInputStream(buf)) { return readModel(is); } }
default void writeModel(File f, M model, Alphabet<I> alphabet) throws IOException { try (OutputStream os = IOUtil.asBufferedOutputStream(f)) { writeModel(os, model, alphabet); } }
default M readModel(byte[] buf) throws IOException { try (ByteArrayInputStream is = new ByteArrayInputStream(buf)) { return readModel(is); } }
default M readModel(File f) throws IOException { try (InputStream is = IOUtil.asBufferedInputStream(f)) { return readModel(is); } }