1 /* 2 * Copyright (C) 2008 Esmertec AG. 3 * Copyright (C) 2008 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.mms.util; 19 20 import android.util.Log; 21 22 import java.util.HashMap; 23 24 public class SendingProgressTokenManager { 25 private static final String TAG = "SendingProgressTokenManager"; 26 private static final boolean DEBUG = false; 27 private static final boolean LOCAL_LOGV = false; 28 private static final HashMap<Object, Long> TOKEN_POOL; 29 30 public static final long NO_TOKEN = -1L; 31 32 static { 33 TOKEN_POOL = new HashMap<Object, Long>(); 34 } 35 get(Object key)36 synchronized public static long get(Object key) { 37 Long token = TOKEN_POOL.get(key); 38 if (LOCAL_LOGV) { 39 Log.v(TAG, "TokenManager.get(" + key + ") -> " + token); 40 } 41 return token != null ? token : NO_TOKEN; 42 } 43 put(Object key, long token)44 synchronized public static void put(Object key, long token) { 45 if (LOCAL_LOGV) { 46 Log.v(TAG, "TokenManager.put(" + key + ", " + token + ")"); 47 } 48 TOKEN_POOL.put(key, token); 49 } 50 remove(Object key)51 synchronized public static void remove(Object key) { 52 if (LOCAL_LOGV) { 53 Log.v(TAG, "TokenManager.remove(" + key + ")"); 54 } 55 TOKEN_POOL.remove(key); 56 } 57 } 58