Search in sources :

Example 11 with Node

use of org.cybergarage.xml.Node in project i2p.i2p by i2p.

the class Device method getServiceList.

// //////////////////////////////////////////////
// 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);
    }
    return serviceList;
}
Also used : Node(org.cybergarage.xml.Node)

Example 12 with Node

use of org.cybergarage.xml.Node in project i2p.i2p by i2p.

the class Device method getParentDevice.

// //////////////////////////////////////////////
// Parent Device
// //////////////////////////////////////////////
// Thanks for Stefano Lenzi (07/24/04)
/**
 * @return A Device that contain this object.<br>
 *         Return <code>null</code> if this is a root device.
 */
public Device getParentDevice() {
    if (isRootDevice())
        return null;
    Node devNode = getDeviceNode();
    Node aux = null;
    // <device><deviceList><device>
    aux = devNode.getParentNode().getParentNode();
    return new Device(aux);
}
Also used : Node(org.cybergarage.xml.Node)

Example 13 with Node

use of org.cybergarage.xml.Node in project i2p.i2p by i2p.

the class Device method getRootDevice.

// //////////////////////////////////////////////
// Root Device
// //////////////////////////////////////////////
public Device getRootDevice() {
    Node rootNode = getRootNode();
    if (rootNode == null)
        return null;
    Node devNode = rootNode.getNode(Device.ELEM_NAME);
    if (devNode == null)
        return null;
    return new Device(rootNode, devNode);
}
Also used : Node(org.cybergarage.xml.Node)

Example 14 with Node

use of org.cybergarage.xml.Node in project i2p.i2p by i2p.

the class Device method getIconList.

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();
            byte[] iconBytes = iconBytesMap.get(iconURL);
            if (iconBytes != null) {
                icon.setBytes(iconBytes);
            }
        }
        iconList.add(icon);
    }
    return iconList;
}
Also used : Node(org.cybergarage.xml.Node)

Example 15 with Node

use of org.cybergarage.xml.Node in project i2p.i2p by i2p.

the class Device method updateConfigId.

private void updateConfigId(Device dev) {
    int configId = 0;
    DeviceList cdevList = dev.getDeviceList();
    int cdevCnt = cdevList.size();
    for (int n = 0; n < cdevCnt; n++) {
        Device cdev = cdevList.getDevice(n);
        updateConfigId(cdev);
        configId += cdev.getConfigId();
        configId &= UPnP.CONFIGID_UPNP_ORG_MAX;
    }
    ServiceList serviceList = dev.getServiceList();
    int serviceCnt = serviceList.size();
    for (int n = 0; n < serviceCnt; n++) {
        Service service = serviceList.getService(n);
        service.updateConfigId();
        configId += service.getConfigId();
        configId &= UPnP.CONFIGID_UPNP_ORG_MAX;
    }
    Node devNode = getDeviceNode();
    if (devNode == null)
        return;
    String devDescXml = devNode.toString();
    configId += UPnP.caluculateConfigId(devDescXml);
    configId &= UPnP.CONFIGID_UPNP_ORG_MAX;
    devNode.setAttribute(CONFIG_ID, configId);
}
Also used : Node(org.cybergarage.xml.Node)

Aggregations

Node (org.cybergarage.xml.Node)58 ParserException (org.cybergarage.xml.ParserException)7 ArrayList (java.util.ArrayList)5 ServiceData (org.cybergarage.upnp.xml.ServiceData)5 Parser (org.cybergarage.xml.Parser)5 IOException (java.io.IOException)4 File (java.io.File)3 Device (org.cybergarage.upnp.Device)3 DeviceData (org.cybergarage.upnp.xml.DeviceData)3 UPnPDevice (org.osgi.service.upnp.UPnPDevice)3 URL (java.net.URL)2 Log (net.i2p.util.Log)2 InvalidDescriptionException (org.cybergarage.upnp.device.InvalidDescriptionException)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)2 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1