Search in sources :

Example 46 with Node

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

the class StateVariable method getAllowedValueList.

// //////////////////////////////////////////////
// AllowedValueList
// //////////////////////////////////////////////
public AllowedValueList getAllowedValueList() {
    AllowedValueList valueList = new AllowedValueList();
    Node valueListNode = getStateVariableNode().getNode(AllowedValueList.ELEM_NAME);
    if (valueListNode == null)
        return null;
    int nNode = valueListNode.getNNodes();
    for (int n = 0; n < nNode; n++) {
        Node node = valueListNode.getNode(n);
        if (AllowedValue.isAllowedValueNode(node) == false)
            continue;
        AllowedValue allowedVal = new AllowedValue(node);
        valueList.add(allowedVal);
    }
    return valueList;
}
Also used : Node(org.cybergarage.xml.Node)

Example 47 with Node

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

the class ControlPoint method getDevice.

public Device getDevice(String name) {
    int nRoots = devNodeList.size();
    for (int n = 0; n < nRoots; n++) {
        // AIOOB was thrown from here, maybe would be better to
        // copy the list before traversal?
        Node rootNode;
        try {
            rootNode = devNodeList.getNode(n);
        } catch (ArrayIndexOutOfBoundsException aioob) {
            break;
        }
        Device dev = getDevice(rootNode);
        if (dev == null)
            continue;
        if (dev.isDevice(name) == true)
            return dev;
        Device cdev = dev.getDevice(name);
        if (cdev != null)
            return cdev;
    }
    return null;
}
Also used : Node(org.cybergarage.xml.Node)

Example 48 with Node

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

the class Device method getDeviceData.

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

Example 49 with Node

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

the class Device method getDescriptionData.

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

Example 50 with Node

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

the class Device method addDevice.

/**
 * Add a Device to device without checking for duplicate or syntax error.
 * This method set or reset the root node of the Device and itself<br>
 * <br>
 * Note: This method should be used to create a dynamic<br>
 * Device withtout writing any XML that describe the device<br>
 *
 * @param d Add Device d to the Device
 */
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);
    }
}
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