Ejemplo n.º 1
0
 /**
  * Internal method used to copy from manifest status monitor parameter to PhoneLabParameter class
  * instance
  *
  * @param param
  * @param element
  */
 private void copyParameter(PhoneLabParameter param, Element element) {
   NamedNodeMap map = element.getAttributes();
   for (int i = 0; i < map.getLength(); i++) {
     Node attr = map.item(i);
     if (attr.getNodeName().equals("name")) {
       param.setName(attr.getNodeValue());
     } else if (attr.getNodeName().equals("value")) {
       param.setValue(attr.getNodeValue());
     } else if (attr.getNodeName().equals("units")) {
       param.setUnits(attr.getNodeValue());
     } else if (attr.getNodeName().equals("setby")) {
       param.setSetBy(attr.getNodeValue());
     }
   }
 }
Ejemplo n.º 2
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.º 3
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);
  }