Java Code Examples for org.fourthline.cling.model.message.header.UpnpHeader#Type

The following examples show how to use org.fourthline.cling.model.message.header.UpnpHeader#Type . 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: 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 2
Source File: UpnpHeaders.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public <H extends UpnpHeader> H getFirstHeader(UpnpHeader.Type type, Class<H> subtype) {
    UpnpHeader[] headers = getAsArray(type);
    if (headers.length == 0) return null;

    for (UpnpHeader header : headers) {
        if (subtype.isAssignableFrom(header.getClass())) {
            return (H) header;
        }
    }
    return null;
}
 
Example 3
Source File: UpnpHeaders.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public <H extends UpnpHeader> H getFirstHeader(UpnpHeader.Type type, Class<H> subtype) {
    UpnpHeader[] headers = getAsArray(type);
    if (headers.length == 0) return null;

    for (UpnpHeader header : headers) {
        if (subtype.isAssignableFrom(header.getClass())) {
            return (H) header;
        }
    }
    return null;
}
 
Example 4
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 5
Source File: UpnpHeaders.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public String getFirstHeaderString(UpnpHeader.Type type) {
    UpnpHeader header = getFirstHeader(type);
    return header != null ? header.getString() : null;
}
 
Example 6
Source File: ReceivingAsync.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected <H extends UpnpHeader> H getFirstHeader(UpnpHeader.Type headerType, Class<H> subtype) {
    return getInputMessage().getHeaders().getFirstHeader(headerType, subtype);
}
 
Example 7
Source File: UpnpHeaders.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public UpnpHeader getFirstHeader(UpnpHeader.Type type) {
    return getAsArray(type).length > 0
            ? getAsArray(type)[0]
            : null;
}
 
Example 8
Source File: UpnpHeaders.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public UpnpHeader[] getAsArray(UpnpHeader.Type type) {
    if (parsedHeaders == null) parseHeaders();
    return parsedHeaders.get(type) != null
            ? parsedHeaders.get(type).toArray(new UpnpHeader[parsedHeaders.get(type).size()])
            : new UpnpHeader[0];
}
 
Example 9
Source File: UpnpHeaders.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public void remove(UpnpHeader.Type type) {
    super.remove(type.getHttpName());
    if (parsedHeaders != null)
        parsedHeaders.remove(type);
}
 
Example 10
Source File: UpnpHeaders.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public void add(UpnpHeader.Type type, UpnpHeader value) {
    super.add(type.getHttpName(), value.getString());
    if (parsedHeaders != null)
        addParsedValue(type, value);
}
 
Example 11
Source File: UpnpHeaders.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public List<UpnpHeader> get(UpnpHeader.Type type) {
    if (parsedHeaders == null) parseHeaders();
    return parsedHeaders.get(type);
}
 
Example 12
Source File: UpnpHeaders.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public boolean containsKey(UpnpHeader.Type type) {
    if (parsedHeaders == null) parseHeaders();
    return parsedHeaders.containsKey(type);
}
 
Example 13
Source File: ReceivingAsync.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected <H extends UpnpHeader> H getFirstHeader(UpnpHeader.Type headerType, Class<H> subtype) {
    return getInputMessage().getHeaders().getFirstHeader(headerType, subtype);
}
 
Example 14
Source File: UpnpHeaders.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public String getFirstHeaderString(UpnpHeader.Type type) {
    UpnpHeader header = getFirstHeader(type);
    return header != null ? header.getString() : null;
}
 
Example 15
Source File: UpnpHeaders.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public UpnpHeader getFirstHeader(UpnpHeader.Type type) {
    return getAsArray(type).length > 0
            ? getAsArray(type)[0]
            : null;
}
 
Example 16
Source File: UpnpHeaders.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public UpnpHeader[] getAsArray(UpnpHeader.Type type) {
    if (parsedHeaders == null) parseHeaders();
    return parsedHeaders.get(type) != null
            ? parsedHeaders.get(type).toArray(new UpnpHeader[parsedHeaders.get(type).size()])
            : new UpnpHeader[0];
}
 
Example 17
Source File: UpnpHeaders.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public void remove(UpnpHeader.Type type) {
    super.remove(type.getHttpName());
    if (parsedHeaders != null)
        parsedHeaders.remove(type);
}
 
Example 18
Source File: UpnpHeaders.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public void add(UpnpHeader.Type type, UpnpHeader value) {
    super.add(type.getHttpName(), value.getString());
    if (parsedHeaders != null)
        addParsedValue(type, value);
}
 
Example 19
Source File: UpnpHeaders.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public List<UpnpHeader> get(UpnpHeader.Type type) {
    if (parsedHeaders == null) parseHeaders();
    return parsedHeaders.get(type);
}
 
Example 20
Source File: UpnpHeaders.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public boolean containsKey(UpnpHeader.Type type) {
    if (parsedHeaders == null) parseHeaders();
    return parsedHeaders.containsKey(type);
}