Finite state dictionaries in Java