コード例 #1
0
  public void appendChannelListFromPattern() {
    try {
      // Create a sink and connect:
      Sink sink = new Sink();
      sink.OpenRBNBConnection(getServer(), sinkName);

      // get all the channel paths that match the pattern
      ChannelMap sMap = new ChannelMap();
      sink.RequestRegistration();
      sMap = sink.Fetch(-1, sMap);
      ChannelTree tree = ChannelTree.createFromChannelMap(sMap);

      Pattern p = Pattern.compile(channelPathPattern);
      // for each channel path, check match, collect matches...

      Iterator nodes = tree.iterator();
      while (nodes.hasNext()) {
        ChannelTree.Node n = (ChannelTree.Node) nodes.next();
        // System.out.println("Checking " + n.getFullName() + ";" + n.getName());
        if (!includeHidden && n.getFullName().startsWith("_")) continue;
        if (n.getType() != ChannelTree.CHANNEL) continue;
        String name = n.getFullName();
        Matcher m = p.matcher(name);
        if (m.matches()) {
          //					System.out.println("Matches");
          boolean isSource = false;
          ChannelTree.Node upNode = n.getParent();
          while ((!isSource) || (upNode != null)) {
            if (upNode.getType() == ChannelTree.SOURCE) isSource = true;
            upNode = upNode.getParent();
          }
          if (isSource) {
            // System.out.println("... and is a source.");
            channelPathList.add(n);
          } else {
            // System.out.println("... and is NOT a source.");
          }
        }
      }

    } catch (SAPIException se) {
      se.printStackTrace();
    }
  } // appendChannelListFromPattern
コード例 #2
0
  public void appendChannelListFromString() {
    try {
      StringTokenizer st = new StringTokenizer(channelPathListString, ",");

      // Create a sink and connect:
      Sink sink = new Sink();
      sink.OpenRBNBConnection(getServer(), sinkName);

      // get all the channel paths that match the pattern
      ChannelMap sMap = new ChannelMap();
      sink.RequestRegistration();
      sMap = sink.Fetch(-1, sMap);
      ChannelTree tree = ChannelTree.createFromChannelMap(sMap);

      Pattern p = Pattern.compile(channelPathPattern);
      // for each channel path, check match, collect matches...

      while (st.hasMoreTokens()) {
        String path = st.nextToken();
        //				System.out.println("Checking " + path);

        ChannelTree.Node n = tree.findNode(path);
        if (n == null) continue;
        if (n.getType() != ChannelTree.CHANNEL) continue;
        String name = n.getFullName();
        //				System.out.println("Found it...");
        boolean isSource = false;
        ChannelTree.Node upNode = n.getParent();
        while ((!isSource) || (upNode != null)) {
          if (upNode.getType() == ChannelTree.SOURCE) isSource = true;
          upNode = upNode.getParent();
        }
        if (isSource) {
          //					System.out.println("... and is a source.");
          channelPathList.add(n);
        } else {
          //					System.out.println("... and is NOT a source.");
        }
      } // while next token
    } catch (SAPIException se) {
      se.printStackTrace();
    }
  } // appendChannelListFromString