<commit_before>/*
 * JGrapes Event Driven Framework
 * Copyright (C) 2016  <NAME>
 * 
 * This program is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 3 of the License, or 
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License along 
 * with this program; if not, see <http://www.gnu.org/licenses/>.
 */
package org.jgrapes.core;

import java.util.Arrays;

import org.jgrapes.core.events.HandlingError;
import org.jgrapes.core.internal.EventBase;
import org.jgrapes.core.internal.Matchable;

/**
 * The base class for all events. Event classes form a hierarchy.
 * By default (i.e. as implemented by this class), the event's class 
 * (type) is used for matching. A handler is invoked if the class of the
 * event handled by it is equal to or a base class of the class of the event 
 * to be handled. 
 * <P>
 * This default behavior can be changed by overriding the methods
 * from {@link Matchable}. See {@link NamedEvent} as an example.
 * 
 * @author <NAME>
 */
public class Event extends EventBase {

	/**
	 * Returns the channels associated with the event. Before an
	 * event has been fired, this returns the channels set with
	 * {@link #setChannels(Channel[])}. After an event has been
	 * fired, this returns the channels that the event has
	 * effectively been fired on 
	 * (see {@link Manager#fire(Event, Channel...)}).
	 * 
	 * @return the channels
	 */
	public Channel[] getChannels() {
		return channels;
	}

	/**
	 * Sets the channels that the event is fired on if no channels
	 * are specified explicitly when firing the event
	 * (see {@link org.jgrapes.core.Manager#fire(Event, Channel...)}).
	 * 
	 * @param channels the channels to set
	 * 
	 * @throws IllegalStateException if the method is called after
	 * this event has been fired
	 */
	public void setChannels(Channel[] channels) {
		if (currentlyHandled()) {
			throw new IllegalStateException
				("Channels cannot be changed after fire");
		}
		this.channels = channels;
	}

	/* (non-Javadoc)
	 * @see org.jdrupes.core.internal.Matchable#getMatchKey()
	 */
	@Override
	public Object getMatchKey() {
		return getClass();
	}

	/* (non-Javadoc)<commit_msg>Fixed method name.<commit_after>/*
 * JGrapes Event Driven Framework
 * Copyright (C) 2016  <NAME>
 * 
 * This program is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 3 of the License, or 
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License along 
 * with this program; if not, see <http://www.gnu.org/licenses/>.
 */
package org.jgrapes.core;

import java.util.Arrays;

import org.jgrapes.core.events.HandlingError;
import org.jgrapes.core.internal.EventBase;
import org.jgrapes.core.internal.Matchable;

/**
 * The base class for all events. Event classes form a hierarchy.
 * By default (i.e. as implemented by this class), the event's class 
 * (type) is used for matching. A handler is invoked if the class of the
 * event handled by it is equal to or a base class of the class of the event 
 * to be handled. 
 * <P>
 * This default behavior can be changed by overriding the methods
 * from {@link Matchable}. See {@link NamedEvent} as an example.
 * 
 * @author <NAME>
 */
public class Event extends EventBase {

	/**
	 * Returns the channels associated with the event. Before an
	 * event has been fired, this returns the channels set with
	 * {@link #setChannels(Channel[])}. After an event has been
	 * fired, this returns the channels that the event has
	 * effectively been fired on 
	 * (see {@link Manager#fire(Event, Channel...)}).
	 * 
	 * @return the channels
	 */
	public Channel[] getChannels() {
		return channels;
	}

	/**
	 * Sets the channels that the event is fired on if no channels
	 * are specified explicitly when firing the event
	 * (see {@link org.jgrapes.core.Manager#fire(Event, Channel...)}).
	 * 
	 * @param channels the channels to set
	 * 
	 * @throws IllegalStateException if the method is called after
	 * this event has been fired
	 */
	public void setChannels(Channel[] channels) {
		if (enqueued()) {
			throw new IllegalStateException
				("Channels cannot be changed after fire");
		}
		this.channels = channels;
	}

	/* (non-Javadoc)
	 * @see org.jdrupes.core.internal.Matchable#getMatchKey()
	 */
	@Override
	public Object getMatchKey() {
		return getClass();
	}

	/* (non-Javadoc)
{'fraction_non_alphanumeric': 0.09243043393656353, 'fraction_numerical': 0.001945903872348706, 'mean_word_length': 3.508771929824561, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2133772', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1407, 'n_words': 645}