Package org.cybergarage.xml

Examples of org.cybergarage.xml.Node


   *
   * @param s
   *            Add Service s to the Device
   */
  public void addService(Service s) {
    Node serviceListNode = getDeviceNode().getNode(ServiceList.ELEM_NAME);
    if (serviceListNode == null) {
      serviceListNode = new Node(ServiceList.ELEM_NAME);
      getDeviceNode().addNode(serviceListNode);
    }
    serviceListNode.addNode(s.getServiceNode());
  }
View Full Code Here


   *
   * @author Stefano "Kismet" Lenzi - kismet-sl@users.sourceforge.net - 2005
   *
   */
  public void addDevice(Device d) {
    Node deviceListNode = getDeviceNode().getNode(DeviceList.ELEM_NAME);
    if (deviceListNode == null) {
      // deviceListNode = new Node(ServiceList.ELEM_NAME); twa wrong
      // ELEM_NAME;
      deviceListNode = new Node(DeviceList.ELEM_NAME);
      getDeviceNode().addNode(deviceListNode);
    }
    deviceListNode.addNode(d.getDeviceNode());
    d.setRootNode(null);
    if (getRootNode() == null) {
      Node root = new Node(RootDescription.ROOT_ELEMENT);
      root.setNameSpace("", RootDescription.ROOT_ELEMENT_NAMESPACE);
      Node spec = new Node(RootDescription.SPECVERSION_ELEMENT);
      Node maj = new Node(RootDescription.MAJOR_ELEMENT);
      maj.setValue("1");
      Node min = new Node(RootDescription.MINOR_ELEMENT);
      min.setValue("0");
      spec.addNode(maj);
      spec.addNode(min);
      root.addNode(spec);
      setRootNode(root);
    }
View Full Code Here

  // //////////////////////////////////////////////
  // UserData
  // //////////////////////////////////////////////

  private DeviceData getDeviceData() {
    Node node = getDeviceNode();
    DeviceData userData = (DeviceData) node.getUserData();
    if (userData == null) {
      userData = new DeviceData();
      node.setUserData(userData);
      userData.setNode(node);
    }
    return userData;
  }
View Full Code Here

  private final static String URLBASE_NAME = "URLBase";

  private void setURLBase(String value) {
    if (isRootDevice() == true) {
      Node node = getRootNode().getNode(URLBASE_NAME);
      if (node != null) {
        node.setValue(value);
        return;
      }
      node = new Node(URLBASE_NAME);
      node.setValue(value);
      int index = 1;
      if (getRootNode().hasNodes() == false)
        index = 1;
      getRootNode().insertNode(node, index);
    }
View Full Code Here

  // deviceList
  // //////////////////////////////////////////////

  public DeviceList getDeviceList() {
    DeviceList devList = new DeviceList();
    Node devListNode = getDeviceNode().getNode(DeviceList.ELEM_NAME);
    if (devListNode == null)
      return devList;
    int nNode = devListNode.getNNodes();
    for (int n = 0; n < nNode; n++) {
      Node node = devListNode.getNode(n);
      if (Device.isDeviceNode(node) == false)
        continue;
      Device dev = new Device(node);
      devList.add(dev);
    }
View Full Code Here

  // serviceList
  // //////////////////////////////////////////////

  public ServiceList getServiceList() {
    ServiceList serviceList = new ServiceList();
    Node serviceListNode = getDeviceNode().getNode(ServiceList.ELEM_NAME);
    if (serviceListNode == null)
      return serviceList;
    int nNode = serviceListNode.getNNodes();
    for (int n = 0; n < nNode; n++) {
      Node node = serviceListNode.getNode(n);
      if (Service.isServiceNode(node) == false)
        continue;
      Service service = new Service(node);
      serviceList.add(service);
    }
View Full Code Here

   
    return null;
  }

  public boolean addIcon(Icon icon) {
    Node deviceNode = getDeviceNode();
    if (deviceNode == null)
      return false;

    Node iconListNode = deviceNode.getNode(IconList.ELEM_NAME);
    if (iconListNode == null) {
      iconListNode = new Node(IconList.ELEM_NAME);
      deviceNode.addNode(iconListNode);
    }

    Node iconNode = new Node(Icon.ELEM_NAME);
    if (icon.getIconNode() != null) {
      iconNode.set(icon.getIconNode());
    }
    iconListNode.addNode(iconNode);

    if (icon.hasURL() && icon.hasBytes()) {
      iconBytesMap.put(icon.getURL(), icon.getBytes());
View Full Code Here

    return true;
  }

  public IconList getIconList() {
    IconList iconList = new IconList();
    Node iconListNode = getDeviceNode().getNode(IconList.ELEM_NAME);
    if (iconListNode == null)
      return iconList;
    int nNode = iconListNode.getNNodes();
    for (int n = 0; n < nNode; n++) {
      Node node = iconListNode.getNode(n);
      if (Icon.isIconNode(node) == false)
        continue;
      Icon icon = new Icon(node);
      if (icon.hasURL()) {
        String iconURL = icon.getURL();
View Full Code Here

  }

  private synchronized byte[] getDescriptionData(String host) {
    if (isNMPRMode() == false)
      updateURLBase(host);
    Node rootNode = getRootNode();
    if (rootNode == null)
      return new byte[0];
    // Thanks for Mikael Hakman (04/25/05)
    String desc = new String();
    desc += UPnP.XML_DECLARATION;
    desc += "\n";
    desc += rootNode.toString();
    return desc.getBytes();
  }
View Full Code Here

    allowedValueRangeNode = node;
  }

  public AllowedValueRange(){
    //TODO Test
    allowedValueRangeNode = new Node(ELEM_NAME);
  }
View Full Code Here

TOP

Related Classes of org.cybergarage.xml.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.