📄 communicationevent.java
字号:
/* * Copyright (c) 2003 - 2007, Silvio Meier and Tobias Reinhard * * All rights reserved. * * Redistribution and use in source and binary forms, * with or without modification, are permitted provided * that the following conditions are met: * * o Redistributions of source code must retain the above * copyright notice, this list of conditions and the * following disclaimer. * o Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the * following disclaimer in the documentation and/or other * materials provided with the distribution. * o The names of its contributors may not be used to endorse * or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */package net.sf.cscc;/** * This class represents a communication event. A communication event * describes events that occur between the communication of * two communication partners. This specific type of event is identified by * a numeric id which can be retrieved with the method * {@link #getEventId()}. The event can also contain some additional * data, for example the id of the communication partner. * * @author Silvio Meier (SM) * @copyright Silvio Meier, Tobias Reinhard, 2003 * @history 2003-05-14 SM First Version * 2003-05-14 SM working on additional methods and events, * correction of some comments. * 2003-05-20 TR Comments corrected * 2006-10-29 SM Comments revised. * @version $Date: 2007/07/01 17:04:05 $, $Author: reode_orm $, $Revision: 1.1 $ * @responsibilities Represents a communication event. */public class CommunicationEvent { /** * Constant describes if the connection was established. */ public static final int CONNECTION_ESTABLISHED = 1; /** * Describes the type of event which occurs if the connection breaks. */ public static final int CONNECTION_BROKEN = 2; /** * Describes the normal closing of connection by one of the * communication partners. */ public static final int CONNECTION_CLOSED = 3; /** * Constant describes the start of a listener thread. */ public static final int CONNECTION_START_LISTENING = 4; /** * Constant describes the end of a listening thread. */ public static final int CONNECTION_STOP_LISTENING = 5; /** * Stores a numeric id about the event. */ protected int eventId; /** * Stores additional data about the communication event. */ protected Object additionalData; /** * Constructor initializes the object. * @pre data != null * @post true * @param id Identifies the communication event uniquely. * @param data Some additional data which can also be provided * with the event. This can be, for example, an identification * object for the communication partner which caused the event. */ public CommunicationEvent(int id, Object data) { eventId = id; additionalData = data; } /** * Constructor initializes the object. * @pre true * @post true * @param id Identifies the communication event uniquely. */ public CommunicationEvent(int id) { eventId = id; additionalData = null; } /** * This method returns the additional data of the message. * @pre true * @post true * @return Returns the object containing the data which is associated * to the occurred event. */ public Object getData() { return additionalData; } /** * This method returns the event id. This event id can be used * to determine which kind of event happened. * @pre true * @post true * @return Returns the event key of this event. */ public int getEventId() { return eventId; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -