<commit_before>/*
 * Copyright (c) 2012 <NAME>, <NAME>
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * <NAME> - initial API and implementation
 */
package prm4j.indexing;

import prm4j.api.BaseEvent;
import prm4j.api.MatchHandler;

public abstract class BaseMonitorState {

    private final int index;

    public BaseMonitorState(int index) {
	this.index = index;
    }

    public abstract BaseMonitorState getSuccessor(BaseEvent baseEvent);

    /**
     * Tests, if the current state is an accepting state.
     *
     * @return <code>true</code> if the current state is accepting
     */
    public abstract boolean isAccepting();

    public abstract MatchHandler getMatchHandler();

    /**
     * Tests, if all successor states are dead states. (A dead state is a non-accepting state, where all successors are
     * dead states. Because final state <i>may</i> be an accepting state, it is not always a dead state.)
     *
     * @return <code>true</code> if all successor states are dead states
     */
    public abstract boolean isFinal();

    public int getIndex() {
	return index;
    }

}<commit_msg>Add finite/infinite state space distinction to BaseMonitorState<commit_after>/*
 * Copyright (c) 2012 <NAME>, <NAME>
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * <NAME> - initial API and implementation
 */
package prm4j.indexing;

import prm4j.api.BaseEvent;
import prm4j.api.MatchHandler;

/**
 * Models the internal state of a {@link StatefulMonitor} where the state space may be finite or infinite.
 *
 * @see  {@link BaseMonitor}
 */
public abstract class BaseMonitorState {

    /**
     * Unique index for finite state spaces.
     */
    private final int index;

    /**
     * Creates a monitor state assuming a finite state space. The monitor will have an unique index.
     *
     * @param index
     */
    public BaseMonitorState(int index) {
	this.index = index;
    }

    /**
     * Creates a monitor state assuming an infinite state space. This monitor will not have an unique index.
     */
    public BaseMonitorState() {
	index = -1;
    }

    public abstract BaseMonitorState getSuccessor(BaseEvent baseEvent);

    /**
     * Tests, if the current state is an accepting state.
     *
     * @return <code>true</code> if the current state is accepting
     */
    public abstract boolean isAccepting();

    public abstract MatchHandler getMatchHandler();

    /**
     * @return <code>true</code> if the state space is finite, of <code>false</code> if there may exist an infinite
     *         number of possible states.
     */
    public boolean isFinite() {
	return index >= 0;
    }

    /**
     * Tests, if all successor states are dead states. (A dead state is a non-accepting state, where all successors are
     * dead states. Because final state <i>may</i> be an accepting state, it is not always a dead state.)
     *
     * @return <code>true</code> if all successor states are dead states
     */
    public abstract boolean isFinal();

    /**
     * Returns the unique index of this state if the state space is finite. A valid index is a non-negative integer.
     *
     * @return the unique index of this state or -1 if the state space is infinite.
     */
    public int getIndex() {
	return index;
    }

}
{'fraction_non_alphanumeric': 0.08814016172506739, 'fraction_numerical': 0.006738544474393531, 'mean_word_length': 2.9228329809725158, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2489311', 'n_tokens_mistral': 1037, 'n_tokens_neox': 999, 'n_words': 422}