/** Obtains a set of all listeners for given type. * @param type type of events to test * @return unmutable set of all listeners (Node) for a type */ public synchronized java.util.Set listenersFor (ConnectionCookie.Type type) { LinkedList list; if (type.isPersistent ()) { list = (LinkedList)entry.getFile ().getAttribute (EA_LISTENERS); } else { list = listeners; } if (list == null) return Collections.EMPTY_SET; Iterator it = list.iterator (); HashSet set = new HashSet (7); while (it.hasNext ()) { Pair pair = (Pair)it.next (); if (type.overlaps(pair.getType ())) { try { set.add (pair.getNode ()); } catch (IOException e) { // ignore the exception } } } return set; }
boolean persistent = type.isPersistent (); LinkedList list;
boolean persistent = type.isPersistent (); LinkedList list;
ConnectionCookie.Type type = ev.getType (); boolean persistent = type.isPersistent (); if (persistent) { list = (LinkedList)entry.getFile ().getAttribute (EA_LISTENERS); Pair pair = (Pair)it.next (); if (pair.getType ().overlaps(ev.getType())) { try { ConnectionCookie.Listener l = (ConnectionCookie.Listener)pair.getNode ().getCookie (ConnectionCookie.Listener.class);
/** Test if the type is supported. * @param t type * @exception InvalidObjectException if type is not valid */ private void testSupported (ConnectionCookie.Type t) throws InvalidObjectException { for (int i = 0; i < types.length; i++) { if (t.overlaps(types[i])) { return; } } throw new InvalidObjectException (t.toString ()); }