当前位置: 首页>>代码示例>>Java>>正文


Java HashMap.put方法代码示例

本文整理汇总了Java中java.util.HashMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java HashMap.put方法的具体用法?Java HashMap.put怎么用?Java HashMap.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.HashMap的用法示例。


在下文中一共展示了HashMap.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateRootWithGhostTutor

import java.util.HashMap; //导入方法依赖的package包/类
private static Node generateRootWithGhostTutor(List<Tutor> tutors, List<Course> courses, List<Shift> shifts) {
    HashMap<Rank, Set<Course>> ghostCoursePreferences = new HashMap<>();
    ghostCoursePreferences.put(Rank.PREFER, new HashSet<>(courses));

    HashMap<Rank, Set<Shift>> ghostShiftPreferences = new HashMap<>();
    ghostShiftPreferences.put(Rank.PREFER, new HashSet<>(shifts));

    HashMap<Rank, Integer> ghostShiftFrequencyPreferences = new HashMap<>();
    ghostShiftFrequencyPreferences.put(Rank.PREFER, Integer.MAX_VALUE);

    TutorPreferences ghostTutorPreference = new TutorPreferences(ghostCoursePreferences, ghostShiftPreferences, ghostShiftFrequencyPreferences);
    Tutor ghostTutor = new Tutor(-1, "Ghost", "Tutor", ghostTutorPreference, TutorStatus.ACTIVE);

    tutors.add(ghostTutor);
    return generateRoot(tutors, courses, shifts);
}
 
开发者ID:cocolocomoco21,项目名称:ULCRS,代码行数:17,代码来源:Scheduler.java

示例2:

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Cellの取得で存在しないIDを指定した場合にjsonフォーマットでNotFoundが返却されること. $format → atom Accept → application/atom+xml
 */
@Test
public final void $formatがatomかつacceptがatomでCellの取得で存在しないIDを指定した場合にjsonフォーマットでNotFoundが返却されること() {
    this.settleCell();
    // $format atom
    // Acceptヘッダ application/atom+xml
    HashMap<String, String> headers = new HashMap<String, String>();
    headers.put(HttpHeaders.AUTHORIZATION, BEARER_MASTER_TOKEN);
    headers.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_ATOM_XML);
    this.setHeaders(headers);

    PersoniumResponse res = this.restGet(getUrl(this.cellId, QUERY_FORMAT_ATOM));

    // TODO $formatのxml対応が完了したら確認内容を修正する
    assertEquals(HttpStatus.SC_NOT_FOUND, res.getStatusCode());
    assertEquals(MediaType.APPLICATION_JSON, res.getResponseHeaders(HttpHeaders.CONTENT_TYPE)[0].getValue());
    this.checkErrorResponse(res.bodyAsJson(), "PR404-OD-0002");
}
 
开发者ID:personium,项目名称:personium-core,代码行数:21,代码来源:ReadTest.java

示例3: getHeaders

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Get response headers returned by last call
 *
 * @return response heades as Map
 */
public Map<String, String> getHeaders() {
	Map<String, List<String>> map = con.getHeaderFields();
	HashMap<String, String> res = new HashMap<String, String>(map.size());
	for (String key : map.keySet()) {
		List<String> list = map.get(key);
		StringBuilder tmp = new StringBuilder();
		int n = 0;
		if (list.size() == 1) {
			res.put(key, list.get(0));
			continue;
		}
		if (list.size() == 0) {
			res.put(key, "");
			continue;
		}
		for (String one : list) {
			if (n > 0)
				tmp.append(";");
			tmp.append(one);
			n++;
		}
		res.put(key, tmp.toString());
	}
	return res;
}
 
开发者ID:Nexenta,项目名称:edgex-java-connector,代码行数:31,代码来源:EdgexClient.java

示例4: getFilterRegistrations

import java.util.HashMap; //导入方法依赖的package包/类
@Override
public Map<String, ? extends FilterRegistration> getFilterRegistrations()
{
    if (!_enabled)
        throw new UnsupportedOperationException();

    HashMap<String, FilterRegistration> registrations = new HashMap<String, FilterRegistration>();
    ServletHandler handler=ServletContextHandler.this.getServletHandler();
    FilterHolder[] holders=handler.getFilters();
    if (holders!=null)
    {
        for (FilterHolder holder : holders)
            registrations.put(holder.getName(),holder.getRegistration());
    }
    return registrations;
}
 
开发者ID:xiaomin0322,项目名称:marathon-auth-plugin,代码行数:17,代码来源:ServletContextHandler.java

示例5: calculateWinner

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Attempts to calculate the winner, returning either the winning {@link Entrant},
 * or <code>null</code>, if the winner can not yet be determined. Optionally records the winning match.
 *
 * @return The winning {@link Entrant}, or <code>null</code>, if the winner
 * can not yet be determined.
 */
