Example usage for java.lang UnsupportedOperationException getMessage

List of usage examples for java.lang UnsupportedOperationException getMessage

Introduction

In this page you can find the example usage for java.lang UnsupportedOperationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Map map = new HashMap();
    map = Collections.unmodifiableMap(map);

    try {/*  w w  w  . j a v  a2 s.  c o  m*/
        map.put("key", "new value");
    } catch (UnsupportedOperationException e) {
        System.out.println(e.getMessage());
    }

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    List stuff = Arrays.asList(new String[] { "a", "b" });

    List list = new ArrayList(stuff);
    list = Collections.unmodifiableList(list);

    try {/*from   w  ww .j  a  v  a  2s.  c  o  m*/
        list.set(0, "new value");
    } catch (UnsupportedOperationException e) {
        System.out.println(e.getMessage());
    }

}

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.)/*  ww  w  .  java 2  s.  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);

    }
}

From source file:Main.java

/**
 * Unbind drawables./*from w ww. j  a  v a 2 s  .com*/
 *
 * @param view the view
 */
public static void unbindDrawables(View view) {
    if (view == null)
        return;
    if (view.getBackground() != null) {
        view.getBackground().setCallback(null);
    }
    if (view instanceof ViewGroup) {
        for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
            unbindDrawables(((ViewGroup) view).getChildAt(i));
        }
        try {
            ((ViewGroup) view).removeAllViews();
        } catch (UnsupportedOperationException mayHappen) {
            Log.e("Error:", mayHappen.getMessage());
        }
    }
}

From source file:org.springframework.ws.soap.saaj.support.SaajUtils.java

/**
 * Checks whether we can find a SAAJ 1.2 implementation, being aware of the broken WebLogic 9 SAAJ implementation.
 * <p/>//from w  ww . jav a 2 s.  co  m
 * WebLogic 9 does implement SAAJ 1.2, but throws UnsupportedOperationExceptions when a SAAJ 1.2 method is called.
 */
private static boolean isSaaj12(SOAPElement soapElement) {
    try {
        Method m = soapElement.getClass().getMethod("getPrefix", new Class[0]);
        // we might be using the SAAJ 1.2 API, while the impl is 1.1
        // let's see if the method is not abstract
        if (Modifier.isAbstract(m.getModifiers())) {
            logger.warn("Detected SAAJ API version 1.2, while implementation provides version 1.1. "
                    + "Please replace the SAAJ API jar with a version that corresponds to your runtime "
                    + "implementation (which might be provided by your app server).");
            return false;
        } else {
            soapElement.getPrefix();
            return true;
        }
    } catch (NoSuchMethodException e) {
        // getPrefix not found
        return false;
    } catch (UnsupportedOperationException ex) {
        // getPrefix results in UOE, let's see if we're dealing with WL 9
        if (WEBLOGIC_9_SAAJ_EXCEPTION_MESSAGE.equals(ex.getMessage())) {
            return false;
        } else {
            throw ex;
        }
    }
}

From source file:net.sbbi.upnp.impls.InternetGatewayDevice.java

private static InternetGatewayDevice[] lookupDeviceDevices(int timeout, int ttl, int mx,
        boolean WANIPConnection, boolean WANPPPConnection, NetworkInterface ni) throws IOException {
    UPNPRootDevice[] devices = null;// ww w .  j  av  a  2s .c o m
    InternetGatewayDevice[] rtrVal = null;
    if (timeout == -1) {
        devices = Discovery.discover(Discovery.DEFAULT_TIMEOUT, ttl, mx,
                "urn:schemas-upnp-org:device:InternetGatewayDevice:1", ni);
    } else {
        devices = Discovery.discover(timeout, ttl, mx, "urn:schemas-upnp-org:device:InternetGatewayDevice:1",
                ni);
    }

    if (devices != null) {
        Set valid = new HashSet();
        for (int i = 0; i < devices.length; i++) {
            try {
                valid.add(new InternetGatewayDevice(devices[i], WANIPConnection, WANPPPConnection));
            } catch (UnsupportedOperationException ex) {
                // the device is either not IP or PPP
                if (log.isDebugEnabled())
                    log.debug("UnsupportedOperationException during discovery " + ex.getMessage());
            }
        }
        if (valid.size() == 0) {
            return null;
        }
        rtrVal = new InternetGatewayDevice[valid.size()];
        int i = 0;
        for (Iterator itr = valid.iterator(); itr.hasNext();) {
            rtrVal[i++] = (InternetGatewayDevice) itr.next();
        }

    }
    return rtrVal;
}

From source file:com.pinanet.newsintegration.NewsFacadeREST.java

/**
 * Retrieves representation of an instance of
 * com.pinanet.newsintegration.News/*from w  w  w.  j a v  a  2  s  . co m*/
 *
 * @return an instance of java.lang.String
 */
@GET
@Path("stage")
@Produces("application/json")
public String getBZOStage() {
    JSONObject jsonObject = new JSONObject();
    String jsonString = "{\n" + "    \"glossary\": {\n" + "        \"title\": \"example glossary\",\n"
            + "      \"GlossDiv\": {\n" + "            \"title\": \"S\",\n" + "         \"GlossList\": {\n"
            + "                \"GlossEntry\": {\n" + "                    \"ID\": \"SGML\",\n"
            + "               \"SortAs\": \"SGML\",\n"
            + "               \"GlossTerm\": \"Standard Generalized Markup Language\",\n"
            + "               \"Acronym\": \"SGML\",\n" + "               \"Abbrev\": \"ISO 8879:1986\",\n"
            + "               \"GlossDef\": {\n"
            + "                        \"para\": \"A meta-markup language, used to create markup languages such as DocBook.\",\n"
            + "                  \"GlossSeeAlso\": [\"GML\", \"XML\"]\n" + "                    },\n"
            + "               \"GlossSee\": \"markup\"\n" + "                }\n" + "            }\n"
            + "        }\n" + "    }\n" + "}";
    try {
        jsonObject = new JSONObject(jsonString);
    } catch (UnsupportedOperationException e) {
        return e.getMessage();
    } catch (JSONException ex) {
        Logger.getLogger(NewsFacadeREST.class.getName()).log(Level.SEVERE, null, ex);
    }
    return jsonObject.toString();
}

From source file:org.osiam.resources.exception.OsiamExceptionHandler.java

@ExceptionHandler(UnsupportedOperationException.class)
@ResponseStatus(HttpStatus.NOT_IMPLEMENTED)
@ResponseBody/*  w w w. jav  a 2 s.  co  m*/
public ErrorResponse handleUnsupportedOperation(UnsupportedOperationException e) {
    return produceErrorResponse(e.getMessage(), HttpStatus.NOT_IMPLEMENTED);
}

From source file:org.elasticsearch.client.RestClientTests.java

public void testPerformAsyncWithUnsupportedMethod() throws Exception {
    RestClient.SyncResponseListener listener = new RestClient.SyncResponseListener(10000);
    try (RestClient restClient = createRestClient()) {
        restClient.performRequestAsync("unsupported", randomAsciiOfLength(5), listener);
        listener.get();// www  .  j  a v a2 s  .co m

        fail("should have failed because of unsupported method");
    } catch (UnsupportedOperationException exception) {
        assertEquals("http method not supported: unsupported", exception.getMessage());
    }
}

From source file:org.wikipedia.vlsergey.secretary.utils.AbstractDocumentBuilderPool.java

@Override
public void passivateObject(DocumentBuilder obj) {
    try {/*from   w ww. j  a v  a 2  s.c  om*/
        (obj).setErrorHandler(defaultErrorHandler);
        (obj).reset();
    } catch (UnsupportedOperationException exc) {
        log.warn(exc.getMessage(), exc);
    }
}