| 1 |
package morfologik.fsa.builders; |
| 2 |
|
| 3 |
import java.io.IOException; |
| 4 |
import java.io.OutputStream; |
| 5 |
import java.util.Set; |
| 6 |
|
| 7 |
import morfologik.fsa.FSA; |
| 8 |
import morfologik.fsa.FSAFlags; |
| 9 |
|
| 10 |
/** |
| 11 |
* All FSA serializers (to binary formats) will implement this interface. |
| 12 |
*/ |
| 13 |
public interface FSASerializer { |
| 14 |
/** |
| 15 |
* Serialize a finite state automaton to an output stream. |
| 16 |
* |
| 17 |
* @param fsa The automaton to serialize. |
| 18 |
* @param os The output stream to serialize to. |
| 19 |
* @param <T> A subclass of {@link OutputStream}, returned for chaining. |
| 20 |
* @return Returns <code>T</code> for chaining. |
| 21 |
* @throws IOException Rethrown if an I/O error occurs. |
| 22 |
*/ |
| 23 |
public <T extends OutputStream> T serialize(FSA fsa, T os) throws IOException; |
| 24 |
|
| 25 |
/** |
| 26 |
* @return Returns the set of flags supported by the serializer (and the output |
| 27 |
* automaton). |
| 28 |
*/ |
| 29 |
public Set<FSAFlags> getFlags(); |
| 30 |
|
| 31 |
/** |
| 32 |
* Sets the filler separator (only if {@link #getFlags()} returns |
| 33 |
* {@link FSAFlags#SEPARATORS}). |
| 34 |
* |
| 35 |
* @param filler The filler separator byte. |
| 36 |
* @return Returns <code>this</code> for call chaining. |
| 37 |
*/ |
| 38 |
public FSASerializer withFiller(byte filler); |
| 39 |
|
| 40 |
/** |
| 41 |
* Sets the annotation separator (only if {@link #getFlags()} returns |
| 42 |
* {@link FSAFlags#SEPARATORS}). |
| 43 |
* |
| 44 |
* @param annotationSeparator The filler separator byte. |
| 45 |
* @return Returns <code>this</code> for call chaining. |
| 46 |
*/ |
| 47 |
public FSASerializer withAnnotationSeparator(byte annotationSeparator); |
| 48 |
|
| 49 |
/** |
| 50 |
* Enables support for right language count on nodes, speeding up perfect hash |
| 51 |
* counts (only if {@link #getFlags()} returns {@link FSAFlags#NUMBERS}). |
| 52 |
* |
| 53 |
* @return Returns <code>this</code> for call chaining. |
| 54 |
*/ |
| 55 |
public FSASerializer withNumbers(); |
| 56 |
} |