コード例 #1
0
ファイル: ChannelId.java プロジェクト: hao2181/cometd
  /**
   * Tests whether this {@code ChannelId} matches the given {@code ChannelId}.
   *
   * <p>If the given {@code ChannelId} is {@link #isWild() wild}, then it matches only if it is
   * equal to this {@code ChannelId}.
   *
   * <p>If this {@code ChannelId} is non-wild, then it matches only if it is equal to the given
   * {@code ChannelId}.
   *
   * <p>Otherwise, this {@code ChannelId} is either shallow or deep wild, and matches {@code
   * ChannelId}s with the same number of equal segments (if it is shallow wild), or {@code
   * ChannelId}s with the same or a greater number of equal segments (if it is deep wild).
   *
   * @param channelId the channelId to match
   * @return true if this {@code ChannelId} matches the given {@code ChannelId}
   */
  public boolean matches(ChannelId channelId) {
    resolve();

    if (channelId.isWild()) return equals(channelId);

    switch (_wild) {
      case 0:
        {
          return equals(channelId);
        }
      case 1:
        {
          if (channelId._segments.length != _segments.length) return false;
          for (int i = _segments.length - 1; i-- > 0; )
            if (!_segments[i].equals(channelId._segments[i])) return false;
          return true;
        }
      case 2:
        {
          if (channelId._segments.length < _segments.length) return false;
          for (int i = _segments.length - 1; i-- > 0; )
            if (!_segments[i].equals(channelId._segments[i])) return false;
          return true;
        }
      default:
        {
          throw new IllegalStateException();
        }
    }
  }
コード例 #2
0
ファイル: ChannelId.java プロジェクト: hao2181/cometd
  /**
   * @param id the channel to test
   * @return whether this {@code ChannelId} is the parent of the given {@code ChannelId}
   * @see #isAncestorOf(ChannelId)
   */
  public boolean isParentOf(ChannelId id) {
    resolve();

    if (isWild() || depth() != id.depth() - 1) return false;

    for (int i = _segments.length; i-- > 0; ) {
      if (!_segments[i].equals(id._segments[i])) return false;
    }
    return true;
  }
コード例 #3
0
 @Override
 public String toString() {
   return _id.toString();
 }
コード例 #4
0
 public boolean isService() {
   return _id.isService();
 }
コード例 #5
0
 public boolean isMeta() {
   return _id.isMeta();
 }
コード例 #6
0
 public String getId() {
   return _id.toString();
 }
コード例 #7
0
 public boolean isWild() {
   return _id.isWild();
 }