private NFA<Event> createStartEndNFA() { State<Event> startState = new State<>("start", State.StateType.Start); State<Event> endState = new State<>("end", State.StateType.Normal); State<Event> endingState = new State<>("", State.StateType.Final); startState.addTake( endState, new SimpleCondition<Event>() { private static final long serialVersionUID = -4869589195918650396L; @Override public boolean filter(Event value) throws Exception { return value.getName().equals("start"); } }); endState.addTake( endingState, new SimpleCondition<Event>() { private static final long serialVersionUID = 2979804163709590673L; @Override public boolean filter(Event value) throws Exception { return value.getName().equals("end"); } }); endState.addIgnore(BooleanConditions.<Event>trueFunction()); List<State<Event>> states = new ArrayList<>(); states.add(startState); states.add(endState); states.add(endingState); return new NFA<>(states, 2L, false); }
endState.addIgnore(BooleanConditions.<Event>trueFunction());
notNext.addIgnore(lastSink, new RichNotCondition<>(notCondition)); } else { notNext.addProceed(lastSink, new RichNotCondition<>(notCondition));
/** * Patterns with quantifiers AT_LEAST_ONE_* are created as a pair of states: a singleton state and * looping state. This method creates the first of the two. * * @param sinkState the state the newly created state should point to, it should be a looping state * @return the newly created state */ @SuppressWarnings("unchecked") private State<T> createInitMandatoryStateOfOneOrMore(final State<T> sinkState) { final IterativeCondition<T> currentCondition = (IterativeCondition<T>) currentPattern.getCondition(); final State<T> firstState = createState(currentPattern.getName(), State.StateType.Normal); firstState.addTake(sinkState, currentCondition); final IterativeCondition<T> ignoreCondition = getIgnoreCondition(currentPattern); if (ignoreCondition != null) { firstState.addIgnore(ignoreCondition); } return firstState; }
/** * Creates a pair of states that enables relaxed strictness before a zeroOrMore looping state. * * @param loopingState the first state of zeroOrMore complex state * @param lastSink the state that the looping one points to * @return the newly created state */ @SuppressWarnings("unchecked") private State<T> createInitOptionalStateOfZeroOrMore(final State<T> loopingState, final State<T> lastSink) { final IterativeCondition<T> currentCondition = (IterativeCondition<T>) currentPattern.getCondition(); final State<T> firstState = createState(currentPattern.getName(), State.StateType.Normal); firstState.addProceed(lastSink, BooleanConditions.<T>trueFunction()); firstState.addTake(loopingState, currentCondition); final IterativeCondition<T> ignoreFunction = getIgnoreCondition(currentPattern); if (ignoreFunction != null) { final State<T> firstStateWithoutProceed = createState(currentPattern.getName(), State.StateType.Normal); firstState.addIgnore(firstStateWithoutProceed, ignoreFunction); firstStateWithoutProceed.addIgnore(ignoreFunction); firstStateWithoutProceed.addTake(loopingState, currentCondition); addStopStates(firstStateWithoutProceed); } return firstState; }
/** * Creates the given state as a looping one. Looping state is one with TAKE edge to itself and * PROCEED edge to the sinkState. It also consists of a similar state without the PROCEED edge, so that * for each PROCEED transition branches in computation state graph can be created only once. * * @param sinkState the state that the converted state should point to * @return the first state of the created complex state */ @SuppressWarnings("unchecked") private State<T> createLooping(final State<T> sinkState) { final IterativeCondition<T> currentCondition = (IterativeCondition<T>) currentPattern.getCondition(); final IterativeCondition<T> ignoreCondition = getInnerIgnoreCondition(currentPattern); final IterativeCondition<T> trueFunction = BooleanConditions.trueFunction(); final State<T> loopingState = createState(currentPattern.getName(), State.StateType.Normal); loopingState.addProceed(sinkState, trueFunction); loopingState.addTake(currentCondition); addStopStateToLooping(loopingState); if (ignoreCondition != null) { final State<T> ignoreState = createState(currentPattern.getName(), State.StateType.Normal); ignoreState.addTake(loopingState, currentCondition); ignoreState.addIgnore(ignoreCondition); loopingState.addIgnore(ignoreState, ignoreCondition); addStopStateToLooping(ignoreState); } return loopingState; }
notNext.addIgnore(lastSink, new NotCondition<>(notCondition)); } else { notNext.addProceed(lastSink, new NotCondition<>(notCondition));
notNext.addIgnore(lastSink, new NotCondition<>(notCondition)); } else { notNext.addProceed(lastSink, new NotCondition<>(notCondition));
notNext.addIgnore(lastSink, new NotCondition<>(notCondition)); } else { notNext.addProceed(lastSink, new NotCondition<>(notCondition));