Changeset 7030 in josm for trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java
- Timestamp:
- 2014-04-29T18:06:29+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java
r7005 r7030 383 383 384 384 public static String getHandlerInfoAsJSON(String cmd) { 385 StringWriter w = new StringWriter(); 386 PrintWriter r = new PrintWriter(w); 387 RequestHandler handler = null; 388 try { 389 Class<?> c = handlers.get(cmd); 390 if (c==null) return null; 391 handler = handlers.get(cmd).newInstance(); 392 } catch (Exception ex) { 393 Main.error(ex); 385 try (StringWriter w = new StringWriter()) { 386 PrintWriter r = new PrintWriter(w); 387 RequestHandler handler = null; 388 try { 389 Class<?> c = handlers.get(cmd); 390 if (c==null) return null; 391 handler = handlers.get(cmd).newInstance(); 392 } catch (InstantiationException | IllegalAccessException ex) { 393 Main.error(ex); 394 return null; 395 } 396 397 printJsonInfo(cmd, r, handler); 398 return w.toString(); 399 } catch (IOException e) { 400 Main.error(e); 394 401 return null; 395 402 } 396 403 } 404 405 private static void printJsonInfo(String cmd, PrintWriter r, RequestHandler handler) { 397 406 r.printf("{ \"request\" : \"%s\"", cmd); 398 407 if (handler.getUsage() != null) { … … 438 447 } 439 448 r.append("]}"); 440 try {441 return w.toString();442 } finally {443 try {444 w.close();445 } catch (IOException ex) {446 Main.warn(ex);447 }448 }449 449 } 450 450
Note:
See TracChangeset
for help on using the changeset viewer.
