當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。