Java Code Examples for org.fourthline.cling.model.message.header.UpnpHeader#getValue()

The following examples show how to use org.fourthline.cling.model.message.header.UpnpHeader#getValue() . 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: IncomingSearchResponse.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
public UDN getRootDeviceUDN() {
    // This processes the headers as specified in UDA 1.0, tables in section 1.1.12

    UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class);
    if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn();

    UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class);
    if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn();

    return null;
}
 
Example 2
Source File: IncomingNotificationRequest.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return The UDN value after parsing various USN header values, or <code>null</code>.
 */
public UDN getUDN() {
    // This processes the headers as specified in UDA 1.0, tables in section 1.1.12

    UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class);
    if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn();

    UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class);
    if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn();

    return null;
}
 
Example 3
Source File: IncomingSearchResponse.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
public UDN getRootDeviceUDN() {
    // This processes the headers as specified in UDA 1.0, tables in section 1.1.12

    UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class);
    if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn();

    UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class);
    if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn();

    return null;
}
 
Example 4
Source File: IncomingNotificationRequest.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @return The UDN value after parsing various USN header values, or <code>null</code>.
 */
public UDN getUDN() {
    // This processes the headers as specified in UDA 1.0, tables in section 1.1.12

    UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class);
    if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn();

    UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class);
    if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn();

    return null;
}
 
Example 5
Source File: IncomingEventRequestMessage.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return <code>true</code> if this message as an NT and NTS header.
 */
public boolean hasNotificationHeaders() {
    UpnpHeader ntHeader = getHeaders().getFirstHeader(UpnpHeader.Type.NT);
    UpnpHeader ntsHeader = getHeaders().getFirstHeader(UpnpHeader.Type.NTS);
    return ntHeader != null && ntHeader.getValue() != null
            && ntsHeader != null && ntsHeader.getValue() != null;
}
 
Example 6
Source File: UpnpHeaders.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void parseHeaders() {
    // This runs as late as possible and only when necessary (getter called and map is dirty)
    parsedHeaders = new LinkedHashMap();
    if (log.isLoggable(Level.FINE))
        log.fine("Parsing all HTTP headers for known UPnP headers: " + size());
    for (Entry<String, List<String>> entry : entrySet()) {

        if (entry.getKey() == null) continue; // Oh yes, the JDK has 'null' HTTP headers

        UpnpHeader.Type type = UpnpHeader.Type.getByHttpName(entry.getKey());
        if (type == null) {
            if (log.isLoggable(Level.FINE))
                log.fine("Ignoring non-UPNP HTTP header: " + entry.getKey());
            continue;
        }

        for (String value : entry.getValue()) {
            UpnpHeader upnpHeader = UpnpHeader.newInstance(type, value);
            if (upnpHeader == null || upnpHeader.getValue() == null) {
                if (log.isLoggable(Level.FINE))
                    log.fine(
                        "Ignoring known but irrelevant header (value violates the UDA specification?) '"
                            + type.getHttpName()
                            + "': "
                            + value
                    );
            } else {
                addParsedValue(type, upnpHeader);
            }
        }
    }
}
 
Example 7
Source File: DLNAHeaders.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void parseHeaders() {
    if (parsedHeaders == null) super.parseHeaders();
    
    // This runs as late as possible and only when necessary (getter called and map is dirty)
    parsedDLNAHeaders = new LinkedHashMap();
    log.log(Level.FINE, "Parsing all HTTP headers for known UPnP headers: {0}", size());
    for (Entry<String, List<String>> entry : entrySet()) {

        if (entry.getKey() == null) continue; // Oh yes, the JDK has 'null' HTTP headers

        DLNAHeader.Type type = DLNAHeader.Type.getByHttpName(entry.getKey());
        if (type == null) {
            log.log(Level.FINE, "Ignoring non-UPNP HTTP header: {0}", entry.getKey());
            continue;
        }

        for (String value : entry.getValue()) {
            UpnpHeader upnpHeader = DLNAHeader.newInstance(type, value);
            if (upnpHeader == null || upnpHeader.getValue() == null) {
                log.log(Level.FINE, "Ignoring known but non-parsable header (value violates the UDA specification?) '{0}': {1}", new Object[]{type.getHttpName(), value});
            } else {
                addParsedValue(type, upnpHeader);
            }
        }
    }
}
 
