📄 dataevent.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;import java.io.Serializable;/** * This class encapsulates the data which is associated with a specific * data event that occurred. * * @author Silvio Meier (SM) * @copyright Silvio Meier, Tobias Reinhard, 2003 * @history 2003-05-09 SM First Version * 2003-05-14 SM working on additional methods and events, * correction of some comments. * 2003-05-21 SM Added methods for retrieving the client id * if the data event was received by a server. * 2006-11-02 SM Comments revised. * @version $Date: 2007/07/01 17:04:05 $, $Author: reode_orm $, $Revision: 1.1 $ * @obligation Objects which are encapsulated by this class have to * implement the {@link java.io.Serializable} interface. Also * all objects which are reachable (intransiently referenced) * in the object reference graph from the * encapsulated object have to implement the * {@link java.io.Serializable} interface. */public class DataEvent implements Serializable { /** * Serial id for serialization. */ private static final long serialVersionUID = -5265956446620156753L; /** * This variable stores a key which identifies the event uniquely. * This key can be any object and helps the user to determine which * kind of data is encapsulated in this DataEvent object. */ protected Object eventKey; /** * This field refers to the data which is encapsulated in this DataEvent. */ protected Object data; /** * This variable refers to the object identifying the sender client uniquely. */ protected Object clientId; /** * Constructor initializes the object. * * @pre key != null && data != null * @post true * @param key Key which identifies the type of the event which occurred. * The content of this key can be used to determine which type * of data is transmitted * @param data The data which should be transmitted. The class of this * object must implement the interface {@link java.io.Serializable}. * All of the directly or indirectly intransiently referenced * data objects must implement this interface. */ public DataEvent(Object key, Object data) { eventKey = key; this.data = data; this.clientId = null; } /** * This method returns the encapsulated event data. The type of the * object can be determined by using the event key. This is done by * calling the method {@link #getEventKey()}. * @pre true * @post true * @return Returns the object containing the data which is associated * with the occurring event. */ public Object getData() { return data; } /** * This method returns the event key. The event key information * can be used to determine which kind of data is encapsulated within * this object. * * @pre true * @post true * @return Returns the event key of this event. */ public Object getEventKey() { return eventKey; } /** * This method sets the id for identifying the client. This method will * be used internally by the server. * @pre id != null * @post true * @param id Identification object for the client. */ void setClientId(Object id) { this.clientId = id; } /** * This method returns the client id which is represented as an object. * The sender client Id is set if the DataEvent object is received * at a target client. * This id object is used to identify from which client this DataEvent * was sent. If the data event is received by the server, <i>null</i> * is returned. * * @pre true * @post true * @return Returns the client id as object, if this DataEvent object is * received by the server. */ public Object getClientId() { return this.clientId; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -