List of usage examples for java.lang UnsupportedOperationException getCause
public synchronized Throwable getCause()
From source file:org.jenkinsci.plugins.workflow.structs.DescribableHelper.java
private static Object uncoerce(Object o, Type type) { if (type instanceof Class && ((Class) type).isEnum() && o instanceof Enum) { return ((Enum) o).name(); } else if (type == URL.class && o instanceof URL) { return ((URL) o).toString(); } else if ((type == Character.class || type == char.class) && o instanceof Character) { return ((Character) o).toString(); } else if (o instanceof Object[]) { List<Object> list = new ArrayList<Object>(); Object[] array = (Object[]) o; for (Object elt : array) { list.add(uncoerce(elt, array.getClass().getComponentType())); }/*w ww. j a v a 2 s . c o m*/ return list; } else if (o instanceof List && acceptsList(type)) { List<Object> list = new ArrayList<Object>(); for (Object elt : (List<?>) o) { list.add(uncoerce(elt, ((ParameterizedType) type).getActualTypeArguments()[0])); } return list; } else if (o != null && !o.getClass().getName().startsWith("java.")) { try { // Check to see if this can be treated as a data-bound struct. Map<String, Object> nested = uninstantiate(o); if (type != o.getClass()) { nested.put(CLAZZ, o.getClass().getSimpleName()); } return nested; } catch (UnsupportedOperationException x) { // then leave it raw if (!(x.getCause() instanceof NoStaplerConstructorException)) { LOG.log(Level.WARNING, "failed to uncoerce " + o, x); } } } return o; }
From source file:ste.cameracontrol.ui.CameraControlCLI.java
/** * Parameters are a command and any option parameters * such as <em><b>--camera</b> port-id</em> * specifying the the port id for a camera. * (See <em>usb.core.PortIdentifier</em> for information * about those identifiers.)/* w ww.j a va 2s . c om*/ * Such port ids may be omitted when there is only one * camera currently connected; list them * using the <em>cameras</em> commands. * PTP devices may support only some of these commands. * * <table border=1 cellpadding=3 cellspacing=0 width="80%"> * <tr bgcolor="#ccccff" class="TableHeadingColor"> * <th>Command and Arguments</th> * <th>Description</th> * <th>Options</th> * </tr> * * <tr valign=top> * <td> <code>cameras</code> </td> * <td> (same as "devices") </td> * <td> <em>none</em> </td> * </tr> * * <tr valign=top> * <td> <code>capture</code> </td> * <td> starts capturing images or other objects, according * to the current device properties. </td> * <td> <em>--port-id</em> id <br /> * <em>--storage</em> id * </td> * </tr> * * <tr valign=top> * <td> <code>devices</code> </td> * <td> Lists PTP devices with their port identifiers </td> * <td> <em>none</em> </td> * </tr> * * <tr valign=top> * <td> <code>devinfo</code> </td> * <td> Displays the DeviceInfo for a camera, including * all the operations, events, device properties, * and object formats supported. </td> * <td> <em>--port-id</em> id </td> * </tr> * * <tr valign=top> * <td> <code>devprops</code> </td> * <td> shows all device properties, with types and values. </td> * <td> <em>--port-id</em> id </td> * </tr> * * <tr valign=top> * <td> <code>format</code> </td> * <td> Reformats the specified storage unit (zero based). </td> * <td> <em>--port-id</em> id * <br> <em>--storage</em> number * </td> * </tr> * * <tr valign=top> * <td> <code>getprop</code> <em>propname</em></td> * <td> shows named device property, with type and value. </td> * <td> <em>--port-id</em> id </td> * </tr> * * <tr valign=top> * <td> <code>help</code> </td> * <td> shows command summary</td> * <td> <em>none</em> </td> * </tr> * * <tr valign=top> * <td> <code>images</code> </td> * <td> Downloads image files to directory </td> * <td> <em>--port-id</em> id * <br> <em>--overwrite</em> * <br> <em>--directory</em> directory (default "images") </td> * </tr> * * <tr valign=top> * <td> <code>powerdown</code> </td> * <td> Causes the device to power down. </td> * <td> <em>--port-id</em> id </td> * </tr> * * <tr valign=top> * <td> <code>put</code> <em>file-or-URL [...]</em> </td> * <td> Copies images or other objects to device. </td> * <td> <em>--port-id</em> id <br /> * <em>--storage</em> id * </tr> * * <tr valign=top> * <td> <code>reset</code> </td> * <td> Issues a PTP level reset. </td> * <td> <em>--port-id</em> id </td> * </tr> * * <tr valign=top> * <td> <code>selftest</code> </td> * <td> Runs a basic device self test. </td> * <td> <em>--port-id</em> id </td> * </tr> * * <tr valign=top> * <td> <code>status</code> </td> * <td> Shows status summary for the device </td> * <td> <em>--port-id</em> id </td> * </tr> * * <tr valign=top> * <td> <code>storage</code> </td> * <td> Displays the StorageInfo for the device's * storage units, all or just the specified (zero base) store </td> * <td> <em>--port-id</em> id * <br> <em>--storage</em> number * </td> * </tr> * * <tr valign=top> * <td> <code>thumbs</code> </td> * <td> Downloads image thumbnails to directory </td> * <td> <em>--port-id</em> id * <br> <em>--overwrite</em> * <br> <em>--directory</em> directory (default "thumbs") </td> * </tr> * * <tr valign=top> * <td> <code>tree</code> </td> * <td> Lists contents of camera storage. </td> * <td> <em>--port-id</em> id </td> * </tr> * * </table> */ public static void main(String[] args) throws Exception { if (args.length == 0) { usage(-1); } Options options = new Options(); options.addOption( OptionBuilder.withLongOpt("camera").withArgName("c").hasArg().withArgName("value").create()); options.addOption("d", "directory", true, ""); options.addOption("h", "help", false, ""); options.addOption("w", "overwrite", false, ""); options.addOption("s", "storage", true, ""); CommandLineParser parser = new PosixParser(); CommandLine line = parser.parse(options, args); try { if (line.hasOption('c')) { device = line.getOptionValue('c'); } if (line.hasOption('d')) { directory = new File(line.getOptionValue('d')); } else { directory = new File("images"); } if (line.hasOption('h')) { usage(0); System.exit(0); } if (line.hasOption('s')) { storageId = Integer.parseInt(line.getOptionValue('s')); if (storageId < 0) { System.err.println("--storage N ... " + "parameter must be an integer"); usage(-1); } } if (line.hasOption('w')) { overwrite = true; } if (!directory.exists()) { directory.mkdirs(); } Configuration c = new Configuration(); c.setImageDir(directory.getAbsolutePath()); controller = CameraController.getInstance(); controller.initialize(c); controller.startCamera(); for (String arg : line.getArgs()) { /* if ("cameras".equals (argv [c]) || "devices".equals (argv [c])) cameras (argv, c); else */ if ("get-events".equals(arg)) { getEvents(); } else if ("shoot".equals(arg)) { shoot(); } else if ("devinfo".equals(arg)) { devinfo(); } /*else if ("devprops".equals (argv [c])) devprops (argv, c); else if ("format".equals (argv [c])) format (argv, c); else if ("getprop".equals (argv [c])) getprop (argv, c); */ else if ("help".equals(arg)) { usage(0); } /* else if ("images".equals (argv [c])) images (argv, c); else if ("put".equals (argv [c])) put (argv, c); else if ("powerdown".equals (argv [c])) powerdown (argv, c); else if ("reset".equals (argv [c])) reset (argv, c); else if ("selftest".equals (argv [c])) selftest (argv, c); else if ("status".equals (argv [c])) status (argv, c); else if ("storage".equals (argv [c])) storage (argv, c); else if ("thumbs".equals (argv [c])) thumbs (argv, c); else if ("tree".equals (argv [c])) tree (argv, c); */ else { usage(-1); } } } catch (UnsupportedOperationException e) { System.err.println("Device does not support " + e.getMessage()); System.exit(1); } catch (PTPException e) { // // Let's intercept for now when a device is busy // Throwable cause = e.getCause(); if (cause instanceof USBBusyException) { System.err.println( "The camera is busy. Please make sure not any other program is using and locking the device."); } else { System.err.println(e.getMessage()); } System.exit(1); } catch (SecurityException e) { System.err.println(e.getMessage()); System.exit(1); } }