import java.util.*; class Transition { public Transition (State destintation) { _symbolList = new LinkedList(); _destination = destintation; } public boolean isRedundant (Transition transition) { // Iterate through the symbols of the other transition. ListIterator i = null; try { i = transition._symbolList.listIterator(0); } catch (IndexOutOfBoundsException e) { i = null; } while (i != null) { // Grab the current symbol from the other transition. Character current = null; try { current = (Character)i.next(); } catch (NoSuchElementException e) { i = null; continue; } // Do the symbols match? if (testSymbol(current.charValue())) { return true; } } // The symbol was not found. return false; } public boolean testSymbol (char c) { // Iterate through the symbols. ListIterator i = null; try { i = _symbolList.listIterator(0); } catch (IndexOutOfBoundsException e) { i = null; } while (i != null) { // Test the current symbol. Character current = null; try { current = (Character)i.next(); } catch (NoSuchElementException e) { i = null; continue; } // Is this the symbol? if (c == current.charValue()) { return true; } } // The symbol was not found. return false; } public State followTransition () { return _destination; } public void addSymbol (char c) { _symbolList.add(new Character(c)); } protected LinkedList _symbolList; protected State _destination; }