public @Nullable Entrant calculateWinner() {
    HashMap<Entrant, Integer> wins = new HashMap<>();
    for (Map.Entry<String, Entrant> match : this.winnerStore.entrySet()) {
        Entrant winner = match.getValue();
        if (winner != null) {
            int winCount = Optional.fromNullable(wins.get(winner)).or(0) + 1;
            wins.put(winner, winCount);
            if (winCount > 1) {
                tourney.recordMatch(match.getKey());
                return winner;
            }
        }
    }

    if (this.getMatchesPlayed() > 2) tourney.recordMatch(this.winnerStore.keySet().iterator().next());
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:25,代码来源:KDMSession.java

示例6: doSerialize

import java.util.HashMap; //导入方法依赖的package包/类
@Override
public void doSerialize(RegistrationData registrationData, IAccount account) throws IOException {
	HashMap<String, Object> data = new HashMap<String, Object>();
	data.put("publicKey", Format.convert(registrationData.getPublicKey()));

	account.putProperty(new AccountProperty(PropertyType.REGISTRATION, data));
}
 
开发者ID:EonTechnology,项目名称:server,代码行数:8,代码来源:RegistrationDataPropertySerializer.java

示例7: testC3getBatchDetails

import java.util.HashMap; //导入方法依赖的package包/类
public void testC3getBatchDetails(){
     
  TestKit probe = new TestKit(system);
  ActorRef subject = system.actorOf(props);
  Request reqObj = new Request();
  reqObj.setOperation(ActorOperations.GET_BATCH.getValue());
  HashMap<String, Object> innerMap = new HashMap<>();
  innerMap.put(JsonKey.BATCH_ID ,batchId );
  reqObj.getRequest().put(JsonKey.BATCH, innerMap);
  subject.tell(reqObj, probe.getRef());
  Response response = probe.expectMsgClass(duration("1000 second"),Response.class);
  String hashtagId = (String) ((Map<String,Object>)response.getResult().get(JsonKey.RESPONSE)).get(JsonKey.HASHTAGID);
  assertEquals(true,hashtagId.equalsIgnoreCase(hashTagId));
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:15,代码来源:CourseBatchManagementActorTest.java

示例8: getNewHotel

import java.util.HashMap; //导入方法依赖的package包/类
private Hotel getNewHotel(int num){
    Hotel hotel = new Hotel();
    HashMap<String, String> mUploadedImages = new HashMap<>();
    mUploadedImages.put("image1","http://i.imgur.com/DvpvklR.png");
    mUploadedImages.put("image2","http://i.imgur.com/DvpvklR.png");
    mUploadedImages.put("image3","http://i.imgur.com/DvpvklR.png");
    mUploadedImages.put("image4","http://i.imgur.com/DvpvklR.png");
    switch (num){
        case 1:
            hotel.setName("Hotel Name");
            hotel.setUid("1234");
            hotel.setBreakfast(true);
            hotel.setBeach(false);
            hotel.setGym(true);
            hotel.setLat(27.257895700000002);
            hotel.setLon(33.8116067);
            hotel.setPets(true);
            hotel.setPhone("01066770250");
            hotel.setPool(false);
            hotel.setPrice(1300);
            hotel.setRate(4);
            hotel.setResturant(false);
            hotel.setSpa(true);
            hotel.setWebsite("www.website.com");
            hotel.setWifi(true);
            hotel.setImagesUrls(mUploadedImages);
    }


    return hotel;
}
 
开发者ID:Elbehiry,项目名称:Viajes,代码行数:32,代码来源:HotelsPresenterTest.java

示例9: invoke

import java.util.HashMap; //导入方法依赖的package包/类
@Override
public HttpResponse invoke(HttpRequestBuilder request, ScriptContext context) {
    COUNTER.incrementAndGet();
    if (request.getMultiPartItems() != null) {
        for (MultiPartItem item : request.getMultiPartItems()) {
            if (item.getValue().isStream()) {
                String s = item.getValue().getAsString();
                if (item.getContentType() == null) {
                    item.setContentType(APPLICATION_OCTET_STREAM);
                }
                item.setValue(new ScriptValue(s));
            }
        }
    }
    HttpResponse response = super.invoke(request, context);
    ManualRestDocumentation restDocumentation = new ManualRestDocumentation();
    restDocumentation.beforeTest(this.getClass(), "invoke");
    KarateRestDocumentationConfigurer configurer = new KarateRestDocumentationConfigurer(restDocumentation);
    configurer.apply();        
    HashMap<String, Object> configuration = configurer.getConfiguration();
    RestDocumentationContext restDocumentationContext = configurer.getContext();
    configuration.put(RestDocumentationContext.class.getName(), restDocumentationContext);        
    getDelegate().handle(request, response, configuration);
    restDocumentation.afterTest();
    return response;

}
 
开发者ID:intuit,项目名称:karate,代码行数:28,代码来源:RestDocsHttpClient.java

示例10: notifyTvBoxVolOff

import java.util.HashMap; //导入方法依赖的package包/类
/**通知机顶盒声音关*/
public static void notifyTvBoxVolOff(Context context, String url,String projectId, ApiRequestListener handler) {
    final HashMap<String, String> params = new HashMap<>();
    params.put("action", 1+"");
    params.put("projectId", projectId);
    final HashMap<String, String> bodyParams = new HashMap<>();
    if(!TextUtils.isEmpty(url)) {
        new AppServiceOk(context,formatProUrl(context,url+"/volume?",params),Action.POST_NOTIFY_VOL_OFF_JSON,handler,bodyParams).get();
    }
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:11,代码来源:AppApi.java

示例11: buildSysUserInfo

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * SysUserInfo
 * @param users
 * @return
 */
public static String buildSysUserInfo(Set<User> users){
    HashMap<String, Object> map = new HashMap<>();
    map.put("count",users.size());
    map.put("userinfo",users);
    return buildProto(SYS_USERSINFO_CODE,map);
}
 
开发者ID:ChinaLHR,项目名称:JavaQuarkBBS,代码行数:12,代码来源:QuarkChatProtocol.java

示例12: findDistributions

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Uses reflection to return an HashMap of distributions suitable for LDStrategy.
 * (With mean value specifiable) Search's key is distribution name and value is the
 * Class of found distribution
 * @return found distributions
 */
protected static HashMap<String, Distribution> findDistributions() {
	Distribution[] all = Distribution.findAllWithMean();
	HashMap<String, Distribution> tmp = new HashMap<String, Distribution>();
	for (Distribution element : all) {
		tmp.put(element.getName(), element);
	}
	return tmp;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:15,代码来源:LDStrategyEditor.java

示例13: requesttoAuthz

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Cookie認証で自分セルローカルトークンを取得できること.
 */
@Test
public final void Cookie認証で自分セルローカルトークンを取得できること() {

    // パスワード認証で自分セルリフレッシュトークン取得
    String addbody = "&username=account2&password=password2";
    PersoniumResponse res = requesttoAuthz(addbody);
    assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, res.getStatusCode());
    // cookieの値と有効期限の確認
    String sessionId = checkSessionId(false, Setup.TEST_CELL1);

    // 認証前のアカウントの最終ログイン時刻を取得しておく
    Long lastAuthenticatedTime = AuthTestCommon.getAccountLastAuthenticated(Setup.TEST_CELL1, "account2");
    // Cookie認証
    String body = "response_type=token&client_id=" + UrlUtils.cellRoot(Setup.TEST_CELL_SCHEMA1)
            + "&redirect_uri=" + UrlUtils.cellRoot(Setup.TEST_CELL_SCHEMA1) + REDIRECT_HTML
            + "&state=" + DEFAULT_STATE;
    HashMap<String, String> headers = new HashMap<String, String>();
    headers.put("session-id", sessionId);
    res = requesttoAuthzWithBody(Setup.TEST_CELL1, body, headers);

    checkSessionId(true, Setup.TEST_CELL1);
    // アカウントの最終ログイン時刻が更新されていないことの確認
    AuthTestCommon.accountLastAuthenticatedNotUpdatedCheck(Setup.TEST_CELL1, "account2", lastAuthenticatedTime);

    // {redirect_uri}#access_token={access_token}&token_type=Bearer&expires_in={expires_in}&state={state}
    Map<String, String> response = parseResponse(res);
    try {
        AccountAccessToken aToken = AccountAccessToken.parse(response.get(OAuth2Helper.Key.ACCESS_TOKEN),
                UrlUtils.cellRoot(Setup.TEST_CELL1));
        assertNotNull("access token parse error.", aToken);
        assertEquals(OAuth2Helper.Scheme.BEARER, response.get(OAuth2Helper.Key.TOKEN_TYPE));
        assertEquals("3600", response.get(OAuth2Helper.Key.EXPIRES_IN));
        assertEquals(DEFAULT_STATE, response.get(OAuth2Helper.Key.STATE));
    } catch (TokenParseException e) {
        fail(e.getMessage());
        e.printStackTrace();
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:42,代码来源:ImplicitFlowTest.java

示例14: makeRescanDummy

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Dummy provider for rescan action
 *
 * @return dummy provider
 */
@NonNull
private HashMap<String, Object> makeRescanDummy()
{
	final HashMap<String, Object> result = new HashMap<>();
	final String name = getString(R.string.title_rescan);
	result.put(Providers.NAME, name);
	result.put(Providers.ICON, R.drawable.ic_refresh);
	result.put(Providers.PACKAGE, null);
	result.put(RESCAN_KEY, true);
	return result;
}
 
开发者ID:1313ou,项目名称:Treebolic,代码行数:17,代码来源:MainActivity.java

示例15: begin

import java.util.HashMap; //导入方法依赖的package包/类
@Override
public final void begin(final String name, final Attributes attrs) {
    labels = new HashMap<Object, Label>();
    HashMap<String, Object> vals = new HashMap<String, Object>();
    vals.put("access", attrs.getValue("access"));
    vals.put("name", attrs.getValue("name"));
    vals.put("desc", attrs.getValue("desc"));
    vals.put("signature", attrs.getValue("signature"));
    vals.put("exceptions", new ArrayList<String>());
    push(vals);
    // values will be extracted in ExceptionsRule.end();
}
 
开发者ID:acmerli,项目名称:fastAOP,代码行数:13,代码来源:ASMContentHandler.java


注:本文中的java.util.HashMap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。