@Override public Object read(Object serviceImpl) throws Exception { return Reflections.get(field, serviceImpl); }
public ProtocolInfo(MimeType contentFormatMimeType) { this.protocol = Protocol.HTTP_GET; this.contentFormat = contentFormatMimeType.toString(); }
public MimeType getContentFormatMimeType() throws IllegalArgumentException { return MimeType.valueOf(contentFormat); }
protected boolean isUsableImageType(MimeType mt) { return mt.getType().equals("image") && (mt.getSubtype().equals("png") || mt.getSubtype().equals("jpg") || mt.getSubtype().equals("jpeg") || mt.getSubtype().equals("gif")); }
@Override protected void onConnectionFailed(Throwable t) { log.log(Level.WARNING, "HTTP connection failed: " + requestMessage, Exceptions.unwrap(t)); }
public boolean isUDACompliantXML() { // UDA spec says "must be text/xml", however, sometimes you get a charset token as well... return isText() && getValue().getSubtype().equals(DEFAULT_CONTENT_TYPE.getSubtype()); }
@Override public Object read(Object serviceImpl) throws Exception { return Reflections.invoke(getGetter(), serviceImpl); }
public URL normalizeURI(URI relativeOrAbsoluteURI) { // TODO: I have one device (Netgear 834DG DSL Router) that sends a <URLBase>, and even that is wrong (port)! // This can be fixed by "re-enabling" UPnP in the upnpService after a reboot, it will then use the right port... // return URIUtil.createAbsoluteURL(getDescriptorURL(), relativeOrAbsoluteURI); if (getDetails() != null && getDetails().getBaseURL() != null) { // If we have an <URLBase>, all URIs are relative to it return URIUtil.createAbsoluteURL(getDetails().getBaseURL(), relativeOrAbsoluteURI); } else { // Otherwise, they are relative to the descriptor location return URIUtil.createAbsoluteURL(getIdentity().getDescriptorURL(), relativeOrAbsoluteURI); } }
/** * Use this constructor if your local icon data can be resolved on the classpath, for * example: <code>MyClass.class.getResource("/my/icon.png)</code> * * @param url A URL of the icon data that can be read with <code>new File(url.toURI())</code>. */ public Icon(String mimeType, int width, int height, int depth, URL url) throws IOException{ this(mimeType, width, height, depth, new File(URIUtil.toURI(url))); }
public static void main(final String[] args) throws Exception { if (OS.checkForMac()) PlatformApple.setup(APP, APPNAME); SwingUtilities.invokeLater(new Runnable() { public void run() { APP.getView().setVisible(true); APP.onViewReady(args); } }); }
@Override protected void onException(Throwable t) { log.log(Level.WARNING, "HTTP request failed: " + requestMessage, Exceptions.unwrap(t)); }
/** * Used internally by Cling when {@link RemoteDevice} is discovered, you shouldn't have to call this. */ public Icon(String mimeType, int width, int height, int depth, URI uri) { this(mimeType != null && mimeType.length() > 0 ? MimeType.valueOf(mimeType) : null, width, height, depth, uri, null); }
public String getString() { return getValue().toString(); }
/** * Handles errors when network has been switched, during reception of * network switch broadcast. Logs a warning by default, override to * change this behavior. */ protected void handleRouterExceptionOnNetworkTypeChange(RouterException ex) { Throwable cause = Exceptions.unwrap(ex); if (cause instanceof InterruptedException) { log.log(Level.INFO, "Router was interrupted: " + ex, cause); } else { log.log(Level.WARNING, "Router error on network change: " + ex, ex); } }
/** * Use this constructor if your local icon data is in a <code>byte[]</code>. * * @param uniqueName Must be a valid URI path segment and unique within the scope of a device. */ public Icon(String mimeType, int width, int height, int depth, String uniqueName, byte[] data) { this(mimeType != null && mimeType.length() > 0 ? MimeType.valueOf(mimeType) : null, width, height, depth, URI.create(uniqueName), data); }
@Override public void handleStartFailure(InitializationException ex) throws InitializationException { if (ex instanceof NoNetworkException) { log.info("Unable to initialize network router, no network found."); } else { log.severe("Unable to initialize network router: " + ex); log.severe("Cause: " + Exceptions.unwrap(ex)); } }
public void setString(String s) throws InvalidHeaderException { setValue(MimeType.valueOf(s)); }
@Override protected URI valueOf(String s) throws InvalidValueException { try { // These URIs are really defined as 'string' datatype in AVTransport1.0.pdf, but we can try // to parse whatever devices give us, like the Roku which sends "unknown url". return super.valueOf(s); } catch (InvalidValueException ex) { log.info("Ignoring invalid URI in evented value '" + s +"': " + Exceptions.unwrap(ex)); return null; } }
protected void shutdownRouter() { try { getRouter().shutdown(); } catch (RouterException ex) { Throwable cause = Exceptions.unwrap(ex); if (cause instanceof InterruptedException) { log.log(Level.INFO, "Router shutdown was interrupted: " + ex, cause); } else { log.log(Level.SEVERE, "Router error on shutdown: " + ex, cause); } } }