public void add(URI uri,HttpCookie cookie){
  if (cookie == null) {
    throw new NullPointerException("cookie is null");
  }
  lock.lock();
  try {
    cookieJar.remove(cookie);
    if (cookie.getMaxAge() != 0) {
      cookieJar.add(cookie);
      if (cookie.getDomain() != null) {
        addIndex(domainIndex,cookie.getDomain(),cookie);
      }
      if (uri != null) {
        addIndex(uriIndex,getEffectiveURI(uri),cookie);
      }
    }
  }
  finally {
    lock.unlock();
  }
}

public void add ( URI uri , HttpCookie cookie ) { if ( cookie == null ) { throw new NullPointerException ( "cookie is null" ) ; } lock . lock ( ) ; try { cookieJar . remove ( cookie ) ; if ( cookie . getMaxAge ( ) != 0 ) { cookieJar . add ( cookie ) ; if ( cookie . getDomain ( ) != null ) { addIndex ( domainIndex , cookie . getDomain ( ) , cookie ) ; } if ( uri != null ) { addIndex ( uriIndex , getEffectiveURI ( uri ) , cookie ) ; } } } finally { lock . unlock ( ) ; } }
add one cookie into cookie store .
