morfologik.fsa
Class FSA5Serializer

java.lang.Object
  extended by morfologik.fsa.FSA5Serializer
All Implemented Interfaces:
FSASerializer

public final class FSA5Serializer
extends java.lang.Object
implements FSASerializer

Serializes in-memory FSA graphs to a binary format compatible with Jan Daciuk's fsa's package FSA5 format.

It is possible to serialize the automaton with numbers required for perfect hashing. See withNumbers() method.

See Also:
FSA5, FSA.read(java.io.InputStream)

Field Summary
 byte annotationByte
           
 byte fillerByte
           
 
Constructor Summary
FSA5Serializer()
           
 
Method Summary
 java.util.Set<FSAFlags> getFlags()
          Return supported flags.
<T extends java.io.OutputStream>
T
serialize(FSA fsa, T os)
          Serialize root state s to an output stream in FSA5 format.
 FSA5Serializer withAnnotationSeparator(byte annotationSeparator)
          Supports built-in annotation separator.
 FSA5Serializer withFiller(byte filler)
          Supports built-in filler separator.
 FSASerializer withLogger(IMessageLogger logger)
          Log extra messages during construction.
 FSA5Serializer withNumbers()
          Serialize the automaton with the number of right-language sequences in each node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fillerByte

public byte fillerByte
See Also:
FSA5.filler

annotationByte

public byte annotationByte
See Also:
FSA5.annotation
Constructor Detail

FSA5Serializer

public FSA5Serializer()
Method Detail

withNumbers

public FSA5Serializer withNumbers()
Serialize the automaton with the number of right-language sequences in each node. This is required to implement perfect hashing. The numbering also preserves the order of input sequences.

Specified by:
withNumbers in interface FSASerializer
Returns:
Returns the same object for easier call chaining.

withFiller

public FSA5Serializer withFiller(byte filler)
Supports built-in filler separator. Only if FSASerializer.getFlags() returns FSAFlags.SEPARATORS.

Specified by:
withFiller in interface FSASerializer

withAnnotationSeparator

public FSA5Serializer withAnnotationSeparator(byte annotationSeparator)
Supports built-in annotation separator. Only if FSASerializer.getFlags() returns FSAFlags.SEPARATORS.

Specified by:
withAnnotationSeparator in interface FSASerializer

withLogger

public FSASerializer withLogger(IMessageLogger logger)
Log extra messages during construction.

Specified by:
withLogger in interface FSASerializer

serialize

public <T extends java.io.OutputStream> T serialize(FSA fsa,
                                                    T os)
                                         throws java.io.IOException
Serialize root state s to an output stream in FSA5 format.

Specified by:
serialize in interface FSASerializer
Returns:
Returns os for chaining.
Throws:
java.io.IOException
See Also:
withNumbers

getFlags

public java.util.Set<FSAFlags> getFlags()
Return supported flags.

Specified by:
getFlags in interface FSASerializer