List of usage examples for java.util HashMap containsKey
public boolean containsKey(Object key)
From source file:com.z.controllers.HomeController.java
@RequestMapping(value = "establecimientos/Count/{localidad}/{departamento}/{lat}/{lng}/{distanciaKM}/{regimen}", method = RequestMethod.GET) public @ResponseBody HashMap<String, Integer> getEstbylocdepCount(@PathVariable("localidad") String localidad, @PathVariable("departamento") String departamento, @PathVariable("lat") String lat, @PathVariable("lng") String lng, @PathVariable("distanciaKM") double distanciaKM, @PathVariable("regimen") String regimen) { Criteria criteria = new CriteriaDistance(Float.parseFloat(lat), Float.parseFloat(lng), distanciaKM); List<Establecimientos> establecimientos; if (regimen.equals("Todos")) { establecimientos = criteria//from w ww .j a va 2 s. c o m .meetCriteria(establecimientosDAO.listByLocalidadAndDepartamento(localidad, departamento)); } else { establecimientos = criteria.meetCriteria( establecimientosDAO.listByLocalidadAndDepartamento(localidad, departamento, regimen)); } HashMap<String, Integer> regimens = new HashMap(); regimens.put("Publico", 0); regimens.put("Privado Subvencionado", 0); regimens.put("Privado No Subvencionado", 0); for (Establecimientos establecimiento : establecimientos) { if (regimens.containsKey(establecimiento.getRegimen())) { regimens.put(establecimiento.getRegimen(), regimens.get(establecimiento.getRegimen()) + 1); } } regimens.put("Total", establecimientos.size()); return regimens; }
From source file:edu.cornell.mannlib.vitro.webapp.search.controller.ExternalLookupAutocompleteController.java
public ExternalLookupService getExternalLookupService(String serviceURI, VitroRequest vreq) throws Exception { HashMap<String, String> serviceInfo = this.getServiceInformation(serviceURI, vreq); if (!serviceInfo.containsKey("serviceClass")) { log.error("No service class returned for service URI " + serviceURI); throw new Exception("No service class returned for service URI " + serviceURI); }//from w w w.j a v a 2s. c om String serviceClassURI = serviceInfo.get("serviceClass"); //URI is of form java:.., need to get portion after java:... String serviceClassName = DataGetterUtils.getClassNameFromUri(serviceClassURI); if (serviceClassName != null) { ExternalLookupService externalServiceClass = null; Object object = null; try { Class classDefinition = Class.forName(serviceClassName); object = classDefinition.newInstance(); externalServiceClass = (ExternalLookupService) object; } catch (InstantiationException e) { System.out.println(e); } catch (IllegalAccessException e) { System.out.println(e); } catch (ClassNotFoundException e) { System.out.println(e); } if (externalServiceClass == null) { log.error("could not find Lookup Class for " + serviceClassName); return null; } //Initialize this class log.debug("Initializing " + serviceClassName + " with serviceInfo " + serviceInfo.toString()); externalServiceClass.initializeLookup(serviceInfo); return externalServiceClass; } log.debug("Service class name is null for " + serviceURI + " and no lookup will occur"); return null; }
From source file:com.github.haixing_hu.bean.DefaultProperty.java
@Override public final boolean containsKey(final String key) { final HashMap<String, Object> map = getMappedValue(); return map.containsKey(key); }
From source file:org.epics.archiverappliance.retrieval.channelarchiver.ChannelArchiverReadOnlyPlugin.java
@Override public void initialize(String configURL, ConfigService configService) throws IOException { try {/*from w w w .ja v a2 s. c o m*/ URI srcURI = new URI(configURL); HashMap<String, String> queryNVPairs = URIUtils.parseQueryString(srcURI); if (queryNVPairs.containsKey("serverURL")) { this.setServerURL(queryNVPairs.get("serverURL")); } else { throw new IOException("Cannot initialize the plugin; this needs the serverURL to be specified"); } if (queryNVPairs.containsKey("archiveKey")) { this.setArchiveKey(Integer.parseInt(queryNVPairs.get("archiveKey"))); } else { throw new IOException("Cannot initialize the plugin; this needs the archiver key to be specified"); } if (queryNVPairs.containsKey("reducedArchiveKey")) { this.setReducedArchiveKey(Integer.parseInt(queryNVPairs.get("reducedArchiveKey"))); } if (queryNVPairs.containsKey("name")) { name = queryNVPairs.get("name"); } else { name = new URL(this.getServerURL()).getHost(); logger.debug("Using the default name of " + name + " for this channel archiver engine"); } this.setDescription("ChannelArchiverReadOnlyPlugin plugin with serverURL " + serverURL + " and archiveKey " + archiveKey + ((reducedArchiveKey != -1) ? (" and a reducedArchiveKey of " + reducedArchiveKey) : (" and no reducedArchiveKey"))); } catch (URISyntaxException ex) { throw new IOException(ex); } }
From source file:com.openerp.services.MeetingSyncService.java
public void performSync(Context context, Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) { // TODO Auto-generated method stub try {/*www . ja v a 2s . c o m*/ // creating a object of MeetingDBHelper to handle database db = new MeetingDBHelper(context); int user_id = Integer.parseInt(OpenERPAccountManager.currentUser(context).getUser_id()); JSONObject domain = new JSONObject(); domain.accumulate("domain", new JSONArray("[[\"user_id\", \"=\", " + user_id + "],[\"id\",\"not in\", " + JSONDataHelper.intArrayToJSONArray(db.localIds(db)) + "]]")); // start sync service to fetch new Records from OpenERP Server to // localDB // first delete records from localdb which are no more in OpenERP // Server // second add new records from OpenERP Server to localdb which are // not in localdb // update localdb with OpenERP Server OEHelper oe = db.getOEInstance(); if (oe.syncWithServer(db, domain)) { // Sync Done, Next stuff.... // initilizing com.openerp.support.calendar obejct to delete // event from OpenERP mobile calendar which are no more in // OpenERP Server and local db calendar = new OECalendar(context); // contains records which are deleted from OpenERP Server and // local db HashMap<String, List<HashMap<String, Object>>> deleted_ids = oe.getDeletedRows(); // check whether any deleted record foud for crm.meeting if (deleted_ids.containsKey("crm.meeting")) { // contains all the deleted records for crm.meeting module List<HashMap<String, Object>> ids = deleted_ids.get("crm.meeting"); // deleting events from OpenERP mobile calendar by id for (int i = 0; i < ids.size(); i++) { // fetching whole row which are deleted @SuppressWarnings("unchecked") HashMap<String, Object> row = ((List<HashMap<String, Object>>) ids.get(i).get("records")) .get(0); // fetching calendar_event_id from localdb to and // deleting events by event_id[calendar_event_id]from // OpenERP mobile calendar calendar.delete_CalendarEvent(Integer.parseInt(row.get("calendar_event_id").toString())); } } // start syncing crm.meetings With OpenERP mobile calandar // creating OpenERP mobile calendar if not exist // registering event under OpenERP mobile calendar if not exist // sync manully created events in OpenERP mobile calendar to // OpenERP Server calendar.sync_Event_TOServer(account, db); } } catch (Exception e) { e.printStackTrace(); } }
From source file:fi.aalto.seqpig.io.BamStorer.java
private int getFieldIndex(String field, HashMap<String, Integer> fieldNames) { if (!fieldNames.containsKey(field)) { System.err.println("Warning: field missing: " + field); return -1; }//from w w w. j a va 2 s.c om return ((Integer) fieldNames.get(field)).intValue(); }
From source file:com.lge.friendsCamera.CustomListAdapter.java
/** * Return file information/* w ww .j a v a 2s . co m*/ * * @param position position of row view * @param key key value of file information (ex) name, size etc. * @return information of the key */ public String getInfo(int position, String key) { HashMap<String, String> info = mItemInfo.get(position); if (info.containsKey(key)) { return info.get(key); } return null; }
From source file:com.predic8.membrane.core.interceptor.authentication.session.TelekomSMSTokenProvider.java
private synchronized String getAccessToken() throws Exception { long now = System.currentTimeMillis(); if (token == null || tokenExpiration < now) { Exchange exc = new Request.Builder().post("https://global.telekom.com/gcp-web-api/oauth") .header(Header.HOST, "global.telekom.com") .header(Header.AUTHORIZATION, "Basic " + new String( Base64.encodeBase64((clientId + ":" + clientSecret).getBytes("UTF-8")), "UTF-8")) .header(Header.ACCEPT, "application/json") .header(Header.USER_AGENT, Constants.PRODUCT_NAME + " " + Constants.VERSION) .header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded") .body(new URLParamUtil.ParamBuilder().add("grant_type", "client_credentials") .add("scope", scope).build()) .buildExchange();/*from ww w . ja v a 2 s. c om*/ exc.setRule(new NullRule() { @Override public SSLProvider getSslOutboundContext() { return new SSLContext(new SSLParser(), new ResolverMap(), null); } }); new HttpClient().call(exc, false, true); if (exc.getResponse().getStatusCode() != 200) throw new RuntimeException("Telekom Authentication Server returned: " + exc.getResponse()); HashMap<String, String> values = Util.parseSimpleJSONResponse(exc.getResponse()); if (!values.containsKey("access_token") || !values.containsKey("expires_in")) throw new Exception( "Telekom Authentication: Received 200 and JSON body, but no access_token or no expires_in."); token = values.get("access_token"); tokenExpiration = Long.parseLong(values.get("expires_in")) + System.currentTimeMillis() - 2000; } return token; }
From source file:at.medevit.elexis.ehc.core.internal.EhcCoreServiceTest.java
@Test public void testGetPatientDocument() { EhcCoreServiceImpl service = new EhcCoreServiceImpl(); CdaCh cda = service.getCdaChDocument(patient, mandant); assertNotNull(cda);//from w w w . j a v a2s .co m org.ehealth_connector.common.Patient cdaPatient = cda.getPatient(); assertNotNull(cdaPatient); assertEquals("name", cdaPatient.getName().getFamilyName()); assertEquals("firstname", cdaPatient.getName().getGivenNames()); assertEquals(AdministrativeGender.FEMALE, cdaPatient.getAdministrativeGenderCode()); Calendar bDay = Calendar.getInstance(); bDay.set(2000, 00, 01, 00, 00, 00); bDay.set(Calendar.MILLISECOND, 00); assertEquals(bDay.getTime(), cdaPatient.getBirthday()); List<Address> addresses = cdaPatient.getAddresses(); assertFalse(addresses.isEmpty()); assertEquals("City", addresses.get(0).getCity()); HashMap<String, AddressUse> phones = cdaPatient.getTelecoms().getPhones(); assertFalse(phones.isEmpty()); assertTrue(phones.containsKey("tel:+01555123")); }
From source file:at.ac.tuwien.qse.sepm.service.impl.TagServiceImpl.java
@Override public List<Tag> getMostFrequentTags(List<Photo> photos) throws ServiceException { LOGGER.debug("Entering getMostFrequentTags with {}", photos); HashMap<Tag, Integer> counter = new HashMap<>(); // count the frequency of each tag for (Photo photo : photos) { for (Tag tag : photo.getData().getTags()) { if (counter.containsKey(tag)) { counter.put(tag, counter.get(tag) + 1); } else { counter.put(tag, 1);/*w ww .j a va 2 s . co m*/ } } } if (counter.size() == 0) { throw new ServiceException("No Tags found"); } // return the most frequent tags return counter.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByValue())).limit(5) .map(Map.Entry::getKey).collect(Collectors.toList()); }