Java Code Examples for java.util.Map.put()

The following are Jave code examples for showing how to use put() of the java.util.Map 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: rocketmq-rocketmq-all-4.1.0-incubating   File: ConsumerProgressSubCommand.java   View Source Code Vote up 7 votes
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;
}
 
Example 2
Project: Hyke   File: HykeLocationManager.java   View Source Code Vote up 7 votes
@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);
}
 
Example 3
Project: mobile-store   File: NanoHTTPD.java   View Source Code Vote up 6 votes
/**
 * 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);
}
 
Example 4
Project: school-website   File: SubjectController.java   View Source Code Vote up 6 votes
/**
 * 添加学科
 * @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;
}
 
Example 5
Project: xm-uaa   File: SystemEventMapperUnitTest.java   View Source Code Vote up 6 votes
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;

}
 
Example 6
Project: Lagerta   File: Commander.java   View Source Code Vote up 5 votes
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());
}
 
Example 7
Project: urllib   File: Queries.java   View Source Code Vote up 5 votes
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);
}
 
Example 8
Project: EasyAppleSyncAdapter   File: SyncManager.java   View Source Code Vote up 5 votes
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;
}
 
Example 9
Project: JRediClients   File: RedissonMapTest.java   View Source Code Vote up 5 votes
@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")));
}
 
Example 10
Project: oscm   File: OperatorClientTest.java   View Source Code Vote up 5 votes
@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);
}
 
Example 11
Project: fdk-java   File: HttpEventCodecTest.java   View Source Code Vote up 5 votes
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;
}
 
Example 12
Project: cim-processor   File: TerminalNode.java   View Source Code Vote up 5 votes
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");
}
 
Example 13
Project: personium-core   File: PropertyLimitCheckerTest.java   View Source Code Vote up 5 votes
/**
 * .
 */
@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());
}
 
Example 14
Project: supervisor   File: SupervisorServiceImpl.java   View Source Code Vote up 5 votes
@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;
}
 
Example 15
Project: Elasticsearch   File: FulltextAnalyzerResolver.java   View Source Code Vote up 5 votes
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;
}
 
Example 16
Project: bdf2   File: BpmServiceImpl.java   View Source Code Vote up 5 votes
/**
 * 初始化任务完成时需要向流程上下文当中设置的变量
 * 
 * @param variablesMap
 * @param task
 */
private void initCompleteTaskVariables(Map<String, Object> variablesMap, Task task) {
	ContextHolder.getLoginUser();
	IUser loginUser = ContextHolder.getLoginUser();
	String userName = this.defaultProcessUsername;
	if (loginUser != null) {
		userName = loginUser.getUsername();
	}
	variablesMap.put(LAST_PROCESS_USER, userName);
	variablesMap.put(LAST_PASS_ACTIVITY_NAME, task.getName());
}
 
Example 17
Project: karanotes   File: FaqinfoServiceImpl.java   View Source Code Vote up 5 votes
@Override
public Map selectFromFaqinfo(Map map) throws Exception {
	Map result = new HashMap<>();
	List<Map> list = faqDaoImpl.selectFaqList(map);
	String count = faqDaoImpl.selectFaqCount();
	result.put("faqlist", list);
	result.put("count", count);
	return result;
}
 
Example 18
Project: personium-core   File: PropertyGetTest.java   View Source Code Vote up 4 votes
/**
 * Propertyを作成して_正常に取得できること.
 */
