1 /* |
1 /* |
2 * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Sun designates this |
7 * published by the Free Software Foundation. Sun designates this |
26 package java.nio.channels; |
26 package java.nio.channels; |
27 |
27 |
28 import java.net.InetAddress; |
28 import java.net.InetAddress; |
29 import java.net.NetworkInterface; |
29 import java.net.NetworkInterface; |
30 import java.io.IOException; |
30 import java.io.IOException; |
31 import java.util.List; |
|
32 |
31 |
33 /** |
32 /** |
34 * A token representing the membership of an Internet Protocol (IP) multicast |
33 * A token representing the membership of an Internet Protocol (IP) multicast |
35 * group. |
34 * group. |
36 * |
35 * |
37 * <p> A membership key may represent a membership to receive all datagrams sent |
36 * <p> A membership key may represent a membership to receive all datagrams sent |
38 * to the group, or it may be <em>source-specific</em>, meaning that it |
37 * to the group, or it may be <em>source-specific</em>, meaning that it |
39 * represents a membership that receives only datagrams from a specific source |
38 * represents a membership that receives only datagrams from a specific source |
40 * address. Whether or not a membership key is source-specific may be determined |
39 * address. Whether or not a membership key is source-specific may be determined |
41 * by invoking its {@link #getSourceAddress() getSourceAddress} method. |
40 * by invoking its {@link #sourceAddress() sourceAddress} method. |
42 * |
41 * |
43 * <p> A membership key is valid upon creation and remains valid until the |
42 * <p> A membership key is valid upon creation and remains valid until the |
44 * membership is dropped by invoking the {@link #drop() drop} method, or |
43 * membership is dropped by invoking the {@link #drop() drop} method, or |
45 * the channel is closed. The validity of the membership key may be tested |
44 * the channel is closed. The validity of the membership key may be tested |
46 * by invoking its {@link #isValid() isValid} method. |
45 * by invoking its {@link #isValid() isValid} method. |
91 * |
90 * |
92 * <p> Upon return, this membership object will be {@link #isValid() invalid}. |
91 * <p> Upon return, this membership object will be {@link #isValid() invalid}. |
93 * If the multicast group membership is already invalid then invoking this |
92 * If the multicast group membership is already invalid then invoking this |
94 * method has no effect. Once a multicast group membership is invalid, |
93 * method has no effect. Once a multicast group membership is invalid, |
95 * it remains invalid forever. |
94 * it remains invalid forever. |
96 * |
|
97 * @throws IOException |
|
98 * If an I/O error occurs |
|
99 */ |
95 */ |
100 public abstract void drop() throws IOException; |
96 public abstract void drop(); |
101 |
97 |
102 /** |
98 /** |
103 * Block multicast datagrams from the given source address. |
99 * Block multicast datagrams from the given source address. |
104 * |
100 * |
105 * <p> If this membership key is not source-specific, and the underlying |
101 * <p> If this membership key is not source-specific, and the underlying |
138 * @return This membership key |
134 * @return This membership key |
139 * |
135 * |
140 * @throws IllegalStateException |
136 * @throws IllegalStateException |
141 * If the given source address is not currently blocked or the |
137 * If the given source address is not currently blocked or the |
142 * membership key is no longer valid |
138 * membership key is no longer valid |
143 * @throws IOException |
|
144 * If an I/O error occurs |
|
145 */ |
139 */ |
146 public abstract MembershipKey unblock(InetAddress source) throws IOException; |
140 public abstract MembershipKey unblock(InetAddress source); |
147 |
141 |
148 /** |
142 /** |
149 * Returns the channel for which this membership key was created. This |
143 * Returns the channel for which this membership key was created. This |
150 * method will continue to return the channel even after the membership |
144 * method will continue to return the channel even after the membership |
151 * becomes {@link #isValid invalid}. |
145 * becomes {@link #isValid invalid}. |
152 * |
146 * |
153 * @return the channel |
147 * @return the channel |
154 */ |
148 */ |
155 public abstract MulticastChannel getChannel(); |
149 public abstract MulticastChannel channel(); |
156 |
150 |
157 /** |
151 /** |
158 * Returns the multicast group for which this membership key was created. |
152 * Returns the multicast group for which this membership key was created. |
159 * This method will continue to return the group even after the membership |
153 * This method will continue to return the group even after the membership |
160 * becomes {@link #isValid invalid}. |
154 * becomes {@link #isValid invalid}. |
161 * |
155 * |
162 * @return the multicast group |
156 * @return the multicast group |
163 */ |
157 */ |
164 public abstract InetAddress getGroup(); |
158 public abstract InetAddress group(); |
165 |
159 |
166 /** |
160 /** |
167 * Returns the network interface for which this membership key was created. |
161 * Returns the network interface for which this membership key was created. |
168 * This method will continue to return the network interface even after the |
162 * This method will continue to return the network interface even after the |
169 * membership becomes {@link #isValid invalid}. |
163 * membership becomes {@link #isValid invalid}. |
170 * |
164 * |
171 * @return the network interface |
165 * @return the network interface |
172 */ |
166 */ |
173 public abstract NetworkInterface getNetworkInterface(); |
167 public abstract NetworkInterface networkInterface(); |
174 |
168 |
175 /** |
169 /** |
176 * Returns the source address if this membership key is source-specific, |
170 * Returns the source address if this membership key is source-specific, |
177 * or {@code null} if this membership is not source-specific. |
171 * or {@code null} if this membership is not source-specific. |
178 * |
172 * |
179 * @return The source address if this membership key is source-specific, |
173 * @return The source address if this membership key is source-specific, |
180 * otherwise {@code null} |
174 * otherwise {@code null} |
181 */ |
175 */ |
182 public abstract InetAddress getSourceAddress(); |
176 public abstract InetAddress sourceAddress(); |
183 } |
177 } |