Java Code Examples for java.util.concurrent.ConcurrentHashMap.Entry

The following are Jave code examples for showing how to use Entry of the java.util.concurrent.ConcurrentHashMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: EasyHttp   File: RxEasyHttpManager.java   View Source Code Vote up 7 votes
/**
 * Post请求的Rxjava方式.
 * @param url
 * @param requestParams
 * @return
 */
public <T> Flowable<T> post(String url, EasyRequestParams requestParams, RxEasyConverter<T> rxEasyConverter) {
	FormBody.Builder builder = new FormBody.Builder();
	ConcurrentHashMap<String, String> paramsMap = requestParams.getRequestParams();
	for (ConcurrentHashMap.Entry<String, String> entry : paramsMap.entrySet()) {
		builder.add(entry.getKey(), entry.getValue());
	}

	RequestBody requestBody = builder.build();
	final Request request = new Request.Builder()
			.url(url)
			.post(requestBody)
			.build();

	Call call = EasyHttpClientManager.getInstance().getOkHttpClient(EasyCacheType.CACHE_TYPE_DEFAULT).newCall(request);

	return Flowable.create(new CallFlowableOnSubscribe(call,rxEasyConverter), BackpressureStrategy.BUFFER)
			.subscribeOn(Schedulers.io());
}
 
Example 2
Project: AOSP-Kayboard-7.1.2   File: PersonalizationHelper.java   View Source Code Vote up 7 votes
public static void removeAllUserHistoryDictionaries(final Context context) {
    synchronized (sLangUserHistoryDictCache) {
        for (final ConcurrentHashMap.Entry<String, SoftReference<UserHistoryDictionary>> entry
                : sLangUserHistoryDictCache.entrySet()) {
            if (entry.getValue() != null) {
                final UserHistoryDictionary dict = entry.getValue().get();
                if (dict != null) {
                    dict.clear();
                }
            }
        }
        sLangUserHistoryDictCache.clear();
        final File filesDir = context.getFilesDir();
        if (filesDir == null) {
            Log.e(TAG, "context.getFilesDir() returned null.");
            return;
        }
        final boolean filesDeleted = FileUtils.deleteFilteredFiles(
                filesDir, new DictFilter(UserHistoryDictionary.NAME));
        if (!filesDeleted) {
            Log.e(TAG, "Cannot remove dictionary files. filesDir: " + filesDir.getAbsolutePath()
                    + ", dictNamePrefix: " + UserHistoryDictionary.NAME);
        }
    }
}
 
Example 3
Project: GitHub   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
@Override
public boolean clearExpired(Date date) {
    boolean clearedAny = false;
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();

    for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) {
        String name = entry.getKey();
        Cookie cookie = entry.getValue();
        if (cookie.isExpired(date)) {
            // Clear cookies from local store
            cookies.remove(name);

            // Clear cookies from persistent store
            prefsWriter.remove(COOKIE_NAME_PREFIX + name);

            // We've cleared at least one
            clearedAny = true;
        }
    }

    // Update names in persistent store
    if (clearedAny) {
        prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    }
    prefsWriter.commit();

    return clearedAny;
}
 
Example 4
Project: GitHub   File: RequestParams.java   View Source Code Vote up 6 votes
protected List<BasicNameValuePair> getParamsList() {
    List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>();

    for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
        lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }

    lparams.addAll(getParamsList(null, urlParamsWithObjects));

    return lparams;
}
 
Example 5
Project: GitHub   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
@Override
public boolean clearExpired(Date date) {
    boolean clearedAny = false;
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();

    for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) {
        String name = entry.getKey();
        Cookie cookie = entry.getValue();
        if (cookie.isExpired(date)) {
            // Clear cookies from local store
            cookies.remove(name);

            // Clear cookies from persistent store
            prefsWriter.remove(COOKIE_NAME_PREFIX + name);

            // We've cleared at least one
            clearedAny = true;
        }
    }

    // Update names in persistent store
    if (clearedAny) {
        prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    }
    prefsWriter.commit();

    return clearedAny;
}
 
Example 6
Project: GitHub   File: RequestParams.java   View Source Code Vote up 6 votes
protected List<BasicNameValuePair> getParamsList() {
    List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>();

    for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
        lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }

    lparams.addAll(getParamsList(null, urlParamsWithObjects));

    return lparams;
}
 
