Ejemplo n.º 1
0
 /**
  * Update Status Monitor Parameter
  *
  * @param param parameter to replace
  * @throws XPathExpressionException
  */
 public void updateStatParameter(PhoneLabParameter param) throws XPathExpressionException {
   Element statusElement =
       (Element) xpath.evaluate("/manifest/statusmonitor", document, XPathConstants.NODE);
   Node pNode =
       (Node)
           xpath.evaluate(
               "parameter[@name='" + param.getName() + "']", statusElement, XPathConstants.NODE);
   statusElement.removeChild(pNode);
   Element newElement = document.createElement("parameter");
   if (param.getUnits() != null) newElement.setAttribute("units", param.getUnits());
   if (param.getValue() != null) newElement.setAttribute("value", param.getValue());
   if (param.getSetBy() != null) newElement.setAttribute("set_by", param.getSetBy());
   statusElement.appendChild(newElement);
 }
Ejemplo n.º 2
0
  /**
   * Add Status Monitor Parameter to manifest
   *
   * @param param parameter to add
   * @throws XPathExpressionException
   */
  public void addStatParameters(PhoneLabParameter param) throws XPathExpressionException {
    Node node = (Node) xpath.evaluate("/manifest/statusmonitor", document, XPathConstants.NODE);
    Element statusElement = null;
    if (node == null) { // no status monitor
      statusElement = document.createElement("statusmonitor");
      document.getFirstChild().appendChild(statusElement);
    } else {
      statusElement = (Element) node;
    }

    Element newElement = document.createElement("parameter");
    if (param.getUnits() != null) newElement.setAttribute("units", param.getUnits());
    if (param.getValue() != null) newElement.setAttribute("value", param.getValue());
    if (param.getSetBy() != null) newElement.setAttribute("set_by", param.getSetBy());
    statusElement.appendChild(newElement);
  }