Java Code Examples for org.fourthline.cling.model.types.UDN#valueOf()

The following examples show how to use org.fourthline.cling.model.types.UDN#valueOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeyondUpnpService.java    From BeyondUPnP with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    //Create LocalDevice
    LocalService localService = new AnnotationLocalServiceBinder().read(BeyondContentDirectoryService.class);
    localService.setManager(new DefaultServiceManager<>(
            localService, BeyondContentDirectoryService.class));

    String macAddress = Utils.getMACAddress(Utils.WLAN0);
    //Generate UUID by MAC address
    UDN udn = UDN.valueOf(UUID.nameUUIDFromBytes(macAddress.getBytes()).toString());

    try {
        mLocalDevice = new LocalDevice(new DeviceIdentity(udn), new UDADeviceType("MediaServer"),
                new DeviceDetails("Local Media Server"), new LocalService[]{localService});
    } catch (ValidationException e) {
        e.printStackTrace();
    }
    upnpService.getRegistry().addDevice(mLocalDevice);

    //LocalBinder instead of binder
    binder = new LocalBinder();
}
 
Example 2
Source File: ServiceReference.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public ServiceReference(String s) {
    String[] split = s.split("/");
    if (split.length == 2) {
        this.udn =  UDN.valueOf(split[0]);
        this.serviceId = ServiceId.valueOf(split[1]);
    } else {
        this.udn = null;
        this.serviceId = null;
    }
}
 
Example 3
Source File: ServiceReference.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public ServiceReference(String s) {
    String[] split = s.split("/");
    if (split.length == 2) {
        this.udn =  UDN.valueOf(split[0]);
        this.serviceId = ServiceId.valueOf(split[1]);
    } else {
        this.udn = null;
        this.serviceId = null;
    }
}
 
Example 4
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public void hydrateDevice(MutableDevice descriptor, Node deviceNode) throws DescriptorBindingException {

        NodeList deviceNodeChildren = deviceNode.getChildNodes();
        for (int i = 0; i < deviceNodeChildren.getLength(); i++) {
            Node deviceNodeChild = deviceNodeChildren.item(i);

            if (deviceNodeChild.getNodeType() != Node.ELEMENT_NODE)
                continue;

            if (ELEMENT.deviceType.equals(deviceNodeChild)) {
                descriptor.deviceType = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.friendlyName.equals(deviceNodeChild)) {
                descriptor.friendlyName = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.manufacturer.equals(deviceNodeChild)) {
                descriptor.manufacturer = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.manufacturerURL.equals(deviceNodeChild)) {
                descriptor.manufacturerURI = parseURI(XMLUtil.getTextContent(deviceNodeChild));
            } else if (ELEMENT.modelDescription.equals(deviceNodeChild)) {
                descriptor.modelDescription = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.modelName.equals(deviceNodeChild)) {
                descriptor.modelName = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.modelNumber.equals(deviceNodeChild)) {
                descriptor.modelNumber = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.modelURL.equals(deviceNodeChild)) {
                descriptor.modelURI = parseURI(XMLUtil.getTextContent(deviceNodeChild));
            } else if (ELEMENT.presentationURL.equals(deviceNodeChild)) {
                descriptor.presentationURI = parseURI(XMLUtil.getTextContent(deviceNodeChild));
            } else if (ELEMENT.UPC.equals(deviceNodeChild)) {
                descriptor.upc = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.serialNumber.equals(deviceNodeChild)) {
                descriptor.serialNumber = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.UDN.equals(deviceNodeChild)) {
                descriptor.udn = UDN.valueOf(XMLUtil.getTextContent(deviceNodeChild));
            } else if (ELEMENT.iconList.equals(deviceNodeChild)) {
                hydrateIconList(descriptor, deviceNodeChild);
            } else if (ELEMENT.serviceList.equals(deviceNodeChild)) {
                hydrateServiceList(descriptor, deviceNodeChild);
            } else if (ELEMENT.deviceList.equals(deviceNodeChild)) {
                hydrateDeviceList(descriptor, deviceNodeChild);
            } else if (ELEMENT.X_DLNADOC.equals(deviceNodeChild) &&
                    Descriptor.Device.DLNA_PREFIX.equals(deviceNodeChild.getPrefix())) {
                String txt = XMLUtil.getTextContent(deviceNodeChild);
                try {
                    descriptor.dlnaDocs.add(DLNADoc.valueOf(txt));
                } catch (InvalidValueException ex) {
                    log.info("Invalid X_DLNADOC value, ignoring value: " + txt);
                }
            } else if (ELEMENT.X_DLNACAP.equals(deviceNodeChild) &&
                    Descriptor.Device.DLNA_PREFIX.equals(deviceNodeChild.getPrefix())) {
                descriptor.dlnaCaps = DLNACaps.valueOf(XMLUtil.getTextContent(deviceNodeChild));
            }
        }
    }
 