@Test
public final void Propertyを作成して_正常に取得できること() {
    String locationUrl = UrlUtils.property(Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA, PROPERTY_NAME,
            PROPERTY_ENTITYTYPE_NAME);
    try {
        // リクエストパラメータ設定
        PersoniumRequest req = PersoniumRequest.post(PropertyUtils.REQUEST_URL);
        req.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
        req.header(HttpHeaders.AUTHORIZATION, BEARER_MASTER_TOKEN);
        req.addJsonBody(PropertyUtils.PROPERTY_NAME_KEY, PROPERTY_NAME);
        req.addJsonBody(PropertyUtils.PROPERTY_ENTITYTYPE_NAME_KEY, PROPERTY_ENTITYTYPE_NAME);
        req.addJsonBody(PropertyUtils.PROPERTY_TYPE_KEY, EdmSimpleType.STRING.getFullyQualifiedTypeName());

        // リクエスト実行
        PersoniumResponse response = request(req);
        assertEquals(HttpStatus.SC_CREATED, response.getStatusCode());

        // etag取得
        String etag = getEtag(response);

        // Property取得
        req = PersoniumRequest.get(locationUrl);
        req.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
        req.header(HttpHeaders.AUTHORIZATION, BEARER_MASTER_TOKEN);
        PersoniumResponse resGet = request(req);

        // レスポンスチェック
        Map<String, Object> expected = new HashMap<String, Object>();
        expected.put(PropertyUtils.PROPERTY_NAME_KEY, PROPERTY_NAME);
        expected.put(PropertyUtils.PROPERTY_ENTITYTYPE_NAME_KEY, PROPERTY_ENTITYTYPE_NAME);
        expected.put(PropertyUtils.PROPERTY_TYPE_KEY, EdmSimpleType.STRING.getFullyQualifiedTypeName());
        expected.put(PropertyUtils.PROPERTY_NULLABLE_KEY, true);
        expected.put(PropertyUtils.PROPERTY_DEFAULT_VALUE_KEY, null);
        expected.put(PropertyUtils.PROPERTY_COLLECTION_KIND_KEY, Property.COLLECTION_KIND_NONE);
        expected.put(PropertyUtils.PROPERTY_IS_KEY_KEY, false);
        expected.put(PropertyUtils.PROPERTY_UNIQUE_KEY_KEY, null);
        assertEquals(HttpStatus.SC_OK, resGet.getStatusCode());
        checkResponseBody(resGet.bodyAsJson(), locationUrl, PropertyUtils.NAMESPACE, expected, null, etag);
    } finally {
        // 作成したPropertyを削除
        assertEquals(HttpStatus.SC_NO_CONTENT, deleteOdataResource(locationUrl).getStatusCode());
    }
}
 
Example 19
Project: PI-Web-API-Client-Java-Android   File: ElementTemplateApi.java   View Source Code Vote up 4 votes
private okhttp3.Call getSecurityEntriesCall(String webId, String nameFilter, String selectedFields, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
	Object localVarPostBody =  null;
	// verify the required parameter 'webId' is set
	if (webId == null)
		throw new ApiException("Missing required parameter 'webId'");
	String localVarPath = "/elementtemplates/{webId}/securityentries";
	Map<String, String> localVarHeaderParams = new HashMap<String, String>();
	Map<String, Object> localVarFormParams = new HashMap<String, Object>();
	List<Pair> localVarQueryParams = new ArrayList<Pair>();

	final String[] localVarAccepts = {"application/json", "text/json", "text/html", "application/x-ms-application"};

	final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

	if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

	final String[] localVarContentTypes = {"application/json", "text/json" };

	final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
	localVarHeaderParams.put("Content-Type", localVarContentType);

	localVarPath = localVarPath.replaceAll("\\{webId\\}", apiClient.escapeString(webId.toString()));
	if (nameFilter != null)
		localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "nameFilter", nameFilter));
	if (selectedFields != null)
		localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "selectedFields", selectedFields));
	if (progressListener != null)
	{
		apiClient.getHttpClient().networkInterceptors().add(new okhttp3.Interceptor() {
		@Override
		public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
			okhttp3.Response originalResponse = chain.proceed(chain.request());
			return originalResponse.newBuilder()
			.body(new ProgressResponseBody(originalResponse.body(), progressListener))
			.build();
			}
		});
	}
	String[] localVarAuthNames = new String[] {"Basic" };
	return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
 
Example 20
Project: personium-core   File: PropertyLimitCheckerTest.java   View Source Code Vote up 4 votes
/**
 * .
 */
@SuppressWarnings("unchecked")
@Test
public void 階層4に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);

    // ここが3階層目
    ComplexTypeにsimple型Propertyを指定数作成(29, targetComplexTypeBuilder);
    Builder targetComplexTypeBuilder2 = ComplexTypeにcomplex型Propertyを指定数作成(2, "newComplexType3",
            targetComplexTypeBuilder);
    cpBuilderList.add(targetComplexTypeBuilder2);

    ComplexTypeにsimple型Propertyを指定数作成(9, targetComplexTypeBuilder2);

    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", "Edm.String");
    handler.setStaticFields(staticFields);

    Map<String, String> entityTypeMap = new HashMap<String, String>();
    entityTypeMap.put("_ComplexType.Name_uniqueKey", "newComplexType3");
    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(0, errors.size());
}