Search in sources :

Example 26 with Node

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

the class Action method getArgumentList.

// //////////////////////////////////////////////
// argumentList
// //////////////////////////////////////////////
public ArgumentList getArgumentList() {
    ArgumentList argumentList = new ArgumentList();
    Node argumentListNode = getActionNode().getNode(ArgumentList.ELEM_NAME);
    if (argumentListNode == null)
        return argumentList;
    int nodeCnt = argumentListNode.getNNodes();
    for (int n = 0; n < nodeCnt; n++) {
        Node node = argumentListNode.getNode(n);
        if (Argument.isArgumentNode(node) == false)
            continue;
        Argument argument = new Argument(getServiceNode(), node);
        argumentList.add(argument);
    }
    return argumentList;
}
Also used : Node(org.cybergarage.xml.Node)

Example 27 with Node

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

the class JaxpParser method parse.

// //////////////////////////////////////////////
// parse (Node)
// //////////////////////////////////////////////
public org.cybergarage.xml.Node parse(org.cybergarage.xml.Node parentNode, org.w3c.dom.Node domNode, int rank) {
    int domNodeType = domNode.getNodeType();
    // if (domNodeType != Node.ELEMENT_NODE)
    // return;
    String domNodeName = domNode.getNodeName();
    String domNodeValue = domNode.getNodeValue();
    NamedNodeMap attrs = domNode.getAttributes();
    int arrrsLen = (attrs != null) ? attrs.getLength() : 0;
    if (domNodeType == org.w3c.dom.Node.TEXT_NODE) {
        // Change to use Node::addValue() instead of the setValue(). (2008/02/07)
        // parentNode.setValue(domNodeValue);
        parentNode.addValue(domNodeValue);
        return parentNode;
    }
    if (domNodeType != org.w3c.dom.Node.ELEMENT_NODE)
        return parentNode;
    org.cybergarage.xml.Node node = new org.cybergarage.xml.Node();
    node.setName(domNodeName);
    node.setValue(domNodeValue);
    if (parentNode != null)
        parentNode.addNode(node);
    NamedNodeMap attrMap = domNode.getAttributes();
    if (attrMap != null) {
        int attrLen = attrMap.getLength();
        // Debug.message("attrLen = " + attrLen);
        for (int n = 0; n < attrLen; n++) {
            org.w3c.dom.Node attr = attrMap.item(n);
            String attrName = attr.getNodeName();
            String attrValue = attr.getNodeValue();
            node.setAttribute(attrName, attrValue);
        }
    }
    org.w3c.dom.Node child = domNode.getFirstChild();
    if (child == null) {
        node.setValue("");
        return node;
    }
    do {
        parse(node, child, rank + 1);
        child = child.getNextSibling();
    } while (child != null);
    return node;
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.cybergarage.xml.Node) Node(org.cybergarage.xml.Node)

Example 28 with Node

use of org.cybergarage.xml.Node in project felix by apache.

the class BuildDevice method buildRootNode.

private static Node buildRootNode() {
    Node root = new Node(RootDescription.ROOT_ELEMENT);
    root.setAttribute("xmlns", 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);
    return root;
}
Also used : Node(org.cybergarage.xml.Node)

Example 29 with Node

use of org.cybergarage.xml.Node in project felix by apache.

the class BuildDevice method createCyberLinkDevice.

public static Device createCyberLinkDevice(ServiceReference sr) {
    Node root = buildRootNode();
    Device devUPnP = buildRootDeviceNode(root, sr);
    return devUPnP;
}
Also used : UPnPDevice(org.osgi.service.upnp.UPnPDevice) Device(org.cybergarage.upnp.Device) Node(org.cybergarage.xml.Node)

Example 30 with Node

use of org.cybergarage.xml.Node in project felix by apache.

the class BuildDevice method buildDevice.

private static void buildDevice(String id, Device parent, ServiceReference sr) {
    Node dev = new Node(Device.ELEM_NAME);
    DeviceData dd = new DeviceData();
    dd.setDescriptionURI(id + "/gen-desc.xml");
    dev.setUserData(dd);
    Device devUPnP = new Device(dev);
    devUPnP.setDeviceType(extractDeviceType(sr));
    devUPnP.setFriendlyName((String) sr.getProperty(UPnPDevice.FRIENDLY_NAME));
    devUPnP.setManufacture((String) sr.getProperty(UPnPDevice.MANUFACTURER));
    devUPnP.setManufactureURL((String) sr.getProperty(UPnPDevice.MANUFACTURER_URL));
    devUPnP.setModelDescription((String) sr.getProperty(UPnPDevice.MODEL_DESCRIPTION));
    devUPnP.setModelName((String) sr.getProperty(UPnPDevice.MODEL_NAME));
    devUPnP.setModelNumber((String) sr.getProperty(UPnPDevice.MODEL_NUMBER));
    devUPnP.setModelURL((String) sr.getProperty(UPnPDevice.MODEL_URL));
    devUPnP.setSerialNumber((String) sr.getProperty(UPnPDevice.SERIAL_NUMBER));
    devUPnP.setUDN((String) sr.getProperty(UPnPDevice.UDN));
    devUPnP.setUPC((String) sr.getProperty(UPnPDevice.UPC));
    devUPnP.setLocation(id + "/gen-desc.xml");
    addServices(id, devUPnP, sr);
    addDevices(id, devUPnP, sr);
    // twa: essential!!!!!!!
    parent.addDevice(devUPnP);
    devUPnP.setPresentationURL((String) sr.getProperty(UPnPDevice.PRESENTATION_URL));
}
Also used : UPnPDevice(org.osgi.service.upnp.UPnPDevice) Device(org.cybergarage.upnp.Device) Node(org.cybergarage.xml.Node) DeviceData(org.cybergarage.upnp.xml.DeviceData)

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