code: protected int getCount(int type, Collection<ConnectionListener> listeners)
     {
        int count = 0;
  
        for (ConnectionListener cl : listeners)
        {
           if (cl.getState() == type)
              count++;
        }
  
        return count;
     }
docs: Get count
  @param type The type
  @param listeners The listeners
  @return The value