Example 7
Project: AndroidAsyncHTTP   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
@Override
public boolean clearExpired(Date date) {
    boolean clearedAny = false;
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();

    for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) {
        String name = entry.getKey();
        Cookie cookie = entry.getValue();
        if (cookie.isExpired(date)) {
            // Clear cookies from local store
            cookies.remove(name);

            // Clear cookies from persistent store
            prefsWriter.remove(COOKIE_NAME_PREFIX + name);

            // We've cleared at least one
            clearedAny = true;
        }
    }

    // Update names in persistent store
    if (clearedAny) {
        // This prevents map.keySet to compile to a Java 8+ KeySetView return type
        Map<String, Cookie> map = cookies;
        prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", map.keySet()));
    }
    prefsWriter.apply();

    return clearedAny;
}
 
Example 8
Project: Hotspot-master-devp   File: RequestParams.java   View Source Code Vote up 6 votes
/**
 * Returns an HttpEntity containing all request parameters
 */
public HttpEntity getEntity() {

    if (bodyEntity != null) {
        return bodyEntity;
    }

    HttpEntity result = null;

    if (fileParams != null && !fileParams.isEmpty()) {

        MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.STRICT, null, Charset.forName(charset));

        if (bodyParams != null && !bodyParams.isEmpty()) {
            for (NameValuePair param : bodyParams.values()) {
                try {
                    multipartEntity.addPart(param.getName(), new StringBody(param.getValue()));
                } catch (UnsupportedEncodingException e) {
                    LogUtils.e(e.getMessage(), e);
                }
            }
        }

        for (ConcurrentHashMap.Entry<String, ContentBody> entry : fileParams.entrySet()) {
            multipartEntity.addPart(entry.getKey(), entry.getValue());
        }

        result = multipartEntity;
    } else if (bodyParams != null && !bodyParams.isEmpty()) {
        result = new BodyParamsEntity(new ArrayList<NameValuePair>(bodyParams.values()), charset);
    }

    return result;
}
 
Example 9
Project: fiery   File: APIStatisticDayPage.java   View Source Code Vote up 6 votes
@RequestMapping(value = "/apistatisticday", method = RequestMethod.GET)
public String currentlog(Model model,
                         @RequestParam(value = "topdatarange", required = false, defaultValue = "0") String topdaterange,
                         @RequestParam(value = "url", required = false, defaultValue = "") String url
) {

    //date list
    List<String> timelist = DateTimeHelper.getDateTimeListForPage(fieryConfig.getKeepdataday());
    model.addAttribute("datelist", timelist);
    model.addAttribute("datelist_selected", topdaterange);

    model.addAttribute("url", url);

    //now the date render
    long shardtime = DateTimeHelper.getTimesMorning(DateTimeHelper.getBeforeDay(Integer.parseInt(topdaterange)));

    TreeMap<Long, APIStatisticStruct> urlList = apiStatisticTimeSet.getHourDetail(url, shardtime);

    //log.info("size:" + urlList.size());

    model.addAttribute("urllist", urlList);

    //http code
    TreeMap<String, Long> httpCodeMap = new TreeMap<>();
    for (Map.Entry<Long, APIStatisticStruct> timeItem : urlList.entrySet()) {
        for (ConcurrentHashMap.Entry<String, AtomicLong> httpitem : timeItem.getValue().getCode_count().entrySet()) {
            if (!httpCodeMap.containsKey(httpitem.getKey())) {
                httpCodeMap.put(httpitem.getKey(), httpitem.getValue().longValue());
            } else {
                httpCodeMap.put(httpitem.getKey(), httpCodeMap.get(httpitem.getKey()) + httpitem.getValue().longValue());
            }
        }

    }

    model.addAttribute("httpcode", httpCodeMap);

    return "apistatisticday";
}
 
Example 10
Project: jsf-sdk   File: ExtensionLoader.java   View Source Code Vote up 6 votes
/**
 * 得到服务端的全部自动激活扩展
 *
 * @return 自动激活扩展列表
 */
public List<ExtensibleClass> getProviderSideAutoActives() {
    List<ExtensibleClass> extensibleClasses = new ArrayList<ExtensibleClass>();
    for (ConcurrentHashMap.Entry<String, ExtensibleClass> entry : all.entrySet()) {
        ExtensibleClass extensibleClass = entry.getValue();
        if (extensibleClass.isAutoActive() && extensibleClass.isProviderSide()) {
            extensibleClasses.add(extensibleClass);
        }
    }
    Collections.sort(extensibleClasses, new OrderComparator());
    return extensibleClasses;
}
 
Example 11
Project: jsf-sdk   File: ExtensionLoader.java   View Source Code Vote up 6 votes
/**
 * 得到调用端的全部自动激活扩展
 *
 * @return 自动激活扩展列表
 */
