Map 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 Map put method.

This code example shows how to use the following methods:get, incrementAndGet, set
        AtomicLong serialId = getSerialId(pid);
 
        // Asign a serialid to the source if we don't already have one 
        String sourceid = source.get(TRANSIENT_PROPERTY_SERIAL_ID);
        if (sourceid == null) {
            sourceid = new Long(serialId.incrementAndGet()).toString();
            source.put(TRANSIENT_PROPERTY_SERIAL_ID, sourceid);
        } 
 
        // Ignore the serialid on rollback 
        if (rollback) {
            LOGGER.debugf("Config rollback: %s => %s", pid, source);
            serialId.set(Long.parseLong(sourceid));
            configurations.put(pid, source);
            return true; 
        } 
 
        // Update if there is no previous config for this pid 
        Dictionary<String, String> previous = configurations.get(pid);
        if (previous == null) {

10
CodeRank
This code example shows how to use the following methods:put
    public abstract Map<String, String[]> parse(InputStream is);    
    public static Map<String, DataParser> parsers = new HashMap<String, DataParser>();    
 
    // These are our injected Parser. Maybe we later want to allow dynamic injection 
    static { 
        parsers.put("application/x-www-form-urlencoded", new UrlEncodedParser());
        parsers.put("multipart/form-data", new ApacheMultipartParser());
        parsers.put("multipart/mixed", new ApacheMultipartParser());
        parsers.put("application/xml", new TextParser());
        parsers.put("application/json", new TextParser());
    } 
 
    public static void putMapEntry(Map<String, String[]> map, String name, String value) {
        String[] newValues = null;
        String[] oldValues = map.get(name);
        if (oldValues == null) {
            newValues = new String[1];
            newValues[0] = value;
        } else { 
            newValues = new String[oldValues.length + 1];
9
CodeRank
This code example shows how to use the following methods:delete, exists, lastModified
	} 
 
	@Override 
	public File get(String key) {
		File file = super.get(key);
		if (file.exists()) {
			boolean cached;
			Long loadingDate = loadingDates.get(file);
			if (loadingDate == null) {
				cached = false;
				loadingDate = file.lastModified();
			} else { 
				cached = true;
			} 
 
			if (System.currentTimeMillis() - loadingDate > maxFileAge) {
				file.delete();
				loadingDates.remove(file);
			} else if (!cached) {
				loadingDates.put(file, loadingDate);

9
CodeRank
This code example shows how to use the following methods:put
        result.putExtra("com.jakewharton.android.viewpagerindicator.sample.Path", path);
        return result;
    } 
 
    protected void addItem(List<Map<String, Object>> data, String name, Intent intent) {
        Map<String, Object> temp = new HashMap<String, Object>();
        temp.put("title", name);
        temp.put("intent", intent);
        data.add(temp);
    } 
 
    @Override 
    @SuppressWarnings("unchecked") 
    protected void onListItemClick(ListView l, View v, int position, long id) {
        Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);
 
        Intent intent = (Intent) map.get("intent");
        startActivity(intent);
    } 
} 
9
CodeRank
This code example shows how to use the following methods:put
    } 
 
    private void deployParticipant() { 
        undeployServlet(); 
 
        final Map<String, String> initialParameters = new HashMap<String, String>();
        initialParameters.put("javax.ws.rs.Application", "org.wildfly.extension.rts.jaxrs.VolatileParticipantApplication");
 
        final DeploymentInfo participantDeploymentInfo = getDeploymentInfo(DEPLOYMENT_NAME, CONTEXT_PATH, initialParameters);
 
        deployServlet(participantDeploymentInfo);
    } 
 
} 
9
CodeRank
This code example shows how to use the following methods:getHeight, getRowBytes
		super(sizeLimit);
	} 
 
	@Override 
	public boolean put(String key, Bitmap value) {
		if (super.put(key, value)) {
			valueSizes.put(value, getSize(value));
			return true; 
		} else { 
			return false; 
		} 
	} 
 
	@Override 
	public void remove(String key) {
		Bitmap value = super.get(key);
		if (value != null) {
			valueSizes.remove(value);
		} 
		super.remove(key);

9
CodeRank
This code example shows how to use the following methods:put
    @SuppressWarnings("unchecked") 
    public B param(String name, Object value) {
        if (this.params == null) {
            this.params = Maps.newHashMap();
        } 
        this.params.put(name, value);
        return (B) this;
    } 
 
    @Override 
    protected void internalXContent(XContentBuilder builder, Params params) throws IOException {
        if (field != null) {
            builder.field("field", field);
        } 
 
        if (script != null) {
            builder.field("script", script);
        } 
 
        if (lang != null) {
9
CodeRank
This code example shows how to use the following methods:put
        String groovySrc = "hello world: ${name}";
 
        GroovyTemplate t = new GroovyTemplate("Template_123", groovySrc);
        new GroovyTemplateCompiler().compile(t);
 
        Map<String, Object> args = new HashMap<String,Object>();
        args.put("name", "Morten");
        assertThat( t.render( args ) ).isEqualTo("hello world: Morten");
 
        //do it again 
        assertThat( t.render( args ) ).isEqualTo("hello world: Morten");
 
    } 
 
    @Test 
    public void verifyCompilingExtremelyLongLines() { 
        StringBuilder longString = new StringBuilder();
        for (int i=0;i<1000;i++) {
            longString.append("11111111112222222222333333333344444444445555555555");
            longString.append("11111111112222222222333333333344444444445555555555");
9
CodeRank
This code example shows how to use the following methods:get, put
    @Override 
    public void addHeader(String name, String value) {
        if (customHeaders == null) {
            customHeaders = new HashMap<String, List<String>>(2);
        } 
        List<String> header = customHeaders.get(name);
        if (header == null) {
            header = new ArrayList<String>();
            customHeaders.put(name, header);
        } 
        header.add(value);
    } 
 
    @Override 
    public Map<String, List<String>> getHeaders() {
        return customHeaders;
    } 
} 
9
CodeRank
This code example shows how to use the following methods:add
		return (values != null ? values.get(0) : null);
	} 
 
	@Override 
	public void set(K key, V value) {
		List<V> values = new LinkedList<V>();
		values.add(value);
		this.targetMap.put(key, values);
	} 
 
	@Override 
	public void setAll(Map<K, V> values) {
		for (Entry<K, V> entry : values.entrySet()) {
			set(entry.getKey(), entry.getValue());
		} 
	} 
 
	@Override 
	public Map<K, V> toSingleValueMap() {
		LinkedHashMap<K, V> singleValueMap = new LinkedHashMap<K,V>(this.targetMap.size());
9
CodeRank

Related Map put Questions & Answers:

Other Map put Examples

36:	    {
37:	    	stub_id = loader;
38:	        imageViews.put(imageView, url);
39:	        Bitmap bitmap=memoryCache.get(url);
40:	        if(bitmap!=null)

Read More

34:	        String serverUrl = SERVER_URL;
35:	        Map<String, String> params = new HashMap<String, String>();
36:	        params.put("regId", regId);
37:	        params.put("name", name);
38:	        params.put("email", email);
-
35:	        Map<String, String> params = new HashMap<String, String>();
36:	        params.put("regId", regId);
37:	        params.put("name", name);
38:	        params.put("email", email);
39:	        
-
36:	        params.put("regId", regId);
37:	        params.put("name", name);
38:	        params.put("email", email);
39:	        
40:	        long backoff = BACKOFF_MILLI_SECONDS + random.nextInt(1000);
-
43:	        // times.
44:	        for (int i = 1; i <= MAX_ATTEMPTS; i++) {
45:	            Log.d(TAG, "Attempt #" + i + " to register");
46:	            try {
47:	                displayMessage(context, context.getString(

Read More

28:				protected Map<String, String> getParams() {
29:					Map<String, String> params = new HashMap<String, String>();
30:					params.put("name", "Androidhive");
31:					params.put("email", "abc@androidhive.info");
32:					params.put("password", "password123");
-
29:					Map<String, String> params = new HashMap<String, String>();
30:					params.put("name", "Androidhive");
31:					params.put("email", "abc@androidhive.info");
32:					params.put("password", "password123");
33:	
-
30:					params.put("name", "Androidhive");
31:					params.put("email", "abc@androidhive.info");
32:					params.put("password", "password123");
33:	
34:					return params;

Read More

put Method Overview
Associates the specified value with the specified key in this map (optional operation).
See Code Examples for other Java 8 Map Methods: