Class StemmerPatchTrieBinaryIO

java.lang.Object
org.egothor.stemmer.StemmerPatchTrieBinaryIO

public final class StemmerPatchTrieBinaryIO extends Object
Binary persistence helper for patch-command stemmer tries.

This class persists FrequencyTrie instances whose values are compact patch commands represented as String. The serialized trie payload is the native binary format of FrequencyTrie, wrapped in GZip compression.

The helper centralizes the codec and compression details so that higher-level loader APIs can remain focused on source selection rather than stream mechanics.

  • Method Details

    • read

      public static FrequencyTrie<String> read(Path path) throws IOException
      Reads a GZip-compressed binary patch-command trie from a filesystem path.
      Parameters:
      path - source file
      Returns:
      deserialized trie
      Throws:
      NullPointerException - if path is null
      IOException - if reading or decompression fails
    • read

      public static FrequencyTrie<String> read(String fileName) throws IOException
      Reads a GZip-compressed binary patch-command trie from a filesystem path string.
      Parameters:
      fileName - source file name or path string
      Returns:
      deserialized trie
      Throws:
      NullPointerException - if fileName is null
      IOException - if reading or decompression fails
    • read

      public static FrequencyTrie<String> read(InputStream inputStream) throws IOException
      Reads a GZip-compressed binary patch-command trie from an input stream.

      The supplied stream is consumed but not interpreted as plain trie bytes; it is first decompressed using GZIPInputStream.

      Parameters:
      inputStream - source stream
      Returns:
      deserialized trie
      Throws:
      NullPointerException - if inputStream is null
      IOException - if reading or decompression fails
    • readMetadata

      public static TrieMetadata readMetadata(Path path) throws IOException
      Reads only metadata from a GZip-compressed binary patch-command trie stored at a filesystem path.
      Parameters:
      path - source file
      Returns:
      deserialized trie metadata
      Throws:
      NullPointerException - if path is null
      IOException - if reading or decompression fails
    • readMetadata

      public static TrieMetadata readMetadata(String fileName) throws IOException
      Reads only metadata from a GZip-compressed binary patch-command trie stored at a filesystem path string.
      Parameters:
      fileName - source file name or path string
      Returns:
      deserialized trie metadata
      Throws:
      NullPointerException - if fileName is null
      IOException - if reading or decompression fails
    • readMetadata

      public static TrieMetadata readMetadata(InputStream inputStream) throws IOException
      Reads only metadata from a GZip-compressed binary patch-command trie from an input stream.
      Parameters:
      inputStream - source stream
      Returns:
      deserialized trie metadata
      Throws:
      NullPointerException - if inputStream is null
      IOException - if reading or decompression fails
    • write

      public static void write(FrequencyTrie<String> trie, Path path) throws IOException
      Writes a GZip-compressed binary patch-command trie to a filesystem path.
      Parameters:
      trie - trie to persist
      path - target file
      Throws:
      NullPointerException - if any argument is null
      IOException - if writing fails
    • write

      public static void write(FrequencyTrie<String> trie, String fileName) throws IOException
      Writes a GZip-compressed binary patch-command trie to a filesystem path string.
      Parameters:
      trie - trie to persist
      fileName - target file name or path string
      Throws:
      NullPointerException - if any argument is null
      IOException - if writing fails
    • write

      public static void write(FrequencyTrie<String> trie, OutputStream outputStream) throws IOException
      Writes a GZip-compressed binary patch-command trie to an output stream.
      Parameters:
      trie - trie to persist
      outputStream - target stream
      Throws:
      NullPointerException - if any argument is null
      IOException - if writing fails