org.jboss.netty.channel.group
Class DefaultChannelGroup

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<Channel>
          extended by org.jboss.netty.channel.group.DefaultChannelGroup
All Implemented Interfaces:
java.lang.Comparable<ChannelGroup>, java.lang.Iterable<Channel>, java.util.Collection<Channel>, java.util.Set<Channel>, ChannelGroup

public class DefaultChannelGroup
extends java.util.AbstractSet<Channel>
implements ChannelGroup

The default ChannelGroup implementation.

Version:
$Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
Author:
The Netty Project, Trustin Lee

Constructor Summary
DefaultChannelGroup()
          Creates a new group with a generated name.
DefaultChannelGroup(java.lang.String name)
          Creates a new group with the specified name.
 
Method Summary
 boolean add(Channel channel)
           
 void clear()
           
 ChannelGroupFuture close()
          Closes all Channels in this group.
 int compareTo(ChannelGroup o)
           
 boolean contains(java.lang.Object o)
           
 ChannelGroupFuture disconnect()
          Disconnects all Channels in this group from their remote peers.
 boolean equals(java.lang.Object o)
           
 Channel find(java.lang.Integer id)
          Returns the Channel whose ID matches the specified integer.
 java.lang.String getName()
          Returns the name of this group.
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Iterator<Channel> iterator()
           
 boolean remove(java.lang.Object o)
           
 ChannelGroupFuture setInterestOps(int interestOps)
          Calls Channel.setInterestOps(int) for all Channels in this group with the specified interestOps.
 ChannelGroupFuture setReadable(boolean readable)
          Calls Channel.setReadable(boolean) for all Channels in this group with the specified boolean flag.
 int size()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 java.lang.String toString()
           
 ChannelGroupFuture unbind()
          Unbinds all Channels in this group from their local address.
 ChannelGroupFuture write(java.lang.Object message)
          Writes the specified message to all Channels in this group.
 ChannelGroupFuture write(java.lang.Object message, java.net.SocketAddress remoteAddress)
          Writes the specified message with the specified remoteAddress to all Channels in this group.
 
Methods inherited from class java.util.AbstractSet
removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, removeAll, retainAll
 

Constructor Detail

DefaultChannelGroup

public DefaultChannelGroup()
Creates a new group with a generated name.


DefaultChannelGroup

public DefaultChannelGroup(java.lang.String name)
Creates a new group with the specified name. Please note that different groups can have the same name, which means no duplicate check is done against group names.

Method Detail

getName

public java.lang.String getName()
Description copied from interface: ChannelGroup
Returns the name of this group. A group name is purely for helping you to distinguish one group from others.

Specified by:
getName in interface ChannelGroup

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<Channel>
Specified by:
isEmpty in interface java.util.Set<Channel>
Overrides:
isEmpty in class java.util.AbstractCollection<Channel>

size

public int size()
Specified by:
size in interface java.util.Collection<Channel>
Specified by:
size in interface java.util.Set<Channel>
Specified by:
size in class java.util.AbstractCollection<Channel>

find

public Channel find(java.lang.Integer id)
Description copied from interface: ChannelGroup
Returns the Channel whose ID matches the specified integer.

Specified by:
find in interface ChannelGroup
Returns:
the matching Channel if found. null otherwise.

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<Channel>
Specified by:
contains in interface java.util.Set<Channel>
Overrides:
contains in class java.util.AbstractCollection<Channel>

add

public boolean add(Channel channel)
Specified by:
add in interface java.util.Collection<Channel>
Specified by:
add in interface java.util.Set<Channel>
Overrides:
add in class java.util.AbstractCollection<Channel>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<Channel>
Specified by:
remove in interface java.util.Set<Channel>
Overrides:
remove in class java.util.AbstractCollection<Channel>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<Channel>
Specified by:
clear in interface java.util.Set<Channel>
Overrides:
clear in class java.util.AbstractCollection<Channel>

iterator

public java.util.Iterator<Channel> iterator()
Specified by:
iterator in interface java.lang.Iterable<Channel>
Specified by:
iterator in interface java.util.Collection<Channel>
Specified by:
iterator in interface java.util.Set<Channel>
Specified by:
iterator in class java.util.AbstractCollection<Channel>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<Channel>
Specified by:
toArray in interface java.util.Set<Channel>
Overrides:
toArray in class java.util.AbstractCollection<Channel>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<Channel>
Specified by:
toArray in interface java.util.Set<Channel>
Overrides:
toArray in class java.util.AbstractCollection<Channel>

close

public ChannelGroupFuture close()
Description copied from interface: ChannelGroup
Closes all Channels in this group. If the Channel is connected to a remote peer or bound to a local address, it is automatically disconnected and unbound.

Specified by:
close in interface ChannelGroup
Returns:
the ChannelGroupFuture instance that notifies when the operation is done for all channels

disconnect

public ChannelGroupFuture disconnect()
Description copied from interface: ChannelGroup
Disconnects all Channels in this group from their remote peers.

Specified by:
disconnect in interface ChannelGroup
Returns:
the ChannelGroupFuture instance that notifies when the operation is done for all channels

setInterestOps

public ChannelGroupFuture setInterestOps(int interestOps)
Description copied from interface: ChannelGroup
Calls Channel.setInterestOps(int) for all Channels in this group with the specified interestOps. Please note that this operation is asynchronous as Channel.setInterestOps(int) is.

Specified by:
setInterestOps in interface ChannelGroup
Returns:
the ChannelGroupFuture instance that notifies when the operation is done for all channels

setReadable

public ChannelGroupFuture setReadable(boolean readable)
Description copied from interface: ChannelGroup
Calls Channel.setReadable(boolean) for all Channels in this group with the specified boolean flag. Please note that this operation is asynchronous as Channel.setReadable(boolean) is.

Specified by:
setReadable in interface ChannelGroup
Returns:
the ChannelGroupFuture instance that notifies when the operation is done for all channels

unbind

public ChannelGroupFuture unbind()
Description copied from interface: ChannelGroup
Unbinds all Channels in this group from their local address.

Specified by:
unbind in interface ChannelGroup
Returns:
the ChannelGroupFuture instance that notifies when the operation is done for all channels

write

public ChannelGroupFuture write(java.lang.Object message)
Description copied from interface: ChannelGroup
Writes the specified message to all Channels in this group. If the specified message is an instance of ChannelBuffer, it is automatically duplicated to avoid a race condition. Please note that this operation is asynchronous as Channel.write(Object) is.

Specified by:
write in interface ChannelGroup
Returns:
the ChannelGroupFuture instance that notifies when the operation is done for all channels

write

public ChannelGroupFuture write(java.lang.Object message,
                                java.net.SocketAddress remoteAddress)
Description copied from interface: ChannelGroup
Writes the specified message with the specified remoteAddress to all Channels in this group. If the specified message is an instance of ChannelBuffer, it is automatically duplicated to avoid a race condition. Please note that this operation is asynchronous as Channel.write(Object, SocketAddress) is.

Specified by:
write in interface ChannelGroup
Returns:
the ChannelGroupFuture instance that notifies when the operation is done for all channels

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection<Channel>
Specified by:
hashCode in interface java.util.Set<Channel>
Overrides:
hashCode in class java.util.AbstractSet<Channel>

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Collection<Channel>
Specified by:
equals in interface java.util.Set<Channel>
Overrides:
equals in class java.util.AbstractSet<Channel>

compareTo

public int compareTo(ChannelGroup o)
Specified by:
compareTo in interface java.lang.Comparable<ChannelGroup>

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractCollection<Channel>


Copyright © 2008-2011. All Rights Reserved.