morfologik.fsa
Class CFSA2Serializer

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

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

Serializes in-memory FSA graphs to CFSA2.

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

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

Constructor Summary
CFSA2Serializer()
           
 
Method Summary
 java.util.Set<FSAFlags> getFlags()
          Return supported flags.
<T extends java.io.OutputStream>
T
serialize(FSA fsa, T os)
          Serializes any FSA to CFSA2 stream.
 CFSA2Serializer withAnnotationSeparator(byte annotationSeparator)
          Supports built-in annotation separator.
 CFSA2Serializer withFiller(byte filler)
          Supports built-in filler separator.
 CFSA2Serializer withLogger(IMessageLogger logger)
          Log extra messages during construction.
 CFSA2Serializer 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
 

Constructor Detail

CFSA2Serializer

public CFSA2Serializer()
Method Detail

withNumbers

public CFSA2Serializer 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.

serialize

public <T extends java.io.OutputStream> T serialize(FSA fsa,
                                                    T os)
                                         throws java.io.IOException
Serializes any FSA to CFSA2 stream.

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

withFiller

public CFSA2Serializer withFiller(byte filler)
Description copied from interface: FSASerializer
Supports built-in filler separator. Only if FSASerializer.getFlags() returns FSAFlags.SEPARATORS.

Specified by:
withFiller in interface FSASerializer

withAnnotationSeparator

public CFSA2Serializer withAnnotationSeparator(byte annotationSeparator)
Description copied from interface: FSASerializer
Supports built-in annotation separator. Only if FSASerializer.getFlags() returns FSAFlags.SEPARATORS.

Specified by:
withAnnotationSeparator in interface FSASerializer

withLogger

public CFSA2Serializer withLogger(IMessageLogger logger)
Description copied from interface: FSASerializer
Log extra messages during construction.

Specified by:
withLogger in interface FSASerializer