Example 8
Source File: IncomingEventRequestMessage.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return <code>true</code> if this message as an NT and NTS header.
 */
public boolean hasNotificationHeaders() {
    UpnpHeader ntHeader = getHeaders().getFirstHeader(UpnpHeader.Type.NT);
    UpnpHeader ntsHeader = getHeaders().getFirstHeader(UpnpHeader.Type.NTS);
    return ntHeader != null && ntHeader.getValue() != null
            && ntsHeader != null && ntsHeader.getValue() != null;
}
 
Example 9
Source File: UpnpHeaders.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void parseHeaders() {
    // This runs as late as possible and only when necessary (getter called and map is dirty)
    parsedHeaders = new LinkedHashMap();
    if (log.isLoggable(Level.FINE))
        log.fine("Parsing all HTTP headers for known UPnP headers: " + size());
    for (Entry<String, List<String>> entry : entrySet()) {

        if (entry.getKey() == null) continue; // Oh yes, the JDK has 'null' HTTP headers

        UpnpHeader.Type type = UpnpHeader.Type.getByHttpName(entry.getKey());
        if (type == null) {
            if (log.isLoggable(Level.FINE))
                log.fine("Ignoring non-UPNP HTTP header: " + entry.getKey());
            continue;
        }

        for (String value : entry.getValue()) {
            UpnpHeader upnpHeader = UpnpHeader.newInstance(type, value);
            if (upnpHeader == null || upnpHeader.getValue() == null) {
                if (log.isLoggable(Level.FINE))
                    log.fine(
                        "Ignoring known but irrelevant header (value violates the UDA specification?) '"
                            + type.getHttpName()
                            + "': "
                            + value
                    );
            } else {
                addParsedValue(type, upnpHeader);
            }
        }
    }
}
 
Example 10
Source File: DLNAHeaders.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void parseHeaders() {
    if (parsedHeaders == null) super.parseHeaders();
    
    // This runs as late as possible and only when necessary (getter called and map is dirty)
    parsedDLNAHeaders = new LinkedHashMap();
    log.log(Level.FINE, "Parsing all HTTP headers for known UPnP headers: {0}", size());
    for (Entry<String, List<String>> entry : entrySet()) {

        if (entry.getKey() == null) continue; // Oh yes, the JDK has 'null' HTTP headers

        DLNAHeader.Type type = DLNAHeader.Type.getByHttpName(entry.getKey());
        if (type == null) {
            log.log(Level.FINE, "Ignoring non-UPNP HTTP header: {0}", entry.getKey());
            continue;
        }

        for (String value : entry.getValue()) {
            UpnpHeader upnpHeader = DLNAHeader.newInstance(type, value);
            if (upnpHeader == null || upnpHeader.getValue() == null) {
                log.log(Level.FINE, "Ignoring known but non-parsable header (value violates the UDA specification?) '{0}': {1}", new Object[]{type.getHttpName(), value});
            } else {
                addParsedValue(type, upnpHeader);
            }
        }
    }
}
 
Example 11
Source File: IncomingSearchResponse.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public boolean isSearchResponseMessage() {
    UpnpHeader st = getHeaders().getFirstHeader(UpnpHeader.Type.ST);
    UpnpHeader usn = getHeaders().getFirstHeader(UpnpHeader.Type.USN);
    UpnpHeader ext = getHeaders().getFirstHeader(UpnpHeader.Type.EXT); // Has no value!
    return st != null && st.getValue() != null && usn != null && usn.getValue() != null && ext != null;
}
 
Example 12
Source File: IncomingSearchResponse.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public boolean isSearchResponseMessage() {
    UpnpHeader st = getHeaders().getFirstHeader(UpnpHeader.Type.ST);
    UpnpHeader usn = getHeaders().getFirstHeader(UpnpHeader.Type.USN);
    UpnpHeader ext = getHeaders().getFirstHeader(UpnpHeader.Type.EXT); // Has no value!
    return st != null && st.getValue() != null && usn != null && usn.getValue() != null && ext != null;
}