/** * You can call this as the return statement of your overriding method once you have set the * result * * @return */ public final Object exec(Object in) { Object out = in; try { synchronized (this) { if (in == null) { in = value; } else { value = in; } if (status == Task.CANCELED || status == Task.EXCEPTION) { throw new IllegalStateException( this.getStatusString() + " state can not be executed: " + this); } else if (status != Task.EXEC_STARTED) { setStatus(Task.EXEC_STARTED); } } out = doInBackground(in); final boolean doRun; final Task t; synchronized (this) { value = out; doRun = status == EXEC_STARTED; if (doRun) { setStatus(EXEC_FINISHED); } t = chainedTask; } if (this instanceof UITask && doRun) { PlatformUtils.runOnUiThread((UITask) this); } if (t != null) { // #debug L.i("Begin exec chained task", chainedTask.toString() + " INPUT: " + out); t.exec(out); // #debug L.i("End exec chained task", chainedTask.toString()); } } catch (final Throwable t) { // #debug L.e("Unhandled task exception", this.toString(), t); setStatus(EXCEPTION); } return out; }
// @Test public void testToString() { System.out.println("toString"); final Task instance = new Task(Task.FASTLANE_PRIORITY, "start") { protected Object exec(Object in) { return in; } }; String result_1 = instance.toString(); assertTrue(result_1.length() > 5); }