jdk/src/share/classes/sun/nio/ch/MembershipKeyImpl.java
changeset 2057 3acf8e5e2ca0
parent 1152 29d6145d1097
child 5506 202f599c92aa
equal deleted inserted replaced
2056:115e09b7a004 2057:3acf8e5e2ca0
     1 /*
     1 /*
     2  * Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
     2  * Copyright 2008-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
    83             this.groupAddress = groupAddress;
    83             this.groupAddress = groupAddress;
    84             this.interfAddress = interfAddress;
    84             this.interfAddress = interfAddress;
    85             this.sourceAddress = sourceAddress;
    85             this.sourceAddress = sourceAddress;
    86         }
    86         }
    87 
    87 
    88         int group() {
    88         int groupAddress() {
    89             return groupAddress;
    89             return groupAddress;
    90         }
    90         }
    91 
    91 
    92         int interfaceAddress() {
    92         int interfaceAddress() {
    93             return interfAddress;
    93             return interfAddress;
   118             this.groupAddress = groupAddress;
   118             this.groupAddress = groupAddress;
   119             this.index = index;
   119             this.index = index;
   120             this.sourceAddress = sourceAddress;
   120             this.sourceAddress = sourceAddress;
   121         }
   121         }
   122 
   122 
   123         byte[] group() {
   123         byte[] groupAddress() {
   124             return groupAddress;
   124             return groupAddress;
   125         }
   125         }
   126 
   126 
   127         int index() {
   127         int index() {
   128             return index;
   128             return index;
   140     // package-private
   140     // package-private
   141     void invalidate() {
   141     void invalidate() {
   142         valid = false;
   142         valid = false;
   143     }
   143     }
   144 
   144 
   145     public void drop() throws IOException {
   145     public void drop() {
   146         // delegate to channel
   146         // delegate to channel
   147         ((DatagramChannelImpl)ch).drop(this);
   147         ((DatagramChannelImpl)ch).drop(this);
   148     }
   148     }
   149 
   149 
   150     @Override
   150     @Override
   151     public MulticastChannel getChannel() {
   151     public MulticastChannel channel() {
   152         return ch;
   152         return ch;
   153     }
   153     }
   154 
   154 
   155     @Override
   155     @Override
   156     public InetAddress getGroup() {
   156     public InetAddress group() {
   157         return group;
   157         return group;
   158     }
   158     }
   159 
   159 
   160     @Override
   160     @Override
   161     public NetworkInterface getNetworkInterface() {
   161     public NetworkInterface networkInterface() {
   162         return interf;
   162         return interf;
   163     }
   163     }
   164 
   164 
   165     @Override
   165     @Override
   166     public InetAddress getSourceAddress() {
   166     public InetAddress sourceAddress() {
   167         return source;
   167         return source;
   168     }
   168     }
   169 
   169 
   170     @Override
   170     @Override
   171     public MembershipKey block(InetAddress toBlock)
   171     public MembershipKey block(InetAddress toBlock)
   189         }
   189         }
   190         return this;
   190         return this;
   191     }
   191     }
   192 
   192 
   193     @Override
   193     @Override
   194     public MembershipKey unblock(InetAddress toUnblock)
   194     public MembershipKey unblock(InetAddress toUnblock) {
   195         throws IOException
       
   196     {
       
   197         synchronized (stateLock) {
   195         synchronized (stateLock) {
   198             if ((blockedSet == null) || !blockedSet.contains(toUnblock))
   196             if ((blockedSet == null) || !blockedSet.contains(toUnblock))
   199                 throw new IllegalStateException("not blocked");
   197                 throw new IllegalStateException("not blocked");
   200 
   198 
   201             ((DatagramChannelImpl)ch).unblock(this, toUnblock);
   199             ((DatagramChannelImpl)ch).unblock(this, toUnblock);