public List<ExtensibleClass> getConsumerSideAutoActives() {
    List<ExtensibleClass> extensibleClasses = new ArrayList<ExtensibleClass>();
    for (ConcurrentHashMap.Entry<String, ExtensibleClass> entry : all.entrySet()) {
        ExtensibleClass extensibleClass = entry.getValue();
        if (extensibleClass.isAutoActive() && extensibleClass.isConsumerSide()) {
            extensibleClasses.add(extensibleClass);
        }
    }
    Collections.sort(extensibleClasses, new OrderComparator());
    return extensibleClasses;
}
 
Example 12
Project: EasyHttp   File: EasyRequestParams.java   View Source Code Vote up 6 votes
@Override
public String toString() {
    StringBuilder result = new StringBuilder();
    for (ConcurrentHashMap.Entry<String, String> entry : mRequestParams.entrySet()) {
        if (result.length() > 0)
            result.append("&");

        result.append(entry.getKey());
        result.append("=");
        result.append(entry.getValue());
    }
    return result.toString();
}
 
Example 13
Project: EasyHttp   File: EasyHeaderInterceptor.java   View Source Code Vote up 6 votes
@Override
public Response intercept(Chain chain) throws IOException {
    final Request originalRequest = chain.request();

    Request.Builder builder = originalRequest.newBuilder();

    if (mHeaders != null) {
        for (ConcurrentHashMap.Entry<String, String> entry : mHeaders.entrySet()) {
            builder.addHeader(entry.getKey(), entry.getValue());
        }
    }

    return chain.proceed(builder.build());
}
 
Example 14
Project: sealtalk-android-master   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
@Override
public boolean clearExpired(Date date) {
    boolean clearedAny = false;
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();

    for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) {
        String name = entry.getKey();
        Cookie cookie = entry.getValue();
        if (cookie.isExpired(date)) {
            // Clear cookies from local store
            cookies.remove(name);

            // Clear cookies from persistent store
            prefsWriter.remove(COOKIE_NAME_PREFIX + name);

            // We've cleared at least one
            clearedAny = true;
        }
    }

    // Update names in persistent store
    if (clearedAny) {
        prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    }
    prefsWriter.apply();

    return clearedAny;
}
 
Example 15
Project: android-project-gallery   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
@Override
public boolean clearExpired(Date date) {
    boolean clearedAny = false;
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();

    for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) {
        String name = entry.getKey();
        Cookie cookie = entry.getValue();
        if (cookie.isExpired(date)) {
            // Clear cookies from local store
            cookies.remove(name);

            // Clear cookies from persistent store
            prefsWriter.remove(COOKIE_NAME_PREFIX + name);

            // We've cleared at least one
            clearedAny = true;
        }
    }

    // Update names in persistent store
    if (clearedAny) {
        prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    }
    prefsWriter.commit();

    return clearedAny;
}
 
Example 16
Project: android-project-gallery   File: RequestParams.java   View Source Code Vote up 6 votes
protected List<BasicNameValuePair> getParamsList() {
    List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>();

    for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
        lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }

    lparams.addAll(getParamsList(null, urlParamsWithObjects));

    return lparams;
}
 
Example 17
Project: rongyunDemo   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
@Override
public boolean clearExpired(Date date) {
    boolean clearedAny = false;
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();

    for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) {
        String name = entry.getKey();
        Cookie cookie = entry.getValue();
        if (cookie.isExpired(date)) {
            // Clear cookies from local store
            cookies.remove(name);

            // Clear cookies from persistent store
            prefsWriter.remove(COOKIE_NAME_PREFIX + name);

            // We've cleared at least one
            clearedAny = true;
        }
    }

    // Update names in persistent store
    if (clearedAny) {
        prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    }
    prefsWriter.apply();

    return clearedAny;
}
 
Example 18
Project: Mobike   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
@Override
public boolean clearExpired(Date date) {
    boolean clearedAny = false;
    SharedPreferences.Editor prefsWriter = cookiePrefs.edit();

    for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) {
        String name = entry.getKey();
        Cookie cookie = entry.getValue();
        if (cookie.isExpired(date)) {
            // Clear cookies from local store
            cookies.remove(name);

            // Clear cookies from persistent store
            prefsWriter.remove(COOKIE_NAME_PREFIX + name);

            // We've cleared at least one
            clearedAny = true;
        }
    }

    // Update names in persistent store
    if (clearedAny) {
        prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet()));
    }
    prefsWriter.commit();

    return clearedAny;
}
 
Example 19
Project: Mobike   File: RequestParams.java   View Source Code Vote up 6 votes
protected List<BasicNameValuePair> getParamsList() {
    List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>();

    for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
        lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }

    lparams.addAll(getParamsList(null, urlParamsWithObjects));

    return lparams;
}