Package spread
Class SpreadGroup
- java.lang.Object
-
- spread.SpreadGroup
-
public class SpreadGroup extends java.lang.ObjectA SpreadGroup object represents a group on a spread daemon. The group is either a group that has been joined or a private group. To join a group, first create a SpreadGroup object, then join it withjoin(SpreadConnection, String):SpreadGroup group = new SpreadGroup(); group.join(connection, "users");
To leave the group, use
leave():group.leave();
-
-
Field Summary
Fields Modifier and Type Field Description private SpreadConnectionconnectionprivate java.lang.Stringname
-
Constructor Summary
Constructors Modifier Constructor Description SpreadGroup()Initializes a new SpreadGroup object.protectedSpreadGroup(SpreadConnection connection, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object object)Checks if two groups are the same.inthashCode()Returns the hash code of the group, which is defined as the hash code of its name.voidjoin(SpreadConnection connection, java.lang.String name)Joins the groupnameon the connectionconnection.voidleave()Leaves the group.java.lang.StringtoString()Returns the name of the group as a string.
-
-
-
Field Detail
-
name
private java.lang.String name
-
connection
private SpreadConnection connection
-
-
Constructor Detail
-
SpreadGroup
protected SpreadGroup(SpreadConnection connection, java.lang.String name)
-
SpreadGroup
public SpreadGroup()
Initializes a new SpreadGroup object. To join a group with this object, usejoin(SpreadConnection, String).- See Also:
join(SpreadConnection, String)
-
-
Method Detail
-
join
public void join(SpreadConnection connection, java.lang.String name) throws SpreadException
Joins the groupnameon the connectionconnection. Between when the group has been joined with this method and when it is left withleave(), all messages sent to the group will be received by the connection.- Parameters:
connection- the connection to join the group withname- the name of the group to join- Throws:
SpreadException- if attempting to join again with the same group object, if an illegal character is in the group name, or if there is an error trying to join the group- See Also:
leave()
-
leave
public void leave() throws SpreadExceptionLeaves the group. No more messages will be received from this group after this method is called.- Throws:
SpreadException- if the group hasn't been joined, or if there is an error leaving the group- See Also:
join(SpreadConnection, String)
-
toString
public java.lang.String toString()
Returns the name of the group as a string.- Overrides:
toStringin classjava.lang.Object- Returns:
- the name of the group
-
equals
public boolean equals(java.lang.Object object)
Checks if two groups are the same. Two groups are the same if they have the same name.- Overrides:
equalsin classjava.lang.Object- Parameters:
object- the object to compare against- Returns:
- true if object is a SpreadGroup and it has the same name
-
hashCode
public int hashCode()
Returns the hash code of the group, which is defined as the hash code of its name.- Overrides:
hashCodein classjava.lang.Object- Returns:
- int the hash code
-
-