Esempio n. 1
0
  /** Remove a channel. */
  public void removeChannel(Channel channel) {
    String name = channel.getConfig().getName().toLowerCase();

    // unregister the channel
    channels.remove(channel);
    channelMap.remove(name.toLowerCase());
  }
Esempio n. 2
0
 /**
  * Create a channel initialized with the specified configuration.
  *
  * @param config the channel configuration
  * @param start initial state
  */
 public Channel createChannel(ChannelConfig config, boolean start) {
   Channel channel = new Channel(config);
   channel.setName("channel: " + config.getName());
   if (start) {
     channel.start();
   }
   channels.add(channel);
   channelMap.put(config.getName().toLowerCase(), channel);
   return channel;
 }
Esempio n. 3
0
  /**
   * Returns the channel with the specified name. The leading # is removed from the name before
   * searching. The name is not case sensitive. If no channel matches the name specified, it can
   * return the first channel starting with the name if the <code>partial</code> parameter is set to
   * <code>true</code>.
   *
   * @param name the name of the channel to find
   * @param partial use the partial name matching
   * @return instance of the specified channel, <tt>null</tt> if not found
   */
  public Channel getChannel(String name, boolean partial) {
    // stripping leading #
    name = name.replaceFirst("#", "").toLowerCase();

    Channel channel = channelMap.get(name);

    if (channel == null && partial) {
      // match a partial name
      Iterator<String> names = channelMap.keySet().iterator();
      while (channel == null && names.hasNext()) {
        String name2 = names.next();
        if (name2.startsWith(name)) {
          channel = channelMap.get(name2);
        }
      }
    }

    return channel;
  }
Esempio n. 4
0
 /** Clear the channel list. */
 public void clear() {
   channels.clear();
   channelMap.clear();
 }