예제 #1
0
  /**
   * Parses the serialized WiseML document and returns the {@link Node} instance with URN {@code
   * nodeID}.
   *
   * @param serializedWiseML the serialized WiseML document
   * @param nodeID the URN of the node to return
   * @return the {@link Node} instance with URN {@code nodeID}
   */
  @SuppressWarnings("unused")
  public static Node getNode(final String serializedWiseML, final String nodeID) {
    Wiseml wiseml = deserialize(serializedWiseML);

    for (Setup.Node node : wiseml.getSetup().getNode()) {
      if (node.getId().equals(nodeID)) {
        return node;
      }
    }

    return null;
  }
예제 #2
0
  /**
   * Reads out all nodes that are contained in the setup-part of the document.
   *
   * @param wiseml the WiseML document
   * @param types node types to include, e.g. "isense", "telosb" will include all iSense and all
   *     TelosB nodes contained in the WiseML document
   * @return a List of {@link Node} instances
   */
  @SuppressWarnings("unused")
  public static List<Node> getNodes(final Wiseml wiseml, final String... types) {

    List<String> nodeTypes = types == null ? null : Lists.newArrayList(types);
    List<Node> nodes = Lists.newArrayList();

    for (Node node : wiseml.getSetup().getNode()) {
      if (types == null || types.length == 0) {
        nodes.add(node);
      } else {
        // if "containsIgnoreCase"...
        for (String nodeType : nodeTypes) {
          if (nodeType.equalsIgnoreCase(node.getNodeType())) {
            nodes.add(node);
          }
        }
      }
    }

    return nodes;
  }