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


Java HashMap类代码示例

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


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

示例1: findSongsByAlbum

import java.util.HashMap; //导入依赖的package包/类
private void findSongsByAlbum() {

        // Create key list
        keyList = new ArrayList<>();
        songAlbumList = new HashMap<>();

        // Go through songs
        List<SongData> songList = getSongInfoList();
        for (SongData songData: songList) {
            String album = songData.getSongAlbum();

            // Create new if album does not exist
            if (!keyList.contains(album)) {
                keyList.add(album);
                songAlbumList.put(album, new ArrayList<SongData>());
            }
            songAlbumList.get(album).add(songData);
        }
    }
 
开发者ID:Davarco,项目名称:Divertio,代码行数:20,代码来源:AlbumMenuActivity.java

示例2: startWithoutTitle

import java.util.HashMap; //导入依赖的package包/类
@Test
public void startWithoutTitle()
{
    Intent intent = new Intent();

    final Bundle bundle = new Bundle();
    bundle.putInt("description", R.string.app_name);
    bundle.putSerializable("items", new HashMap<String, Integer>());
    intent.putExtras(bundle);

    ActivityController controller = Robolectric.buildActivity(ItemizeActivity.class, intent).create();
    Activity activity = (Activity)controller.get();

    controller.start();
    assertTrue(activity.isFinishing());

    String latestToast = ShadowToast.getTextOfLatestToast();
    assertNotNull(latestToast);
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:20,代码来源:ItemizationActivityTest.java

示例3: testAsyncUpdateRow2

import java.util.HashMap; //导入依赖的package包/类
@Test
public void testAsyncUpdateRow2() {
    Map<String,Object> updateValues = new HashMap<String,Object>();
    updateValues.put(PERSON_FIRST_NAME, "Tennis");
    updateValues.put(PERSON_AGE, 60);

    Future<?> future = storageSource.updateRowAsync(PERSON_TABLE_NAME, "777-77-7777", updateValues);
    waitForFuture(future);

    try {
        IResultSet resultSet = storageSource.getRow(PERSON_TABLE_NAME, "777-77-7777");
        Object[][] expectedPersons = {{"777-77-7777", "Tennis", "Borg", 60, true}};
        checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedPersons);
    }
    catch (Exception e) {
        fail("Exception thrown in async storage operation: " + e.toString());
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:StorageTest.java

示例4: findPathVarIgnoreCaseTest

import java.util.HashMap; //导入依赖的package包/类
@Test
public void findPathVarIgnoreCaseTest() {

    // Setup
    final Request req = Mockito.mock(Request.class);
    Mockito.when(req.params()).thenReturn(new HashMap<String, String>() {
        {
            put(":name", "Bob");
            put(":Age", "21");
        }
    });

    // Test
    final String nameResult = GeneralUtils.findPathVarIgnoreCase(req, "NAME");

    // Assertions
    Assert.assertNotNull(nameResult);
    Assert.assertEquals("Bob", nameResult);

    // Test
    final String ageResult = GeneralUtils.findPathVarIgnoreCase(req, "age");

    // Assertions
    Assert.assertNotNull(ageResult);
    Assert.assertEquals("21", ageResult);
}
 
开发者ID:mgtechsoftware,项目名称:smockin,代码行数:27,代码来源:GeneralUtilsTest.java

示例5: init

import java.util.HashMap; //导入依赖的package包/类
/**
 * Initialize internal data structures
 */
public void init(Map<String, String> configParams) throws FloodlightModuleException {

    this.moduleLoaderState = ModuleLoaderState.INIT;

    // These data structures are initialized here because other
    // module's startUp() might be called before ours        
    this.messageListeners = new ConcurrentHashMap<OFType, ListenerDispatcher<OFType, IOFMessageListener>>();
    this.haListeners = new ListenerDispatcher<HAListenerTypeMarker, IHAListener>();
    this.controllerNodeIPsCache = new HashMap<String, String>();
    this.updates = new LinkedBlockingQueue<IUpdate>();
    this.providerMap = new HashMap<String, List<IInfoProvider>>();
   
    setConfigParams(configParams);

    HARole initialRole = getInitialRole(configParams);
    this.notifiedRole = initialRole;
    this.shutdownService = new ShutdownServiceImpl();

    this.roleManager = new RoleManager(this, this.shutdownService,
                                       this.notifiedRole,
                                       INITIAL_ROLE_CHANGE_DESCRIPTION);
    this.timer = new HashedWheelTimer();

    // Switch Service Startup
    this.switchService.registerLogicalOFMessageCategory(LogicalOFMessageCategory.MAIN);
    this.switchService.addOFSwitchListener(new NotificationSwitchListener());

    this.counters = new ControllerCounters(debugCounterService);
 }
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:33,代码来源:Controller.java

示例6: handleRequestInternal

import java.util.HashMap; //导入依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    Map<String,Object> model = new HashMap<String,Object>();

    model.put("summary", ProfilerControl.generateSummary());
    model.put("profiles", ProfilerControl.getMethodProfiles());

    return new ModelAndView("viewProfiling", model);
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:12,代码来源:ViewProfilingController.java

示例7: getRequestProperties

import java.util.HashMap; //导入依赖的package包/类
/**
 * Returns an unmodifiable Map of general request
 * properties for this connection. The Map keys
 * are Strings that represent the request-header
 * field names. Each Map value is a unmodifiable List
 * of Strings that represents the corresponding
 * field values.
 *
 * @return  a Map of the general request properties for this connection.
 * @throws IllegalStateException if already connected
 * @since 1.4
 */
@Override
public synchronized Map<String, List<String>> getRequestProperties() {
    if (connected)
        throw new IllegalStateException("Already connected");

    // exclude headers containing security-sensitive info
    if (setUserCookies) {
        return requests.getHeaders(EXCLUDE_HEADERS);
    }
    /*
     * The cookies in the requests message headers may have
     * been modified. Use the saved user cookies instead.
     */
    Map<String, List<String>> userCookiesMap = null;
    if (userCookies != null || userCookies2 != null) {
        userCookiesMap = new HashMap<>();
        if (userCookies != null) {
            userCookiesMap.put("Cookie", Arrays.asList(userCookies));
        }
        if (userCookies2 != null) {
            userCookiesMap.put("Cookie2", Arrays.asList(userCookies2));
        }
    }
    return requests.filterAndAddHeaders(EXCLUDE_HEADERS2, userCookiesMap);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:HttpURLConnection.java

示例8: setOpenStackParams

import java.util.HashMap; //导入依赖的package包/类
private static void setOpenStackParams(VirtualizationConnectorDto vcDto,
        String projectName,
        String domainId,
        String rabbitMquser,
        String rabbitMqpassword,
        String rabbitMqport,
        String controllerTypeStr){

    vcDto.setAdminDomainId(domainId);
    vcDto.setAdminProjectName(projectName);

    Map<String, String> providerAttributes = new HashMap<>();
    providerAttributes.put(ATTRIBUTE_KEY_RABBITMQ_USER, rabbitMquser);
    providerAttributes.put(ATTRIBUTE_KEY_RABBITMQ_USER_PASSWORD, rabbitMqpassword);
    providerAttributes.put(ATTRIBUTE_KEY_RABBITMQ_PORT, rabbitMqport);
    vcDto.setProviderAttributes(providerAttributes);

    if (controllerTypeStr != null && (!controllerTypeStr.isEmpty())) {
        vcDto.setControllerType(controllerTypeStr);
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:22,代码来源:VirtualizationConnectorServiceData.java

示例9: handleUpdate

import java.util.HashMap; //导入依赖的package包/类
@Override
protected WriteAttributeResults handleUpdate ( final Map<String, Variant> attributes, final OperationParameters operationParameters ) throws Exception
{
    final Map<String, String> data = new HashMap<String, String> ();

    final Variant active = attributes.get ( "active" ); //$NON-NLS-1$
    final Variant factor = attributes.get ( "factor" ); //$NON-NLS-1$
    final Variant offset = attributes.get ( "offset" ); //$NON-NLS-1$

    if ( active != null && !active.isNull () )
    {
        data.put ( "active", active.asString () ); //$NON-NLS-1$
    }
    if ( factor != null && !factor.isNull () )
    {
        data.put ( "factor", factor.asString () ); //$NON-NLS-1$
    }
    if ( offset != null && !offset.isNull () )
    {
        data.put ( "offset", offset.asString () ); //$NON-NLS-1$
    }

    return updateConfiguration ( data, attributes, false, operationParameters );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:ScaleHandlerImpl.java

示例10: jsonToHasMap

import java.util.HashMap; //导入依赖的package包/类
public static HashMap<String, Object> jsonToHasMap(JSONObject jsonObject) throws JSONException {
    HashMap<String, Object> hs = new HashMap<String, Object>();
    JSONObject object = jsonObject;
    Iterator<?> iterator = object.keys();
    while (iterator.hasNext()) {
        String key = (String) iterator.next();
        Object value = object.get(key);

        if (value instanceof JSONObject) {
            JSONObject jsonObject2 = new JSONObject(value.toString());
            hs.put(key, jsonToHasMap(jsonObject2));
        } else {
            if (value instanceof JSONArray) {
                JSONArray array = new JSONArray(value.toString());
                List<HashMap<?, ?>> list = new ArrayList<>();
                for (int i = 0; i < array.length(); i++) {
                    list.add(jsonToHasMap(array.getJSONObject(i)));
                }
                hs.put(key, list);
            } else {
                hs.put(key, value);
            }
        }
    }
    return hs;
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:27,代码来源:JsonUtils.java

示例11: onNextButtonClicked

import java.util.HashMap; //导入依赖的package包/类
@FXML
private void onNextButtonClicked() {
    // Prevent proceeding when no rooms are selected
    if(selectedRooms.size() <= 0) {
        return;
    }

    Object temp = ScreenManager.getInstance().switchToScreen("/fxml/PlaceBookingScreen.fxml");
    PlaceBookingScreenController controller = (PlaceBookingScreenController) temp;
    Map<RoomCategory, Integer> roomsData = new HashMap<>();
    LocalDate checkInDate = checkInDatePicker.getValue();
    LocalDate checkOutDate = checkOutDatePicker.getValue();
    selectedRooms.forEach((r) -> {
        roomsData.merge(r.getRoomCategory(), 1, Integer::sum);
    });
    controller.initializeData(roomsData, this.packageQtys, checkInDate, checkOutDate);
}
 
开发者ID:maillouxc,项目名称:git-rekt,代码行数:18,代码来源:BrowseRoomsScreenController.java

示例12: getBasicSchemaGridRowList

import java.util.HashMap; //导入依赖的package包/类
/**
  * pull out basicSchemaGridRow object from Schema object.
  * 
 * @param targetTerminal  
 * @param link
 * @return list of BasicSchemaGridRow
 */
public List<BasicSchemaGridRow> getBasicSchemaGridRowList(String targetTerminal, Link link) {
	 List<BasicSchemaGridRow> basicSchemaGridRows=null;
	if(StringUtils.equalsIgnoreCase(Constants.INPUT_SUBJOB_COMPONENT_NAME, link.getSource().getComponentName())
	   ||StringUtils.equalsIgnoreCase(Constants.SUBJOB_COMPONENT, link.getSource().getComponentName()))
	{
		Map<String,Schema> inputSchemaMap=(HashMap<String,Schema>)link.getSource().getProperties().
				get(Constants.SCHEMA_FOR_INPUTSUBJOBCOMPONENT);
		if(inputSchemaMap!=null &&inputSchemaMap.get(targetTerminal)!=null)
		basicSchemaGridRows=SchemaSyncUtility.INSTANCE.
				convertGridRowsSchemaToBasicSchemaGridRows(inputSchemaMap.get(targetTerminal).getGridRow());
	}
	else 
	{	
	Schema previousComponentSchema=SchemaPropagation.INSTANCE.getSchema(link);
	if (previousComponentSchema != null)
	basicSchemaGridRows=SchemaSyncUtility.INSTANCE.
	convertGridRowsSchemaToBasicSchemaGridRows(previousComponentSchema.getGridRow());
	}
	return basicSchemaGridRows;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:28,代码来源:SchemaPropagationHelper.java

示例13: testsForHashMapNullKeysForbidden

import java.util.HashMap; //导入依赖的package包/类
private static Test testsForHashMapNullKeysForbidden() {
  return wrappedHashMapTests(new WrappedHashMapGenerator() {
    @Override Map<String, String> wrap(final HashMap<String, String> map) {
      if (map.containsKey(null)) {
        throw new NullPointerException();
      }
      return new AbstractMap<String, String>() {
        @Override public Set<Map.Entry<String, String>> entrySet() {
          return map.entrySet();
        }
        @Override public String put(String key, String value) {
          checkNotNull(key);
          return map.put(key, value);
        }
      };
    }
  }, "HashMap w/out null keys", ALLOWS_NULL_VALUES);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:19,代码来源:MapTestSuiteBuilderTests.java

示例14: getAirEvent

import java.util.HashMap; //导入依赖的package包/类
private AirEvent getAirEvent(HashMap<String, KeyCode> codeDatas) {
        AirEvent airEvent = null;
        if (!Utility.isEmpty(codeDatas)) {
            if (airVerSion == V3) {
                airEvent = new AirV3Command(codeDatas);
            } else {
                airEvent = new AirV1Command(codeDatas);
            }
        }
//        Map.Entry<String,KeyCode> entry;
//        for(Iterator iterator = codeDatas.entrySet().iterator();iterator.hasNext();){
//            entry = (Map.Entry<String, KeyCode>) iterator.next();
//            entry.getKey();
//            YourKeyCode yourKeyCode = new YourKeyCode();
//            yourKeyCode.setSrcCode(entry.getValue().getSrcCode());
//        }
        return airEvent;
    }
 
开发者ID:yaokantv,项目名称:YKCenterSDKExample_for_AS,代码行数:19,代码来源:AirControlActivity.java

示例15: Z18TestJoinUserOrganisation3

import java.util.HashMap; //导入依赖的package包/类
@Test
public void Z18TestJoinUserOrganisation3(){
  TestKit probe = new TestKit(system);
  ActorRef subject = system.actorOf(props);
  Request reqObj = new Request();
  reqObj.setOperation(ActorOperations.JOIN_USER_ORGANISATION.getValue());
  Map<String, Object> innerMap = new HashMap<>();
  innerMap.put(JsonKey.USER_ID,userId);
  innerMap.put(JsonKey.ORGANISATION_ID,(orgId2+"456as"));
  reqObj.getRequest().put(JsonKey.REQUESTED_BY,userIdnew);
  Map<String, Object> request = new HashMap<String, Object>();
  request.put(JsonKey.USER_ORG, innerMap);
  reqObj.setRequest(request);
  subject.tell(reqObj, probe.getRef());
  probe.expectMsgClass(duration("200 second"), ProjectCommonException.class);
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:17,代码来源:UserManagementActorTest.java


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