/**
  * Method to create a new CallerInfoAsyncQueryHandler object, ensuring correct state of context
  * and uri.
  */
 private void allocate(Context context, Uri contactRef) {
   if ((context == null) || (contactRef == null)) {
     throw new QueryPoolException("Bad context or query uri.");
   }
   mHandler = new CallerInfoAsyncQueryHandler(context);
   mHandler.mQueryContext = context;
   mHandler.mQueryUri = contactRef;
 }
  /** Method to add listeners to a currently running query */
  public void addQueryListener(int token, OnQueryCompleteListener listener, Object cookie) {

    if (DBG)
      log("adding listener to query: " + mHandler.mQueryUri + " handler: " + mHandler.toString());

    // create cookieWrapper, add query request to end of queue.
    CookieWrapper cw = new CookieWrapper();
    cw.listener = listener;
    cw.cookie = cookie;
    cw.event = EVENT_ADD_LISTENER;

    mHandler.startQuery(token, cw, null, null, null, null, null);
  }
 /** Releases the relevant data. */
 private void release() {
   mHandler.mQueryContext = null;
   mHandler.mQueryUri = null;
   mHandler.mCallerInfo = null;
   mHandler = null;
 }