Class FileWordList

  • All Implemented Interfaces:
    WordList

    public class FileWordList
    extends AbstractFileWordList
    Provides an implementation of a WordList that is backed by a file. Each word is read from the file for every get, though the implementation supports a simple memory cache to improve read performance. This implementation should be avoided for files greater than 100MB in size.
    Author:
    Middleware Services
    • Constructor Detail

      • FileWordList

        public FileWordList​(RandomAccessFile raf)
                     throws IOException
        Creates a new case-sensitive word list from the supplied file. The input file is read on initialization and is maintained by this class.

        NOTE Attempts to close the source file will cause IOException when AbstractFileWordList.get(int) is called subsequently.

        Parameters:
        raf - File containing words, one per line.
        Throws:
        IOException - if an error occurs reading the supplied file
      • FileWordList

        public FileWordList​(RandomAccessFile raf,
                            boolean caseSensitive)
                     throws IOException
        Creates a new word list from the supplied file. The input file is read on initialization and is maintained by this class.

        NOTE Attempts to close the source file will cause IOException when AbstractFileWordList.get(int) is called subsequently.

        Parameters:
        raf - File containing words, one per line.
        caseSensitive - Set to true to create case-sensitive word list, false otherwise.
        Throws:
        IOException - if an error occurs reading the supplied file
      • FileWordList

        public FileWordList​(RandomAccessFile raf,
                            boolean caseSensitive,
                            int cachePercent)
                     throws IOException
        Creates a new word list from the supplied file. The input file is read on initialization and is maintained by this class. cachePercent is a percentage of the file size in bytes.

        NOTE Attempts to close the source file will cause IOException when AbstractFileWordList.get(int) is called subsequently.

        Parameters:
        raf - File containing words, one per line.
        caseSensitive - Set to true to create case-sensitive word list, false otherwise.
        cachePercent - Percent (0-100) of file to cache in memory for improved read performance.
        Throws:
        IllegalArgumentException - if cache percent is out of range.
        IOException - if an error occurs reading the supplied file
      • FileWordList

        public FileWordList​(RandomAccessFile raf,
                            boolean caseSensitive,
                            int cachePercent,
                            CharsetDecoder decoder)
                     throws IOException
        Creates a new word list from the supplied file. The input file is read on initialization and is maintained by this class. cachePercent is a percentage of the file size in bytes.

        NOTE Attempts to close the source file will cause IOException when AbstractFileWordList.get(int) is called subsequently.

        Parameters:
        raf - File containing words, one per line.
        caseSensitive - Set to true to create case-sensitive word list, false otherwise.
        cachePercent - Percent (0-100) of file to cache in memory for improved read performance.
        decoder - Charset decoder for converting file bytes to characters
        Throws:
        IllegalArgumentException - if cache percent is out of range.
        IOException - if an error occurs reading the supplied file
      • FileWordList

        public FileWordList​(RandomAccessFile raf,
                            boolean caseSensitive,
                            int cachePercent,
                            CharsetDecoder decoder,
                            boolean allocateDirect)
                     throws IOException
        Creates a new word list from the supplied file. The input file is read on initialization and is maintained by this class. cachePercent is a percentage of the file size in bytes.

        NOTE Attempts to close the source file will cause IOException when AbstractFileWordList.get(int) is called subsequently.

        Parameters:
        raf - File containing words, one per line.
        caseSensitive - Set to true to create case-sensitive word list, false otherwise.
        cachePercent - Percent (0-100) of file to cache in memory for improved read performance.
        decoder - Charset decoder for converting file bytes to characters
        allocateDirect - whether buffers should be allocated with ByteBuffer.allocateDirect(int)
        Throws:
        IllegalArgumentException - if cache percent is out of range.
        IOException - if an error occurs reading the supplied file