private <I, SP, TP, A extends MutableAutomaton<?, I, ?, SP, TP>> A readAutomatonBody(Alphabet<I> alphabet, boolean deterministic, AutomatonCreator<? extends A, I> creator, BlockPropertyDecoder<? extends SP> spDecoder, SinglePropertyDecoder<? extends TP> tpDecoder) throws IOException { int numStates = in.readInt(); A result = creator.createAutomaton(alphabet, numStates); // this cast is required .. final MutableAutomaton<?, I, ?, SP, TP> resultWithCorrectType = result; if (deterministic) { decodeBodyDet(resultWithCorrectType, alphabet, numStates, spDecoder, tpDecoder); } else { decodeBodyNondet(resultWithCorrectType, alphabet, numStates, spDecoder, tpDecoder); } return result; }
private <S, SP> List<S> decodeStatesNondet(MutableAutomaton<S, ?, ?, SP, ?> result, int numStates, BlockPropertyDecoder<? extends SP> decoder) throws IOException { int[] initStates = readInts(in); List<S> stateList = decodeStateProperties(result, numStates, decoder); for (int initId : initStates) { S initState = stateList.get(initId); result.setInitial(initState, true); } return stateList; }
private <S, I, SP, TP> List<S> decodeBodyDet(MutableAutomaton<S, I, ?, SP, TP> result, Alphabet<I> alphabet, int numStates, BlockPropertyDecoder<? extends SP> spDecoder, SinglePropertyDecoder<? extends TP> tpDecoder) throws IOException { List<S> stateList = decodeStatesDet(result, numStates, spDecoder); decodeTransitionsDet(result, stateList, alphabet, tpDecoder); return stateList; }
private <S, I, SP, TP> List<S> decodeBodyNondet(MutableAutomaton<S, I, ?, SP, TP> result, Alphabet<I> alphabet, int numStates, BlockPropertyDecoder<? extends SP> spDecoder, SinglePropertyDecoder<? extends TP> tpDecoder) throws IOException { List<S> stateList = decodeStatesNondet(result, numStates, spDecoder); decodeTransitionsNondet(result, stateList, alphabet, tpDecoder); return stateList; }
public <I, SP, TP, A extends MutableAutomaton<?, I, ?, SP, TP>> A readAutomaton(AutomatonType expectedType, Alphabet<I> alphabet, AutomatonCreator<? extends A, I> creator, BlockPropertyDecoder<? extends SP> spDecoder, SinglePropertyDecoder<? extends TP> tpDecoder) throws IOException { AutomatonType type = readHeader(); if (type != expectedType) { throw new AutomatonSerializationException(); } int alphabetSize = in.readInt(); if (alphabetSize != alphabet.size()) { throw new AutomatonSerializationException(); } return readAutomatonBody(alphabet, type.isDeterministic(), creator, spDecoder, tpDecoder); }
@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()); }
public <I> CompactNFA<I> readNFA(Alphabet<I> alphabet) throws IOException { return readAutomaton(AutomatonType.NFA, alphabet, new CompactNFA.Creator<>(), new AcceptanceDecoder(), SinglePropertyDecoder.nullDecoder()); }
private <S, SP> List<S> decodeStatesDet(MutableAutomaton<S, ?, ?, SP, ?> result, int numStates, BlockPropertyDecoder<? extends SP> decoder) throws IOException { int initStateId = in.readInt(); List<S> stateList = decodeStateProperties(result, numStates, decoder); S initState = stateList.get(initStateId); result.setInitial(initState, true); return stateList; }
public <SP, TP, A extends MutableAutomaton<?, Integer, ?, SP, TP>> A readNativeAutomaton(AutomatonType expectedType, AutomatonCreator<? extends A, Integer> creator, BlockPropertyDecoder<? extends SP> spDecoder, SinglePropertyDecoder<? extends TP> tpDecoder) throws IOException { AutomatonType type = readHeader(); if (type != expectedType) { throw new AutomatonSerializationException(); } int alphabetSize = in.readInt(); if (alphabetSize <= 0) { throw new AutomatonSerializationException(); } Alphabet<Integer> alphabet = Alphabets.integers(0, alphabetSize - 1); return readAutomatonBody(alphabet, type.isDeterministic(), creator, spDecoder, tpDecoder); }
@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()); }
private <S, I, SP, TP> List<S> decodeBodyNondet(MutableAutomaton<S, I, ?, SP, TP> result, Alphabet<I> alphabet, int numStates, BlockPropertyDecoder<? extends SP> spDecoder, SinglePropertyDecoder<? extends TP> tpDecoder) throws IOException { List<S> stateList = decodeStatesNondet(result, numStates, spDecoder); decodeTransitionsNondet(result, stateList, alphabet, tpDecoder); return stateList; }
@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()); }
public <I> CompactDFA<I> readDFA(Alphabet<I> alphabet) throws IOException { return readAutomaton(AutomatonType.DFA, alphabet, new CompactDFA.Creator<>(), new AcceptanceDecoder(), SinglePropertyDecoder.nullDecoder()); }
private <S, SP> List<S> decodeStatesDet(MutableAutomaton<S, ?, ?, SP, ?> result, int numStates, BlockPropertyDecoder<? extends SP> decoder) throws IOException { int initStateId = in.readInt(); List<S> stateList = decodeStateProperties(result, numStates, decoder); S initState = stateList.get(initStateId); result.setInitial(initState, true); return stateList; }
public <I, SP, TP, A extends MutableAutomaton<?, I, ?, SP, TP>> A readAutomaton(AutomatonType expectedType, Alphabet<I> alphabet, AutomatonCreator<? extends A, I> creator, BlockPropertyDecoder<? extends SP> spDecoder, SinglePropertyDecoder<? extends TP> tpDecoder) throws IOException { AutomatonType type = readHeader(); if (type != expectedType) { throw new AutomatonSerializationException(); } int alphabetSize = in.readInt(); if (alphabetSize != alphabet.size()) { throw new AutomatonSerializationException(); } return readAutomatonBody(alphabet, type.isDeterministic(), creator, spDecoder, tpDecoder); }
private <S, SP> List<S> decodeStatesNondet(MutableAutomaton<S, ?, ?, SP, ?> result, int numStates, BlockPropertyDecoder<? extends SP> decoder) throws IOException { int[] initStates = readInts(in); List<S> stateList = decodeStateProperties(result, numStates, decoder); for (int initId : initStates) { S initState = stateList.get(initId); result.setInitial(initState, true); } return stateList; }
private <S, I, SP, TP> List<S> decodeBodyDet(MutableAutomaton<S, I, ?, SP, TP> result, Alphabet<I> alphabet, int numStates, BlockPropertyDecoder<? extends SP> spDecoder, SinglePropertyDecoder<? extends TP> tpDecoder) throws IOException { List<S> stateList = decodeStatesDet(result, numStates, spDecoder); decodeTransitionsDet(result, stateList, alphabet, tpDecoder); return stateList; }
private <I, SP, TP, A extends MutableAutomaton<?, I, ?, SP, TP>> A readAutomatonBody(Alphabet<I> alphabet, boolean deterministic, AutomatonCreator<? extends A, I> creator, BlockPropertyDecoder<? extends SP> spDecoder, SinglePropertyDecoder<? extends TP> tpDecoder) throws IOException { int numStates = in.readInt(); A result = creator.createAutomaton(alphabet, numStates); // this cast is required .. final MutableAutomaton<?, I, ?, SP, TP> resultWithCorrectType = result; if (deterministic) { decodeBodyDet(resultWithCorrectType, alphabet, numStates, spDecoder, tpDecoder); } else { decodeBodyNondet(resultWithCorrectType, alphabet, numStates, spDecoder, tpDecoder); } return result; }
public <I> CompactDFA<I> readDFA(Alphabet<I> alphabet) throws IOException { return readAutomaton(AutomatonType.DFA, alphabet, new CompactDFA.Creator<>(), new AcceptanceDecoder(), SinglePropertyDecoder.nullDecoder()); }