/*
* OutputChannelVector.java
*
* Developed for the "Rethinking CS101" project. See http://www.cs101.org, the
* CS101 homepage or email las@olin.edu.
*
* Please do not redistribute without obtaining permission.
*/
package nodenet;
import nodenet.Node;
import java.util.Vector;
import java.util.Enumeration;
import java.io.Serializable;
/**
* OutputChannelVector is something which acts like a Vector
* of OutputChannel
s instead of Objects.
The methods of * this class were previously synchronized, but Sun's Vector class uses * synchronized methods. Since our only data field is the already * synchronized Vector, locking on this object is redundant.
*
* Copyright (c) 1998 Massachusetts Institute of Technology
*
* @author Todd C. Parnell, tparnell@ai.mit.edu
* @version $Id: OutputChannelVector.java,v 1.7 2004/01/14 20:23:21 gus Exp $
*/
public class OutputChannelVector implements Serializable {
private Vector myVector;
private Node owner;
/**
* Constructs a new OutputChannelVector
*/
public OutputChannelVector(Node owner) {
this.owner = owner;
this.myVector = new Vector( );
}
/**
* Find out who the owner of this object is.
*
* @return a reference to the owning Node
*/
public Node getOwner() {
return owner;
}
/**
* Adds an object to the OutputChannelVector.
*/
public final void addElement( OutputChannel obj ) {
this.myVector.addElement( obj );
}
/**
* Checks to see if it contains an element.
*/
public final boolean contains( Object elem ) {
return this.myVector.contains( elem );
}
/**
* Returns the OutputChannel at a certain index.
*
* @param index index of the OutputChannel being looked up
*/
public final OutputChannel elementAt( int index ) {
return (OutputChannel)this.myVector.elementAt( index );
}
/**
* Transforms OutputChannelVector into yet another type
* of collection of objects, called an Enumeration.
*/
public final Enumeration elements( ) // allows to turn into another type of collection?? thingie
{
return this.myVector.elements( ); // should return Enum of IChannels?
}
/**
* Returns the first OutputChannel in the OutputChannelVector.
*/
public final OutputChannel firstElement( ) {
return (OutputChannel)this.myVector.firstElement( );
}
/**
* Returns true if the OutputChannelVector is empty.
*/
public final boolean isEmpty( ) {
return this.myVector.isEmpty( );
}
/**
* Returns the last OutputChannel in the OutputChannelVector.
*/
public final OutputChannel lastElement( ) {
return (OutputChannel)this.myVector.lastElement( );
}
/**
* Removes all elements from the OutputChannelVector.
*/
public final void removeAllElements( ) {
this.myVector.removeAllElements( );
}
/**
* Removes a specific element from the OutputChannelVector.
*
* @param obj the object being removed
*/
public final boolean removeElement( OutputChannel obj ) {
return this.myVector.removeElement( obj );
}
/**
* Returns the size of the InputChannelVector.
*/
public final int size( ) {
return this.myVector.size( );
}
}
/*
* $Log: OutputChannelVector.java,v $
* Revision 1.7 2004/01/14 20:23:21 gus
* Javadoc and comment cleanup
*
* Revision 1.6 2003/02/24 16:04:15 gus
* Make input and output channel vectors aware of their owners, and able to report
* who their owner is.
*
* Revision 1.5 2003/02/21 17:50:11 gus
* fixed log comment
*
*/