public class FSA extends Object
Modifier and Type | Class and Description |
---|---|
static class |
FSA.Iterator
Class used to iterate over all accepted strings in the fsa.
|
static class |
FSA.State
Thread local state object used to traverse a Finite-State Automaton.
|
Constructor and Description |
---|
FSA(FileInputStream filename)
Loads an FSA from a file input stream using utf-8 encoding
|
FSA(FileInputStream filename,
String charsetname)
Loads an FSA from a file input stream using the specified character encoding
|
FSA(String filename)
Loads an FSA from a file using utf-8 encoding
|
FSA(String filename,
String charsetname)
Loads an FSA from a file using the specified character encoding.
|
Modifier and Type | Method and Description |
---|---|
protected ByteBuffer |
data(int state)
Retrieves data for the given state using the underlying fsa data buffer.
|
protected String |
dataString(int state)
Retrieves data for the given state using the underlying fsa data buffer.
|
protected int |
delta(int state,
byte symbol) |
FSA.State |
getState() |
protected int |
hashDelta(int state,
byte symbol) |
boolean |
hasPerfectHash() |
protected boolean |
isFinal(int state) |
boolean |
isOk() |
FSA.Iterator |
iterator()
Returns a new iterator to the start state.
|
FSA.Iterator |
iterator(FSA.State state)
Returns a new iterator to the given state.
|
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.
|
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.
|
static void |
main(String[] args) |
int |
serial() |
protected int |
start() |
int |
version() |
public FSA(String filename)
IllegalArgumentException
- if the file is not foundpublic FSA(String filename, String charsetname)
IllegalArgumentException
- if the file is not foundpublic FSA(FileInputStream filename)
public FSA(FileInputStream filename, String charsetname)
public FSA.State getState()
public FSA.Iterator iterator()
public FSA.Iterator iterator(FSA.State state)
state
- the state to create the iterator from.public static FSA loadFromResource(String resourceFileName, Class loadingClass)
This is useful for loading fsa's deployed within OSGi bundles.
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.fsaloadingClass
- 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)RuntimeException
- if the class could not be loadedpublic boolean isOk()
public boolean hasPerfectHash()
public int version()
public int serial()
protected int start()
protected int delta(int state, byte symbol)
protected int hashDelta(int state, byte symbol)
protected boolean isFinal(int state)
protected ByteBuffer data(int state)
state
- The fsa state to retrieve data from.protected String dataString(int state)
state
- The fsa state to retrieve data from.public String lookup(String str)
str
- The string to look up.public static void main(String[] args)
Copyright © 2018. All rights reserved.