/**
  * Get a CacheToken for a row as specified by its id (_id column)
  *
  * @param id the id of the record
  * @return a CacheToken needed in order to write data for the record back to the cache
  */
 public synchronized CacheToken getCacheToken(String id) {
   // If another thread is already writing the data, return an invalid token
   CacheToken token = mTokenList.add(id);
   if (mLockMap.contains(id)) {
     token.invalidate();
   }
   return token;
 }
 /*package*/ void invalidate() {
   if (MailActivityEmail.DEBUG && DEBUG_TOKENS) {
     LogUtils.d(mLogTag, "============ List invalidated");
   }
   for (CacheToken token : this) {
     token.invalidate();
   }
   clear();
 }
 public synchronized Cursor putCursorImpl(
     Cursor c, String id, String[] projection, CacheToken token) {
   try {
     if (!token.isValid()) {
       if (MailActivityEmail.DEBUG && DEBUG_CACHE) {
         LogUtils.d(mLogTag, "============ Stale token for " + id);
       }
       mStats.mStaleCount++;
       return c;
     }
     if (c != null && Arrays.equals(projection, mBaseProjection) && !sLockCache) {
       if (MailActivityEmail.DEBUG && DEBUG_CACHE) {
         LogUtils.d(mLogTag, "============ Caching cursor for: " + id);
       }
       // If we've already cached this cursor, invalidate the older one
       Cursor existingCursor = get(id);
       if (existingCursor != null) {
         unlockImpl(id, null, false);
       }
       mLruCache.put(id, c);
       return new CachedCursor(c, this, id);
     }
     return c;
   } finally {
     mTokenList.remove(token);
   }
 }
 /*package*/ int invalidateTokens(String id) {
   if (MailActivityEmail.DEBUG && DEBUG_TOKENS) {
     LogUtils.d(mLogTag, "============ Invalidate tokens for: " + id);
   }
   ArrayList<CacheToken> removeList = new ArrayList<CacheToken>();
   int count = 0;
   for (CacheToken token : this) {
     if (token.getId().equals(id)) {
       token.invalidate();
       removeList.add(token);
       count++;
     }
   }
   for (CacheToken token : removeList) {
     remove(token);
   }
   return count;
 }