@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof NamedDeviceType)) return false; NamedDeviceType that = (NamedDeviceType) o; if (!deviceType.equals(that.deviceType)) return false; if (!udn.equals(that.udn)) return false; return true; }
@Override public String toString() { return "urn:" + getNamespace() + ":device:" + getType()+ ":" + getVersion(); }
public String getString() { return getValue().toString(); } }
public String getDisplayString() { return getType(); }
public DeviceType createDeviceType() { return DeviceType.valueOf(deviceType); }
@Override public int hashCode() { int result = udn.hashCode(); result = 31 * result + deviceType.hashCode(); return result; } }
protected Collection<D> find(DeviceType deviceType, D current) { Collection<D> devices = new HashSet<>(); // Type might be null if we just discovered the device and it hasn't yet been hydrated if (current.getType() != null && current.getType().implementsVersion(deviceType)) { devices.add(current); } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(find(deviceType, embeddedDevice)); } } return devices; }
return new DeviceType(matcher.group(1), matcher.group(2), Integer.valueOf(matcher.group(3))); if (matcher.matches() && matcher.groupCount() >= 2) { log.warning("UPnP specification violation, no device type token, defaulting to " + UNKNOWN + ": " + s); return new DeviceType(matcher.group(1), UNKNOWN, Integer.valueOf(matcher.group(2))); + cleanToken ); return new DeviceType(matcher.group(1), cleanToken, Integer.valueOf(matcher.group(3)));
public String getDisplayString() { return getType(); }
public void setString(String s) throws InvalidHeaderException { try { setValue(DeviceType.valueOf(s)); } catch (RuntimeException ex) { throw new InvalidHeaderException("Invalid device type header value, " + ex.getMessage()); } }
@Override public int hashCode() { int result = udn.hashCode(); result = 31 * result + deviceType.hashCode(); return result; } }
protected Collection<D> find(DeviceType deviceType, D current) { Collection<D> devices = new HashSet(); // Type might be null if we just discovered the device and it hasn't yet been hydrated if (current.getType() != null && current.getType().implementsVersion(deviceType)) { devices.add(current); } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(find(deviceType, embeddedDevice)); } } return devices; }
return new DeviceType(matcher.group(1), matcher.group(2), Integer.valueOf(matcher.group(3))); if (matcher.matches() && matcher.groupCount() >= 2) { log.warning("UPnP specification violation, no device type token, defaulting to " + UNKNOWN + ": " + s); return new DeviceType(matcher.group(1), UNKNOWN, Integer.valueOf(matcher.group(2))); + cleanToken ); return new DeviceType(matcher.group(1), cleanToken, Integer.valueOf(matcher.group(3)));
@Override public String toString() { return "urn:" + getNamespace() + ":device:" + getType()+ ":" + getVersion(); }
protected Service discoverConnectionService(Device device) { if (!device.getType().equals(IGD_DEVICE_TYPE)) { return null; } Device[] connectionDevices = device.findDevices(CONNECTION_DEVICE_TYPE); if (connectionDevices.length == 0) { log.fine("IGD doesn't support '" + CONNECTION_DEVICE_TYPE + "': " + device); return null; } Device connectionDevice = connectionDevices[0]; log.fine("Using first discovered WAN connection device: " + connectionDevice); Service ipConnectionService = connectionDevice.findService(IP_SERVICE_TYPE); Service pppConnectionService = connectionDevice.findService(PPP_SERVICE_TYPE); if (ipConnectionService == null && pppConnectionService == null) { log.fine("IGD doesn't support IP or PPP WAN connection service: " + device); } return ipConnectionService != null ? ipConnectionService : pppConnectionService; }
@Override public String toString() { return getUdn().toString() + "::" + getDeviceType().toString(); }
public static boolean isMediaServerDevice(Device device) { if ("urn:schemas-upnp-org:device:MediaServer:1" .equalsIgnoreCase(device.getType().getType())) { return true; } return false; }
public static NamedDeviceType valueOf(String s) throws InvalidValueException { String[] strings = s.split("::"); if (strings.length != 2) { throw new InvalidValueException("Can't parse UDN::DeviceType from: " + s); } UDN udn; try { udn = UDN.valueOf(strings[0]); } catch (Exception ex) { throw new InvalidValueException("Can't parse UDN: " + strings[0]); } DeviceType deviceType = DeviceType.valueOf(strings[1]); return new NamedDeviceType(udn, deviceType); }
@Override public int hashCode() { int result = udn.hashCode(); result = 31 * result + deviceType.hashCode(); return result; } }
protected Collection<D> find(DeviceType deviceType, D current) { Collection<D> devices = new HashSet<>(); // Type might be null if we just discovered the device and it hasn't yet been hydrated if (current.getType() != null && current.getType().implementsVersion(deviceType)) { devices.add(current); } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(find(deviceType, embeddedDevice)); } } return devices; }