當前位置: 首頁>>代碼示例>>Java>>正文


Java Map.put方法代碼示例

本文整理匯總了Java中java.util.Map.put方法的典型用法代碼示例。如果您正苦於以下問題:Java Map.put方法的具體用法?Java Map.put怎麽用?Java Map.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Map的用法示例。


在下文中一共展示了Map.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMessageQueueAllocationResult

import java.util.Map; //導入方法依賴的package包/類
private Map<MessageQueue, String> getMessageQueueAllocationResult(DefaultMQAdminExt defaultMQAdminExt,
    String groupName) {
    Map<MessageQueue, String> results = new HashMap<>();
    try {
        ConsumerConnection consumerConnection = defaultMQAdminExt.examineConsumerConnectionInfo(groupName);
        for (Connection connection : consumerConnection.getConnectionSet()) {
            String clientId = connection.getClientId();
            ConsumerRunningInfo consumerRunningInfo = defaultMQAdminExt.getConsumerRunningInfo(groupName, clientId,
                false);
            for (MessageQueue messageQueue : consumerRunningInfo.getMqTable().keySet()) {
                results.put(messageQueue, clientId.split("@")[0]);
            }
        }
    } catch (Exception ignore) {
    }
    return results;
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:18,代碼來源:ConsumerProgressSubCommand.java

示例2: onLocationChanged

import java.util.Map; //導入方法依賴的package包/類
@Override
public void onLocationChanged(Location location) {
    FirebaseAuth auth = FirebaseAuth.getInstance();
    String uid = auth.getCurrentUser().getUid();
    DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("users");
    ref.child(uid).child("location").setValue(new Loc(location.getLatitude(), location.getLongitude()));

    SharedPreferences prefs = context.getSharedPreferences("USER_DATA", 0);
    String group_id = prefs.getString("GROUP_ID", "");

    GeoHash geoHash = new GeoHash(location.getLatitude(), location.getLongitude());
    Map<String, Object> updates = new HashMap<String, Object>();
    updates.put("g", geoHash.getGeoHashString());
    updates.put("l", Arrays.asList(location.getLatitude(), location.getLongitude()));

    FirebaseDatabase.getInstance().getReference()
            .child("group_locations")
            .child(group_id)
            .child(uid)
            .setValue(updates);
    EventBus.getDefault().post(location);
}
 
開發者ID:mremondi,項目名稱:Hyke,代碼行數:23,代碼來源:HykeLocationManager.java

示例3: serve

import java.util.Map; //導入方法依賴的package包/類
/**
 * Override this to customize the server.
 * <p/>
 * <p/>
 * (By default, this delegates to serveFile() and allows directory listing.)
 *
 * @param session The HTTP session
 * @return HTTP response, see class Response for details
 */
public Response serve(IHTTPSession session) {
    Map<String, String> files = new HashMap<String, String>();
    Method method = session.getMethod();
    if (Method.PUT.equals(method) || Method.POST.equals(method)) {
        try {
            session.parseBody(files);
        } catch (IOException ioe) {
            return new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage());
        } catch (ResponseException re) {
            return new Response(re.getStatus(), MIME_PLAINTEXT, re.getMessage());
        }
    }

    Map<String, String> parms = session.getParms();
    parms.put(QUERY_STRING_PARAMETER, session.getQueryParameterString());
    return serve(session.getUri(), method, session.getHeaders(), parms, files);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:27,代碼來源:NanoHTTPD.java

示例4: addSubject

import java.util.Map; //導入方法依賴的package包/類
/**
 * 添加學科
 * @param subject 學科
 * @return 返回成功失敗
 * result :
 * 	success
 * 	data.code : -1參數不合法,學科已存在(與已存在的學科同名);-3添加失敗;
 */
@ResponseBody
@RequestMapping("/create")
public CommonResult<Map<String, Object>> addSubject(Subject subject){
	CommonResult<Map<String, Object>> result = new CommonResult<Map<String, Object>>(true);
	Map<String, Object> map = new HashMap<String, Object>();
	int code = 0;
	code = subjectService.insert(subject);
	code = 0 < code ? 0 : code;
	if(0 != code ){
		System.out.println("========================================");
		System.out.println("code : " + code);
		System.out.println("=======================================");
		map.put("code", code);
		result.setSuccess(false);
	}
	result.setData(map);
	return result;
}
 
開發者ID:Topview-us,項目名稱:school-website,代碼行數:27,代碼來源:SubjectController.java

示例5: createEventWithoutDates

import java.util.Map; //導入方法依賴的package包/類
private SystemEvent createEventWithoutDates() {
    SystemEvent event = new SystemEvent();
    Map<String, Object> data = new HashMap<>();
    event.setData(data);
    data.put(Constants.ID, DEFAULT_ID);
    data.put(Constants.NAME, DEFAULT_FIRST_NAME + " " + DEFAULT_LAST_NAME);
    data.put(Constants.IMAGE_URL, DEFAULT_IMAGE_URL);
    data.put(Constants.CREATED_DATE, "");
    data.put(Constants.LAST_MODIFIED_DATE, "");
    data.put(Constants.USER_KEY, DEFAULT_USER_KEY);

    TenantInfo info  = new TenantInfo(null, DEFAULT_USER_LOGIN, null, null, null, null, null);
    event.setTenantInfo(info);

    return event;

}
 
開發者ID:xm-online,項目名稱:xm-uaa,代碼行數:18,代碼來源:SystemEventMapperUnitTest.java

示例6: processAllReplicasRegistration

import java.util.Map; //導入方法依賴的package包/類
public void processAllReplicasRegistration(UUID[] ids, ReplicaConfig[] configs, UUID mainClusterId) {
    LOGGER.info("[G] Registering replica for clusters {} in {}", ids, f(clusterId));
    Map<UUID, ReplicaMetadata> map = new HashMap<>(ids.length);
    for (int i = 0; i < ids.length; i++) {
        map.put(ids[i], new ReplicaMetadata(configs[i], false));
    }
    replicasMetadatas.set(map);
    main.set(mainClusterId);
    ignite.compute().broadcast(new PublisherUpdater());
}
 
開發者ID:epam,項目名稱:Lagerta,代碼行數:11,代碼來源:Commander.java

示例7: toMap

import java.util.Map; //導入方法依賴的package包/類
private static Map<String, String> toMap(List<KeyValue> params) {
  Map<String, String> map = new HashMap<>();
  for (KeyValue keyValue : params) {
    if (!map.containsKey(keyValue.key())) {
      map.put(keyValue.key(), keyValue.value());
    }
  }
  return Collections.unmodifiableMap(map);
}
 
開發者ID:EricEdens,項目名稱:urllib,代碼行數:10,代碼來源:Queries.java

示例8: listLocal

import java.util.Map; //導入方法依賴的package包/類
protected Map<String, LocalResource> listLocal() throws CalendarStorageException {
    // fetch list of local contacts and build hash table to index file name
    LocalResource[] localList = localCollection.getAll();
    Map<String, LocalResource> localResources = new HashMap<>(localList.length);
    for (LocalResource resource : localList) {
        localResources.put(resource.getFileName(), resource);
    }

    return localResources;
}
 
開發者ID:6thsolution,項目名稱:EasyAppleSyncAdapter,代碼行數:11,代碼來源:SyncManager.java

示例9: testContainsValue

import java.util.Map; //導入方法依賴的package包/類
@Test
public void testContainsValue() {
    Map<SimpleKey, SimpleValue> map = redisson.getMap("simple");
    map.put(new SimpleKey("1"), new SimpleValue("2"));
    map.put(new SimpleKey("33"), new SimpleValue("44"));
    map.put(new SimpleKey("5"), new SimpleValue("6"));

    Assert.assertTrue(map.containsValue(new SimpleValue("2")));
    Assert.assertFalse(map.containsValue(new SimpleValue("441")));
    Assert.assertFalse(map.containsValue(new SimpleKey("5")));
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:12,代碼來源:RedissonMapTest.java

示例10: testReadArgumentsFromPropertyFile

import java.util.Map; //導入方法依賴的package包/類
@Test
public void testReadArgumentsFromPropertyFile() throws IOException {
    final Map<String, String> result = new HashMap<String, String>();
    OperatorClient.readArgumentsFromPropertyFile(result, TEST_PROPERTIES);

    final Map<String, String> expected = new HashMap<String, String>();
    expected.put("key1", "aaa");
    expected.put("key2", "bbb");
    expected.put("key3", "ccc");
    assertEquals(expected, result);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:12,代碼來源:OperatorClientTest.java

示例11: headers

import java.util.Map; //導入方法依賴的package包/類
private static Map<String, String> headers(String httpResponse) {
    Map<String, String> hs = new HashMap<>();
    boolean firstLine = true;
    for (String line: httpResponse.split("\\\r\\\n")) {
        if (line.equals("")) { break; }
        if (firstLine) {
            firstLine = false;
            continue;
        }
        String[] parts = line.split(": *", 2);
        hs.put(parts[0].toLowerCase(), parts[1]);
    }
    return hs;
}
 
開發者ID:fnproject,項目名稱:fdk-java,代碼行數:15,代碼來源:HttpEventCodecTest.java

示例12: TerminalNode

import java.util.Map; //導入方法依賴的package包/類
public TerminalNode(Rdf source, int model) {
	super(source, model);
	Map<String,TerminalNode> terminalNodes = modelTerminalNodes.get(model);
	if (terminalNodes == null) {
		terminalNodes = new HashMap<String,TerminalNode>();
		modelTerminalNodes.put(model, terminalNodes);
	}
	terminalNodes.put(source.getId(), this);
	log.debug("Created TerminalNode");
}
 
開發者ID:OmniPrise,項目名稱:cim-processor,代碼行數:11,代碼來源:TerminalNode.java

示例13: ComplexTypePropertyDocHandler

import java.util.Map; //導入方法依賴的package包/類
/**
 * .
 */
@SuppressWarnings("unchecked")
@Test
public void 階層2にComplex型のProperty追加後_製限値を超えた場合異常を通知すること() {
    String testENTITY = "testEntity";
    org.odata4j.edm.EdmEntityType.Builder entityType = EntityTypeを作成(testENTITY);

    List<EdmComplexType.Builder> cpBuilderList = new ArrayList<EdmComplexType.Builder>();

    EdmComplexType.Builder ctBuilder = EntityTypeにcomplex型Propertyを1つ作成("newComplexType", entityType);
    EdmDataServices.Builder builder = EdmDataServices.newBuilder();
    cpBuilderList.add(ctBuilder);

    // ここが2階層目となる
    ComplexTypeにsimple型Propertyを指定數作成(50, ctBuilder);
    Builder targetComplexTypeBuilder = ComplexTypeにcomplex型Propertyを指定數作成(5, "newComplexType2", ctBuilder);
    cpBuilderList.add(targetComplexTypeBuilder);

    EdmSchema.Builder schema = EdmSchema.newBuilder().addEntityTypes(entityType).setNamespace(NS)
            .addComplexTypes(cpBuilderList);
    EdmDataServices metadata = builder.addSchemas(schema).build();

    PropertyDocHandler handler = new ComplexTypePropertyDocHandler();
    JSONObject staticFields = new JSONObject();
    staticFields.put("Type", "newComplexType2");
    handler.setStaticFields(staticFields);

    Map<String, String> entityTypeMap = new HashMap<String, String>();
    entityTypeMap.put("_ComplexType.Name_uniqueKey", "newComplexType");
    handler.setEntityTypeMap(entityTypeMap);
    handler.setEntityTypeId("_uniqueKey");
    Map<String, Object> manyToOneKindMap = new HashMap<String, Object>();
    manyToOneKindMap.put(ComplexType.EDM_TYPE_NAME, "_uniqueKey");
    handler.setManyToOnelinkId(manyToOneKindMap);

    PropertyLimitChecker checker = new PropertyLimitChecker(metadata, handler);
    List<CheckError> errors = checker.checkPropertyLimits();
    assertEquals(1, errors.size());
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:42,代碼來源:PropertyLimitCheckerTest.java

示例14: appInfo

import java.util.Map; //導入方法依賴的package包/類
@Override
public Map<String, Object> appInfo(Map<String, Object> params){
	String authId=params.get("auth_id")==null?"":params.get("auth_id").toString().trim();
	Map<String, Object> rs = new HashMap<String, Object>();
	try {
		Map<String, Object> result = new HashMap<String, Object>();

		AuthKey key = authKeyDao.query(authId);
		if(key==null){
			rs.put("flag", "false");
			rs.put("error", "[413.1]AuthId Not Found");
			return rs;
		}

		App app =authKeyDao.queryAppByAuthId(authId);
		if(null==app){
			rs.put("flag","false");
			rs.put("error","[413.2]App Not Found");
		}else{
			result.put("app",app.getInstruct());
			result.put("app_name",app.getAppName());
			result.put("app_ver",app.getVersion());
			result.put("last_update_time",app.getUpdateTime()==null?"":app.getUpdateTime().substring(0,app.getUpdateTime().length()-2));

			rs.put("flag","true");
			rs.put("error","");
			rs.put("result",result);
		}
	} catch (Exception e) {
		String error = ExceptionUtil.getStackTraceAsString(e);
		LOG.error("getAuthKey error : "+error);
		rs.put("flag", "false");
		rs.put("error", "[500]"+error);
	}
	return rs;
}
 
開發者ID:elves-project,項目名稱:supervisor,代碼行數:37,代碼來源:SupervisorServiceImpl.java

示例15: getCustomTokenFilters

import java.util.Map; //導入方法依賴的package包/類
public Map<String, Settings> getCustomTokenFilters() throws IOException {
    Map<String, Settings> result = new HashMap<>();
    for (Map.Entry<String, String> entry : getCustomThingies(CustomType.TOKEN_FILTER).getAsMap
            ().entrySet()) {
        result.put(entry.getKey(), decodeSettings(entry.getValue()));
    }
    return result;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:9,代碼來源:FulltextAnalyzerResolver.java


注:本文中的java.util.Map.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。