ConcurrentHashMap put - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ConcurrentHashMap put method.

This code example shows how to use the following methods:put
     * @param key the key name for the new param. 
     * @param value the value string for the new param. 
     */ 
    public void put(String key, String value){
        if(key != null && value != null) {
            urlParams.put(key, value);
        } 
    } 
 
    /** 
     * Adds a file to the request. 
     * @param key the key name for the new param. 
     * @param file the file to add. 
     */ 
    public void put(String key, File file) throws FileNotFoundException {
        put(key, new FileInputStream(file), file.getName());
    } 
 
    /** 
     * Adds param with more than one value. 

8
CodeRank
This code example shows how to use the following methods:containsKey, get, put
    private static ConcurrentHashMap<String, Object> services = new ConcurrentHashMap<String, Object>();
 
    @SuppressWarnings("unchecked") 
    public T get(final Class<T> cls){
        String key = cls.getName();
        if (services.containsKey(key)) {
            return (T) services.get(key);
 
        } else { 
            T service = createClient(cls, targetIP, targetPort, connectTimeout,clientNums);
            services.put(key, service);
            return (T) services.get(key);
        } 
    } 
 
    protected T createClient(Class<T> cls, String targetIP, int targetPort, int connectTimeout,int clientNums){
        ReferenceConfig<T> referenceConfig = new ReferenceConfig<T>();
        referenceConfig.setInterface(cls);
        StringBuilder url = new StringBuilder();
        url.append("dubbo://");
7
CodeRank
This code example shows how to use the following methods:get, put, remove
     * @param key 
     *            the key to check 
     * @return <code>true</code> if the node is marked as available. 
     */ 
    public boolean isNodeAvailable( @Nonnull final K key ) {
        final ManagedItem<Boolean> item = _map.get( key );
        if ( item == null ) {
            return updateIsNodeAvailable( key );
        } else if ( isExpired( item ) ) {
            _map.remove( key );
            return updateIsNodeAvailable( key );
        } else { 
            return item._value;
        } 
    } 
 
    private boolean isExpired( final ManagedItem<Boolean> item ) {
        return _ttl > -1 && System.currentTimeMillis() - item._insertionTime > _ttl;
    } 
 

7
CodeRank
This code example shows how to use the following methods:put
    public final Map<String, String> getConfigProperties() {
        return Collections.unmodifiableMap(configProperties);
    } 
 
    public String addConfigProperty(String key, String value) {
        return configProperties.put(key, value);
    } 
 
    /** 
     * Get the className. 
     * 
     * @return the className. 
     */ 
    @Override 
    public final String getClassName() {
        return className;
    } 
 
    /** 
     * Get the jndiName. 
7
CodeRank
This code example shows how to use the following methods:containsKey, get, put
                ProcessJobContext processCtx = (ProcessJobContext) ctx;
                jobname = processCtx.getSessionId() + "-" + processCtx.getProcessInstanceId() + "-" + processCtx.getTimer().getId();
                if (processCtx instanceof StartProcessJobContext) {
                    jobname = "StartProcess-"+((StartProcessJobContext) processCtx).getProcessId()+ "-" + processCtx.getTimer().getId();
                } 
                if (activeTimer.containsKey(jobname)) {
                    return activeTimer.get(jobname);
                } 
             
            } 
            GlobalJDKJobHandle jobHandle = new GlobalJDKJobHandle( idCounter.getAndIncrement() );
             
            TimerJobInstance jobInstance = ((AcceptsTimerJobFactoryManager) globalTimerService).
                                 getTimerJobFactoryManager().createTimerJobInstance( job,
                                                                                     ctx,
                                                                                     trigger,
                                                                                     jobHandle,
                                                                                     (InternalSchedulerService) globalTimerService );
            jobHandle.setTimerJobInstance( (TimerJobInstance) jobInstance );
            interceptor.internalSchedule( (TimerJobInstance) jobInstance );

6
CodeRank
This code example shows how to use the following methods:put
 
 
    private void commitOffset(final String key, final int queueId, final long offset) {
        ConcurrentHashMap<Integer, Long> map = this.offsetTable.get(key);
        if (null == map) {
            map = new ConcurrentHashMap<Integer, Long>(32);
            map.put(queueId, offset);
            this.offsetTable.put(key, map);
        } 
        else { 
            map.put(queueId, offset);
        } 
    } 
 
 
    public String encode() {
        return this.encode(false);
    } 
 
 
6
CodeRank
This code example shows how to use the following methods:get, put
        if (key == null) {
            if (internKeys) {
 
                key = name.toString();
 
                String keyPrime = internedKeysCache.get(key);
                if (keyPrime == null) {
                    key = key.intern();
                    internedKeysCache.put(key, key);
                } else { 
                    key = keyPrime;
                } 
            } else { 
 
                key = name.toString();
            } 
        } 
        return key;
    } 
 
6
CodeRank
This code example shows how to use the following methods:put
	public boolean propertyExists(String name) throws JMSException {
		return this.properties.containsKey(name);
	} 
 
	public void setBooleanProperty(String name, boolean value) throws JMSException {
		this.properties.put(name, value);
	} 
 
	public void setByteProperty(String name, byte value) throws JMSException {
		this.properties.put(name, value);
	} 
 
	public void setDoubleProperty(String name, double value) throws JMSException {
		this.properties.put(name, value);
	} 
 
	public void setFloatProperty(String name, float value) throws JMSException {
		this.properties.put(name, value);
	} 
 
6
CodeRank
This code example shows how to use the following methods:get, put
      ObjectInspector mapKeyObjectInspector,
      ObjectInspector mapValueObjectInspector) {
    ArrayList<Object> signature = new ArrayList<Object>();
    signature.add(mapKeyObjectInspector);
    signature.add(mapValueObjectInspector);
    LazyBinaryMapObjectInspector result = cachedLazyBinaryMapObjectInspector
        .get(signature); 
    if (result == null) {
      result = new LazyBinaryMapObjectInspector(mapKeyObjectInspector,
          mapValueObjectInspector);
      cachedLazyBinaryMapObjectInspector.put(signature, result);
    } 
    return result;
  } 
 
  private LazyBinaryObjectInspectorFactory() { 
    // prevent instantiation 
  } 
} 
6
CodeRank
This code example shows how to use the following methods:get, put
	/** 
	 * Create a new {@code Message.Builder} instance for the given class. 
	 * <p>This method uses a ConcurrentHashMap for caching method lookups. 
	 */ 
	private Message.Builder getMessageBuilder(Class<? extends Message> clazz) throws Exception { 
		Method method = methodCache.get(clazz); 
		if (method == null) { 
			method = clazz.getMethod("newBuilder"); 
			methodCache.put(clazz, method); 
		} 
		return (Message.Builder) method.invoke(clazz); 
	} 
 
	/** 
	 * This method overrides the parent implementation, since this HttpMessageConverter 
	 * can also produce {@code MediaType.HTML "text/html"} ContentType. 
	 */ 
	@Override 
	protected boolean canWrite(MediaType mediaType) { 
		return super.canWrite(mediaType) || MediaType.TEXT_HTML.isCompatibleWith(mediaType); 
7
CodeRank
put Method Overview
Maps the specified key to the specified value in this table.
See Code Examples for other Java 8 ConcurrentHashMap Methods: