edu.rit.chat2
Class ChatRoom

java.lang.Object
  extended by edu.rit.chat2.ChatRoom
All Implemented Interfaces:
Externalizable, Serializable

public class ChatRoom
extends Object
implements Externalizable

Class ChatRoom encapsulates the name and multihandle for a chat room.

See Also:
Serialized Form

Constructor Summary
ChatRoom()
          Construct a new chat room.
ChatRoom(String theName, ChatRef theMultihandle)
          Construct a new chat room with the given name and multihandle.
 
Method Summary
 void disjoin(Chat theChat)
          Disjoin the given chat object from this chat room.
 boolean equals(Object obj)
          Determine if this chat room is equal to the given object.
 int hashCode()
          Returns a hash code for this chat room.
 void join(Chat theChat)
          Join the given chat object to this chat room.
 void putMessage(String line)
          Display the given line of text in the chat log of each chat object that has joined this chat room.
 void readExternal(ObjectInput in)
          Read this chat room from the given object input stream.
 String toString()
          Returns a string version of this chat room.
 void writeExternal(ObjectOutput out)
          Write this chat room to the given object output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChatRoom

public ChatRoom()
Construct a new chat room. This constructor is for use only by object deserialization.


ChatRoom

public ChatRoom(String theName,
                ChatRef theMultihandle)
Construct a new chat room with the given name and multihandle.

Parameters:
theName - Name.
theMultihandle - Multihandle for interface ChatRef.
Throws:
NullPointerException - (unchecked exception) Thrown if theName is null or theMultihandle is null.
Method Detail

join

public void join(Chat theChat)
Join the given chat object to this chat room.

Parameters:
theChat - Chat object.

disjoin

public void disjoin(Chat theChat)
Disjoin the given chat object from this chat room.

Parameters:
theChat - Chat object.

putMessage

public void putMessage(String line)
Display the given line of text in the chat log of each chat object that has joined this chat room.

Parameters:
line - Line of text.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Write this chat room to the given object output stream.

Specified by:
writeExternal in interface Externalizable
Parameters:
out - Object output stream.
Throws:
IOException - Thrown if an I/O error occurred.

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Read this chat room from the given object input stream.

Specified by:
readExternal in interface Externalizable
Parameters:
in - Object input stream.
Throws:
IOException - Thrown if an I/O error occurred.
ClassNotFoundException - Thrown if a class needed to deserialize this object could not be found.

equals

public boolean equals(Object obj)
Determine if this chat room is equal to the given object.

Overrides:
equals in class Object
Parameters:
obj - Object to test.
Returns:
True if this chat room is equal to obj, false otherwise.

hashCode

public int hashCode()
Returns a hash code for this chat room.

Overrides:
hashCode in class Object
Returns:
Hash code.

toString

public String toString()
Returns a string version of this chat room. The string version is the chat room's name.

Overrides:
toString in class Object
Returns:
String version.


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.