Package com.yahoo.fsa

Class FSA

    • Method Detail

      • iterator

        public FSA.Iterator iterator()
        Returns a new iterator to the start state.
      • iterator

        public FSA.Iterator iterator​(FSA.State state)
        Returns a new iterator to the given state.
        Parameters:
        state - the state to create the iterator from.
      • loadFromResource

        public static FSA loadFromResource​(String resourceFileName,
                                           Class<?> loadingClass)
        Loads an FSA from a resource file name, which is resolved from the class path of the class loader of the given class.

        This is useful for loading fsa's deployed within OSGi bundles.

        Parameters:
        resourceFileName - the name of the file, relative to any element on the classpath. For example, if the classpath contains resources/ and the file is resources/myfsa.fsa this argument should be myfsa.fsa
        loadingClass - a class which provides the class loader to use for loading. Any class which is loaded from the same class path as the resource will do (e.g with OSGi - any class in the same bundle jar)
        Returns:
        the loaded FSA
        Throws:
        RuntimeException - if the class could not be loaded
      • isOk

        public boolean isOk()
      • hasPerfectHash

        public boolean hasPerfectHash()
      • version

        public int version()
      • serial

        public int serial()
      • start

        protected int start()
      • delta

        protected int delta​(int state,
                            byte symbol)
      • hashDelta

        protected int hashDelta​(int state,
                                byte symbol)
      • isFinal

        protected boolean isFinal​(int state)
      • data

        protected ByteBuffer data​(int state)
        Retrieves data for the given state using the underlying fsa data buffer.
        Parameters:
        state - The fsa state to retrieve data from.
        Returns:
        A new buffer containing the data for the given state.
      • dataString

        protected String dataString​(int state)
        Retrieves data for the given state using the underlying fsa data buffer.
        Parameters:
        state - The fsa state to retrieve data from.
        Returns:
        A string representation of the data for the given state.
      • lookup

        public String lookup​(String str)
        Convenience method that returns the metadata string in the fsa for the input lookup String, or null if the input string does not exist in the fsa.
        Parameters:
        str - The string to look up.
        Returns:
        Metadata string from the fsa.
      • main

        public static void main​(String[] args)