Example usage for org.apache.lucene.util.automaton Transition toString

List of usage examples for org.apache.lucene.util.automaton Transition toString

Introduction

In this page you can find the example usage for org.apache.lucene.util.automaton Transition toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.eu.bitzone.Leia.java

License:Apache License

private void addAutomaton(final Object parent, final Automaton a) {
    final Object n = create("node");
    setString(n, "text", "Automaton: " + a != null ? a.toDot() : "null");
    add(parent, n);/*ww  w .  ja  va 2 s.  c  o  m*/
    final State[] states = a.getNumberedStates();
    for (final State s : states) {
        final Object n1 = create("node");
        add(n, n1);
        final StringBuilder msg = new StringBuilder();
        msg.append(String.valueOf(s.getNumber()));
        if (a.getInitialState() == s) {
            msg.append(" INITIAL");
        }
        msg.append(s.isAccept() ? " [accept]" : " [reject]");
        msg.append(", " + s.numTransitions + " transitions");
        setString(n1, "text", msg.toString());
        for (final Transition t : s.getTransitions()) {
            final Object n2 = create("node");
            add(n1, n2);
            setString(n2, "text", t.toString());
        }
    }
}

From source file:org.getopt.luke.Luke.java

License:Apache License

private void addAutomaton(Object parent, Automaton a) {

    Object n = create("node");
    setString(n, "text", "Automaton: " + a != null ? a.toDot() : "null");
    add(parent, n);/*from ww w  . j a  v a 2 s.co m*/

    Transition t = new Transition();

    for (int state = 0; state < a.getNumStates(); state++) {
        Object n1 = create("node");
        add(n, n1);

        StringBuilder msg = new StringBuilder();
        msg.append(String.valueOf(state));

        // initial state
        if (state == 0) {
            msg.append(" INITIAL");
        }

        msg.append(a.isAccept(state) ? " [accept]" : " [reject]");

        int numTransitions = a.initTransition(state, t);

        msg.append(", " + numTransitions + " transitions");
        setString(n1, "text", msg.toString());

        //System.out.println("toDot: state " + state + " has " + numTransitions + " transitions; t.nextTrans=" + t.transitionUpto);
        for (int i = 0; i < numTransitions; i++) {
            a.getNextTransition(t);

            Object n2 = create("node");
            add(n1, n2);
            setString(n2, "text", t.toString());
            assert t.max >= t.min;
        }
    }
}