Example 5
Source File: UDA10DeviceDescriptorBinderSAXImpl.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void endElement(ELEMENT element) throws SAXException {
    switch (element) {
        case deviceType:
            getInstance().deviceType = getCharacters();
            break;
        case friendlyName:
            getInstance().friendlyName = getCharacters();
            break;
        case manufacturer:
            getInstance().manufacturer = getCharacters();
            break;
        case manufacturerURL:
            getInstance().manufacturerURI = parseURI(getCharacters());
            break;
        case modelDescription:
            getInstance().modelDescription = getCharacters();
            break;
        case modelName:
            getInstance().modelName = getCharacters();
            break;
        case modelNumber:
            getInstance().modelNumber = getCharacters();
            break;
        case modelURL:
            getInstance().modelURI = parseURI(getCharacters());
            break;
        case presentationURL:
            getInstance().presentationURI = parseURI(getCharacters());
            break;
        case UPC:
            getInstance().upc = getCharacters();
            break;
        case serialNumber:
            getInstance().serialNumber = getCharacters();
            break;
        case UDN:
            getInstance().udn = UDN.valueOf(getCharacters());
            break;
        case X_DLNADOC:
            String txt = getCharacters();
            try {
                getInstance().dlnaDocs.add(DLNADoc.valueOf(txt));
            } catch (InvalidValueException ex) {
                log.info("Invalid X_DLNADOC value, ignoring value: " + txt);
            }
            break;
        case X_DLNACAP:
            getInstance().dlnaCaps = DLNACaps.valueOf(getCharacters());
            break;
    }
}
 
Example 6
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public void hydrateDevice(MutableDevice descriptor, Node deviceNode) throws DescriptorBindingException {

        NodeList deviceNodeChildren = deviceNode.getChildNodes();
        for (int i = 0; i < deviceNodeChildren.getLength(); i++) {
            Node deviceNodeChild = deviceNodeChildren.item(i);

            if (deviceNodeChild.getNodeType() != Node.ELEMENT_NODE)
                continue;

            if (ELEMENT.deviceType.equals(deviceNodeChild)) {
                descriptor.deviceType = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.friendlyName.equals(deviceNodeChild)) {
                descriptor.friendlyName = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.manufacturer.equals(deviceNodeChild)) {
                descriptor.manufacturer = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.manufacturerURL.equals(deviceNodeChild)) {
                descriptor.manufacturerURI = parseURI(XMLUtil.getTextContent(deviceNodeChild));
            } else if (ELEMENT.modelDescription.equals(deviceNodeChild)) {
                descriptor.modelDescription = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.modelName.equals(deviceNodeChild)) {
                descriptor.modelName = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.modelNumber.equals(deviceNodeChild)) {
                descriptor.modelNumber = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.modelURL.equals(deviceNodeChild)) {
                descriptor.modelURI = parseURI(XMLUtil.getTextContent(deviceNodeChild));
            } else if (ELEMENT.presentationURL.equals(deviceNodeChild)) {
                descriptor.presentationURI = parseURI(XMLUtil.getTextContent(deviceNodeChild));
            } else if (ELEMENT.UPC.equals(deviceNodeChild)) {
                descriptor.upc = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.serialNumber.equals(deviceNodeChild)) {
                descriptor.serialNumber = XMLUtil.getTextContent(deviceNodeChild);
            } else if (ELEMENT.UDN.equals(deviceNodeChild)) {
                descriptor.udn = UDN.valueOf(XMLUtil.getTextContent(deviceNodeChild));
            } else if (ELEMENT.iconList.equals(deviceNodeChild)) {
                hydrateIconList(descriptor, deviceNodeChild);
            } else if (ELEMENT.serviceList.equals(deviceNodeChild)) {
                hydrateServiceList(descriptor, deviceNodeChild);
            } else if (ELEMENT.deviceList.equals(deviceNodeChild)) {
                hydrateDeviceList(descriptor, deviceNodeChild);
            } else if (ELEMENT.X_DLNADOC.equals(deviceNodeChild) &&
                    Descriptor.Device.DLNA_PREFIX.equals(deviceNodeChild.getPrefix())) {
                String txt = XMLUtil.getTextContent(deviceNodeChild);
                try {
                    descriptor.dlnaDocs.add(DLNADoc.valueOf(txt));
                } catch (InvalidValueException ex) {
                    log.info("Invalid X_DLNADOC value, ignoring value: " + txt);
                }
            } else if (ELEMENT.X_DLNACAP.equals(deviceNodeChild) &&
                    Descriptor.Device.DLNA_PREFIX.equals(deviceNodeChild.getPrefix())) {
                descriptor.dlnaCaps = DLNACaps.valueOf(XMLUtil.getTextContent(deviceNodeChild));
            }
        }
    }
 
Example 7
Source File: UDA10DeviceDescriptorBinderSAXImpl.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void endElement(ELEMENT element) throws SAXException {
    switch (element) {
        case deviceType:
            getInstance().deviceType = getCharacters();
            break;
        case friendlyName:
            getInstance().friendlyName = getCharacters();
            break;
        case manufacturer:
            getInstance().manufacturer = getCharacters();
            break;
        case manufacturerURL:
            getInstance().manufacturerURI = parseURI(getCharacters());
            break;
        case modelDescription:
            getInstance().modelDescription = getCharacters();
            break;
        case modelName:
            getInstance().modelName = getCharacters();
            break;
        case modelNumber:
            getInstance().modelNumber = getCharacters();
            break;
        case modelURL:
            getInstance().modelURI = parseURI(getCharacters());
            break;
        case presentationURL:
            getInstance().presentationURI = parseURI(getCharacters());
            break;
        case UPC:
            getInstance().upc = getCharacters();
            break;
        case serialNumber:
            getInstance().serialNumber = getCharacters();
            break;
        case UDN:
            getInstance().udn = UDN.valueOf(getCharacters());
            break;
        case X_DLNADOC:
            String txt = getCharacters();
            try {
                getInstance().dlnaDocs.add(DLNADoc.valueOf(txt));
            } catch (InvalidValueException ex) {
                log.info("Invalid X_DLNADOC value, ignoring value: " + txt);
            }
            break;
        case X_DLNACAP:
            getInstance().dlnaCaps = DLNACaps.valueOf(getCharacters());
            break;
    }
}