courses.dsv2pvt.messageclasses
Class Present

java.lang.Object
  extended bycourses.dsv2pvt.messageclasses.Msg
      extended bycourses.dsv2pvt.messageclasses.Present
All Implemented Interfaces:
Serializable

public class Present
extends Msg

Used to inquire whether or not a client(s) is online or not. The response is in form of a list of all ClientStatus objects matching the inquiry. The present message is sent to the server. The server searches for matches and add the ClientStatus object(s) of the match(es) to the Present object and returns it to the client.

See Also:
Serialized Form

Constructor Summary
Present()
          Creates a Present inquiry for all clients that are online.
Present(String subject)
          Creates a Present inquiry for one specific clients.
 
Method Summary
 void addMatch(ClientStatus clientStatus)
          Add a match.
 void addMatches(Iterator iter)
          Adds a collection of matches to the object.
 ClientStatus getMatch(int idx)
          Returns the ClientStatus of the specified client.
 Iterator getMatches()
          Returns an iterator to the collection of matches.
 String getSubject()
          Returns the username of the subject of the inquiry.
 boolean isAll()
          Returns true if the message is an inquiry of all online clients.
 int noMatches()
          The number of matches of the inquiry.
 void setAll(boolean all)
          Sets the status of the inquiry.
 
Methods inherited from class courses.dsv2pvt.messageclasses.Msg
getSender, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Present

public Present()
Creates a Present inquiry for all clients that are online.


Present

public Present(String subject)
Creates a Present inquiry for one specific clients.

Parameters:
subject - the username of the client
Method Detail

noMatches

public int noMatches()
The number of matches of the inquiry.


isAll

public boolean isAll()
Returns true if the message is an inquiry of all online clients.


getSubject

public String getSubject()
Returns the username of the subject of the inquiry.


setAll

public void setAll(boolean all)
Sets the status of the inquiry.

Parameters:
all - true if all online clients, else false.

getMatches

public Iterator getMatches()
Returns an iterator to the collection of matches.


getMatch

public ClientStatus getMatch(int idx)
Returns the ClientStatus of the specified client.

Parameters:
idx - an index (0 <= idx < getMatches())

addMatches

public void addMatches(Iterator iter)
                throws ClassCastException
Adds a collection of matches to the object.

Parameters:
iter - an iterator to a collection of matches to be added.
Throws:
ClassCastException

addMatch

public void addMatch(ClientStatus clientStatus)
Add a match.

Parameters:
clientStatus - the ClientStatus of the match to add.