List of usage examples for java.util HashMap values
public Collection<V> values()
From source file:playground.wrashid.parkingSearch.ppSim.jdepSim.searchStrategies.analysis.ComparisonGarageCounts.java
public static void logOutput(LinkedList<ParkingEventDetails> parkingEventDetails, String outputFileName) { init();//from w ww .ja va 2 s .co m // Output file log.info("starting log parking events"); String iterationFilenamePng = outputFileName + ".png"; String iterationFilenameTxt = outputFileName + ".txt"; HashMap<Id, ParkingOccupancyBins> parkingOccupancyBins = new HashMap<Id, ParkingOccupancyBins>(); for (ParkingEventDetails ped : parkingEventDetails) { ParkingActivityAttributes parkingActivityAttributes = ped.parkingActivityAttributes; Id facilityId = parkingActivityAttributes.getFacilityId(); if (mappingOfParkingNameToParkingId.values().contains(facilityId.toString())) { if (!parkingOccupancyBins.containsKey(facilityId)) { parkingOccupancyBins.put(facilityId, new ParkingOccupancyBins()); } ParkingOccupancyBins parkingOccupancyBin = parkingOccupancyBins.get(facilityId); parkingOccupancyBin.inrementParkingOccupancy(parkingActivityAttributes.getParkingArrivalTime(), parkingActivityAttributes.getParkingArrivalTime() + parkingActivityAttributes.getParkingDuration()); } } int[] sumOfSelectedParkingSimulatedCounts = new int[96]; for (ParkingOccupancyBins pob : parkingOccupancyBins.values()) { for (int i = 0; i < 96; i++) { sumOfSelectedParkingSimulatedCounts[i] += pob.getOccupancy()[i]; } } int numberOfColumns = 2; double matrix[][] = new double[96][numberOfColumns]; for (int i = 0; i < 96; i++) { matrix[i][0] = sumOfSelectedParkingSimulatedCounts[i]; matrix[i][1] = sumOfOccupancyCountsOfSelectedParkings[i]; } String title = "Parking Garage Counts Comparison"; String xLabel = "time (15min-bin)"; String yLabel = "# of occupied parkings"; String[] seriesLabels = new String[2]; seriesLabels[0] = "simulated counts"; seriesLabels[1] = "real counts"; double[] xValues = new double[96]; for (int i = 0; i < 96; i++) { xValues[i] = i / (double) 4; } GeneralLib.writeGraphic(iterationFilenamePng, matrix, title, xLabel, yLabel, seriesLabels, xValues); String txtFileHeader = seriesLabels[0]; for (int i = 1; i < numberOfColumns; i++) { txtFileHeader += "\t" + seriesLabels[i]; } GeneralLib.writeMatrix(matrix, iterationFilenameTxt, txtFileHeader); log.info("finished log parking events"); }
From source file:eu.geopaparazzi.core.ui.dialogs.GpxExportDialogFragment.java
private void startExport() { final Context context = getContext(); new AsyncTask<String, Void, String>() { protected String doInBackground(String... params) { try { List<GpxRepresenter> gpxRepresenterList = new ArrayList<>(); boolean hasAtLeastOne = false; /*// www . j a va 2 s . c om * add gps logs */ HashMap<Long, Line> linesMap = DaoGpsLog.getLinesMap(); Collection<Line> linesCollection = linesMap.values(); for (Line line : linesCollection) { if (isInterrupted) break; gpxRepresenterList.add(line); hasAtLeastOne = true; } /* * get notes */ List<Note> notesList = DaoNotes.getNotesList(null, false); for (Note note : notesList) { if (isInterrupted) break; gpxRepresenterList.add(note); hasAtLeastOne = true; } if (!hasAtLeastOne) { return NODATA; } if (isInterrupted) return INTERRUPTED; File gpxExportDir = ResourcesManager.getInstance(getActivity()).getSdcardDir(); String filename = "geopaparazzi_" + TimeUtilities.INSTANCE.TIMESTAMPFORMATTER_LOCAL.format(new Date()) + "." + FileTypes.GPX.getExtension(); File gpxOutputFile = new File(gpxExportDir, filename); if (exportPath != null) { gpxOutputFile = new File(exportPath); } GpxExport export = new GpxExport(null, gpxOutputFile); export.export(getActivity(), gpxRepresenterList); return gpxOutputFile.getAbsolutePath(); } catch (Exception e) { GPLog.error(this, e.getLocalizedMessage(), e); return null; } } protected void onPostExecute(String response) { // on UI thread! progressBar.setVisibility(View.GONE); if (response.equals(NODATA)) { String msg = context.getString(R.string.no_data_found_in_project_to_export); alertDialog.setMessage(msg); positiveButton.setEnabled(true); } else if (response.equals(INTERRUPTED)) { alertDialog.setMessage("Interrupted by user"); positiveButton.setEnabled(true); } else if (response.length() > 0) { String msg = context.getString(R.string.datasaved) + response; alertDialog.setMessage(msg); positiveButton.setEnabled(true); } else { String msg = context.getString(R.string.data_nonsaved); alertDialog.setMessage(msg); positiveButton.setEnabled(true); } } }.execute((String) null); }
From source file:com.tacitknowledge.util.migration.DistributedJdbcMigrationLauncherFactoryTest.java
/** * Ensure that read-only mode actually works * /*from w w w .ja v a2 s . c om*/ * @exception Exception if anything goes wrong */ public void testDistributedReadOnlyMode() throws Exception { int currentPatchLevel = 3; DistributedMigrationProcess process = (DistributedMigrationProcess) launcher.getMigrationProcess(); process.validateTasks(process.getMigrationTasks()); // need to mock the patch info stores to return the expected patch levels HashMap controlledSystems = process.getControlledSystems(); setReportedPatchLevel(controlledSystems.values(), currentPatchLevel); // Make it readonly process.setReadOnly(true); // Now do the migrations, and make sure we get the right number of events try { process.doMigrations(currentPatchLevel, context); fail("There should have been an exception - unapplied patches + read-only don't work"); } catch (MigrationException me) { // we expect this log.debug("got exception: " + me.getMessage()); } currentPatchLevel = 8; // need to mock the patch info stores to return the expected patch levels setReportedPatchLevel(controlledSystems.values(), currentPatchLevel); int patches = process.doMigrations(currentPatchLevel, context); assertEquals(0, patches); assertEquals(0, getMigrationStartedCount()); assertEquals(0, getMigrationSuccessCount()); }
From source file:com.strategames.catchdastars.activities.SelectMusicActivity.java
@Override public void onItemClicked(LibraryItem item) { Artist artist;//from ww w.jav a 2 s . c o m if (item instanceof Artist) { artist = (Artist) item; HashMap<String, Album> albums = artist.getAlbums(); Album[] albumNames = albums.values().toArray(new Album[albums.size()]); replaceFragment(albumNames, SelectMusicFragment.STATE.ALBUMS); } else if (item instanceof Album) { artist = ((Album) item).getArtist(); Album album = (Album) item; HashMap<String, Track> tracks = album.getTracks(); Track[] trackNames = tracks.values().toArray(new Track[tracks.size()]); replaceFragment(trackNames, SelectMusicFragment.STATE.TRACKS); } else if (item instanceof Track) { // play track as a preview? } }
From source file:com.tacitknowledge.util.migration.jdbc.DistributedJdbcMigrationLauncherFactoryTest.java
/** * Ensure that read-only mode actually works * * @throws Exception if anything goes wrong *///from w w w . j a v a 2 s . c o m public void testDistributedReadOnlyMode() throws Exception { int currentPatchLevel = 3; DistributedMigrationProcess process = (DistributedMigrationProcess) launcher.getMigrationProcess(); process.validateTasks(process.getMigrationTasks()); // need to mock the patch info stores to return the expected patch levels HashMap controlledSystems = process.getControlledSystems(); setReportedPatchLevel(controlledSystems.values(), currentPatchLevel); // Make it readonly process.setReadOnly(true); // Now do the migrations, and make sure we get the right number of events try { process.doMigrations(MockBuilder.getPatchInfoStore(currentPatchLevel), context); fail("There should have been an exception - unapplied patches + read-only don't work"); } catch (MigrationException me) { // we expect this log.debug("got exception: " + me.getMessage()); } currentPatchLevel = 8; // need to mock the patch info stores to return the expected patch levels setReportedPatchLevel(controlledSystems.values(), currentPatchLevel); int patches = process.doMigrations(MockBuilder.getPatchInfoStore(currentPatchLevel), context); assertEquals(0, patches); assertEquals(0, getMigrationStartedCount()); assertEquals(0, getMigrationSuccessCount()); }
From source file:com.o2d.pkayjava.editor.data.migrations.migrators.VersionMigTo009.java
private void fixLibraryItemsLocation(HashMap<String, JsonValue> libraryItems) { if (libraryItems.size() == 0) return;/* w ww. jav a 2 s .c o m*/ //creating libraryArrayJsonString String libraryArrayJsonString = "{"; for (JsonValue entry : libraryItems.values()) { libraryArrayJsonString += "\"" + entry.name + "\": " + entry.prettyPrint(JsonWriter.OutputType.json, 1) + ", "; } libraryArrayJsonString = libraryArrayJsonString.substring(0, libraryArrayJsonString.length() - 2) + "}"; //ProjectInfo data String prjInfoFilePath = projectPath + "/project.dt"; FileHandle projectInfoFile = Gdx.files.internal(prjInfoFilePath); try { String projectInfoContents = FileUtils.readFileToString(projectInfoFile.file()); JsonValue value = jsonReader.parse(projectInfoContents); JsonValue newVal = jsonReader.parse(libraryArrayJsonString); newVal.name = "libraryItems"; newVal.prev = value.get("scenes"); newVal.next = newVal.prev.next; newVal.prev.next = newVal; String content = value.prettyPrint(JsonWriter.OutputType.json, 1); FileUtils.writeStringToFile(new File(prjInfoFilePath), content, "utf-8"); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.almende.demo.conferenceApp.ConferenceAgent.java
public List<Info> getList(final boolean filterIgnored) { List<Info> result = new ArrayList<Info>(); if (getState() != null && getState().containsKey(CONTACTKEY.getKey())) { HashMap<String, Info> contacts = getState().get(CONTACTKEY); for (Info info : contacts.values()) { if (info.isKnown() && !info.isIgnored()) { result.add(info);/* w w w. j a va 2s. co m*/ } } } Collections.sort(result, Collections.reverseOrder()); return result; }
From source file:com.teamd.taxi.validation.DriverValidateUtil.java
@Override public List<FieldError> filterErrors(List<FieldError> errors) { HashMap<String, FieldError> result = new HashMap<>(); for (FieldError error : errors) { String field = error.getField(); if (!result.keySet().contains(field)) { result.put(field, error);// w w w. j ava2 s.c o m } else { result.put(field, higherError(result.get(field), error)); } } return new ArrayList<>(result.values()); }
From source file:org.apache.axis2.engine.ListenerManager.java
/** * Stop all the transports and notify modules of shutdown. *///from www . j a v a 2s . c o m public synchronized void stop() throws AxisFault { if (stopped) { return; } for (Iterator iter = startedTransports.values().iterator(); iter.hasNext();) { TransportListener transportListener = (TransportListener) iter.next(); transportListener.stop(); } /*Stop the transport senders*/ HashMap transportOut = configctx.getAxisConfiguration().getTransportsOut(); if (transportOut.size() > 0) { Iterator trsItr = transportOut.values().iterator(); while (trsItr.hasNext()) { TransportOutDescription outDescription = (TransportOutDescription) trsItr.next(); TransportSender trsSededer = outDescription.getSender(); if (trsSededer != null) { trsSededer.stop(); } } } /*Shut down the modules*/ HashMap modules = configctx.getAxisConfiguration().getModules(); if (modules != null) { Iterator moduleitr = modules.values().iterator(); while (moduleitr.hasNext()) { AxisModule axisModule = (AxisModule) moduleitr.next(); Module module = axisModule.getModule(); if (module != null) { module.shutdown(configctx); } } } configctx.cleanupContexts(); /*Shut down the services*/ for (Iterator services = configctx.getAxisConfiguration().getServices().values().iterator(); services .hasNext();) { AxisService axisService = (AxisService) services.next(); ServiceLifeCycle serviceLifeCycle = axisService.getServiceLifeCycle(); if (serviceLifeCycle != null) { serviceLifeCycle.shutDown(configctx, axisService); } } stopped = true; }
From source file:com.strategames.catchdastars.activities.SelectMusicActivity.java
@Override public void onLoadFinished(android.support.v4.content.Loader<Cursor> loader, Cursor cursor) { this.musicAll = new Library(); int indexArtist = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST); int indexAlbum = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM); int indexData = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA); int indexTitle = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE); int indexTrack = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TRACK); while (cursor.moveToNext()) { String albumTitle = cursor.getString(indexAlbum); String trackPath = cursor.getString(indexData); String trackTitle = cursor.getString(indexTitle); String trackNumber = cursor.getString(indexTrack); String artistName = cursor.getString(indexArtist); this.musicAll.addTrack(artistName, albumTitle, trackTitle, trackNumber, trackPath); if (trackInDatabase(artistName, albumTitle, trackTitle)) { Artist artist = this.musicAll.getArtist(artistName); artist.setSelected(true);//from w w w . ja v a 2s.c o m Album album = artist.getAlbum(albumTitle); album.setSelected(true); Track track = album.getTrack(trackTitle); track.setSelected(true); } } HashMap<String, Artist> artistMap = this.musicAll.getArtists(); Artist[] artists = artistMap.values().toArray(new Artist[artistMap.size()]); CheckBoxTextViewAdapter adapter = new CheckBoxTextViewAdapter(this, artists, this); this.fragment.setAdapter(adapter); }