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]; }
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]; }
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); }
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); }
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); }
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); }