Android Open Source - sloop-sql Async Result






From Project

Back to project page sloop-sql.

License

The source code is released under:

SloopSQL is released into the Public Domain. There are no restrictions on how you may use this code, and there is no warranty or guarantee of fitness for anything. USE AT YOUR OWN RISK (and enjoy).

If you think the Android project sloop-sql listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.megginson.sloopsql;
/*from ww w . j  av  a2s.co  m*/
/**
 * Class to hold result of an AsyncTask
 *
 * If an {@link AsyncTask} throws an exception or error, there needs to be a way
 * to propagate that information to the main thread.  This class creates a strongly-
 * typed generic object to hold au unexpected {@link Throwable} or the expected result type.
 */
public class AsyncResult<T>
{

  private T mResult;

  private Throwable mThrowable;

  /**
   * Constructor for the expected result.
   */
  public AsyncResult(T result)
  {
    mResult = result;
  }

  /**
   * Constructor for an unexpected throwable.
   */
  public AsyncResult(Throwable throwable)
  {
    mThrowable = throwable;
  }
  
  /**
   * Get the expected result.
   *
   * @return A result of the expected type, or null if not available.
   */
  public T getResult()
  {
    return mResult;
  }

  /**
   * Return the unexpected throwable.
   *
   * @return A {@link Throwable} representing an error.
   */
  public Throwable getThrowable()
  {
    return mThrowable;
  }

  /**
   * Test if there's an error.
   *
   * @return true if {#getThrowable()} returns non-null.
   */
  public boolean isError()
  {
    return (getThrowable() != null);
  }

}




Java Source Code List

com.megginson.sloopsql.AsyncResult.java
com.megginson.sloopsql.CSVCursorSerializer.java
com.megginson.sloopsql.DatabaseHandler.java
com.megginson.sloopsql.MainActivity.java
com.megginson.sloopsql.QueryFragment.java
com.megginson.sloopsql.QueryResultAdapter.java
com.megginson.sloopsql.ScriptFragment.java
com.megginson.sloopsql.TabListener.java
com.megginson.sloopsql.TableListAdapter.java
com.megginson.sloopsql.TableListFragment.java
com.megginson.sloopsql.Util.java