Package org.jboss.netty.channel.group
Class DefaultChannelGroup
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<Channel>
-
- org.jboss.netty.channel.group.DefaultChannelGroup
-
- All Implemented Interfaces:
Comparable<ChannelGroup>,Iterable<Channel>,Collection<Channel>,Set<Channel>,ChannelGroup
public class DefaultChannelGroup extends AbstractSet<Channel> implements ChannelGroup
The defaultChannelGroupimplementation.
-
-
Constructor Summary
Constructors Constructor Description DefaultChannelGroup()Creates a new group with a generated name.DefaultChannelGroup(String name)Creates a new group with the specifiedname.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Channel channel)voidclear()ChannelGroupFutureclose()Closes allChannels in this group.intcompareTo(ChannelGroup o)booleancontains(Object o)ChannelGroupFuturedisconnect()Disconnects allChannels in this group from their remote peers.booleanequals(Object o)Channelfind(Integer id)Returns theChannelwhose ID matches the specified integer.StringgetName()Returns the name of this group.inthashCode()booleanisEmpty()Iterator<Channel>iterator()booleanremove(Object o)ChannelGroupFuturesetInterestOps(int interestOps)ChannelGroupFuturesetReadable(boolean readable)CallsChannel.setReadable(boolean)for allChannels in this group with the specified boolean flag.intsize()Object[]toArray()<T> T[]toArray(T[] a)StringtoString()ChannelGroupFutureunbind()Unbinds allChannels in this group from their local address.ChannelGroupFuturewrite(Object message)Writes the specifiedmessageto allChannels in this group.ChannelGroupFuturewrite(Object message, SocketAddress remoteAddress)-
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.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
addAll, containsAll, removeAll, retainAll, spliterator
-
-
-
-
Constructor Detail
-
DefaultChannelGroup
public DefaultChannelGroup()
Creates a new group with a generated name.
-
DefaultChannelGroup
public DefaultChannelGroup(String name)
Creates a new group with the specifiedname. Please note that different groups can have the same name, which means no duplicate check is done against group names.
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:ChannelGroupReturns the name of this group. A group name is purely for helping you to distinguish one group from others.- Specified by:
getNamein interfaceChannelGroup
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<Channel>- Specified by:
isEmptyin interfaceSet<Channel>- Overrides:
isEmptyin classAbstractCollection<Channel>
-
size
public int size()
- Specified by:
sizein interfaceCollection<Channel>- Specified by:
sizein interfaceSet<Channel>- Specified by:
sizein classAbstractCollection<Channel>
-
find
public Channel find(Integer id)
Description copied from interface:ChannelGroupReturns theChannelwhose ID matches the specified integer.- Specified by:
findin interfaceChannelGroup- Returns:
- the matching
Channelif found.nullotherwise.
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<Channel>- Specified by:
containsin interfaceSet<Channel>- Overrides:
containsin classAbstractCollection<Channel>
-
add
public boolean add(Channel channel)
- Specified by:
addin interfaceCollection<Channel>- Specified by:
addin interfaceSet<Channel>- Overrides:
addin classAbstractCollection<Channel>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<Channel>- Specified by:
removein interfaceSet<Channel>- Overrides:
removein classAbstractCollection<Channel>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<Channel>- Specified by:
clearin interfaceSet<Channel>- Overrides:
clearin classAbstractCollection<Channel>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<Channel>- Specified by:
toArrayin interfaceSet<Channel>- Overrides:
toArrayin classAbstractCollection<Channel>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArrayin interfaceCollection<Channel>- Specified by:
toArrayin interfaceSet<Channel>- Overrides:
toArrayin classAbstractCollection<Channel>
-
close
public ChannelGroupFuture close()
Description copied from interface:ChannelGroupCloses allChannels in this group. If theChannelis connected to a remote peer or bound to a local address, it is automatically disconnected and unbound.- Specified by:
closein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
disconnect
public ChannelGroupFuture disconnect()
Description copied from interface:ChannelGroupDisconnects allChannels in this group from their remote peers.- Specified by:
disconnectin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
setInterestOps
public ChannelGroupFuture setInterestOps(int interestOps)
Description copied from interface:ChannelGroupCallsChannel.setInterestOps(int)for allChannels in this group with the specifiedinterestOps. Please note that this operation is asynchronous asChannel.setInterestOps(int)is.- Specified by:
setInterestOpsin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
setReadable
public ChannelGroupFuture setReadable(boolean readable)
Description copied from interface:ChannelGroupCallsChannel.setReadable(boolean)for allChannels in this group with the specified boolean flag. Please note that this operation is asynchronous asChannel.setReadable(boolean)is.- Specified by:
setReadablein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
unbind
public ChannelGroupFuture unbind()
Description copied from interface:ChannelGroupUnbinds allChannels in this group from their local address.- Specified by:
unbindin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
write
public ChannelGroupFuture write(Object message)
Description copied from interface:ChannelGroupWrites the specifiedmessageto allChannels in this group. If the specifiedmessageis an instance ofChannelBuffer, it is automatically duplicated to avoid a race condition. Please note that this operation is asynchronous asChannel.write(Object)is.- Specified by:
writein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
write
public ChannelGroupFuture write(Object message, SocketAddress remoteAddress)
Description copied from interface:ChannelGroupWrites the specifiedmessagewith the specifiedremoteAddressto allChannels in this group. If the specifiedmessageis an instance ofChannelBuffer, it is automatically duplicated to avoid a race condition. Please note that this operation is asynchronous asChannel.write(Object, SocketAddress)is.- Specified by:
writein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceCollection<Channel>- Specified by:
hashCodein interfaceSet<Channel>- Overrides:
hashCodein classAbstractSet<Channel>
-
equals
public boolean equals(Object o)
- Specified by:
equalsin interfaceCollection<Channel>- Specified by:
equalsin interfaceSet<Channel>- Overrides:
equalsin classAbstractSet<Channel>
-
compareTo
public int compareTo(ChannelGroup o)
- Specified by:
compareToin interfaceComparable<ChannelGroup>
-
toString
public String toString()
- Overrides:
toStringin classAbstractCollection<Channel>
-
-