/* * MuxItem.java * * Copyright (c) 1996 Chuck McManis, All Rights Reserved. * * Permission to use, copy, modify, and distribute this software * and its documentation for NON-COMMERCIAL purposes and without * fee is hereby granted provided that this copyright notice * appears in all copies. * * CHUCK MCMANIS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. CHUCK MCMANIS * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT * OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package util.comm; /** * This is the type of object returned from a multiplexor. In addition * to the object from the channel your are monitoring it returns the * name of the channel where it came from, and the index where this name * appeared in the original array you passed to DataChannelMux. This * facilitates writing code like: *
* ...
* MuxItem m = (MuxItem) muxChan.getValue();
* switch (m.index()) {
* case 0: ...
* case 1: ...
* }
* ...
*
*
* @author Chuck McManis
* @version 1.1
*/
public class MuxItem {
private String fromChannel;
private int userIndex;
private Object channelValue;
/**
* Package private constructor only allows things in this package
* to create mux items.
*/
MuxItem(String c, int i, Object v) {
super();
fromChannel = c;
userIndex = i;
channelValue = v;
}
/** accessor method for the object from the source channel. */
public Object value() { return channelValue; }
/** accessor method for the index from the user array. */
public int index() { return userIndex; }
/** accessor method for the name of the source channel. */
public String wasChannel() { return fromChannel; }
}