List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:org.eda.fpsrv.StrTable.java
public void setFromJSONString(String jsonString) { LinkedHashMap<String, String> h_map; try {/* w w w . j a va 2s . co m*/ h_map = new ObjectMapper().readValue(jsonString, new TypeReference<LinkedHashMap<String, Object>>() { }); FPProperty property; for (String key : keySet()) { if (h_map.containsKey(key)) { put(key, h_map.get(key)); } } } catch (IOException ex) { Logger.getLogger(StrTable.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ca.sfu.federation.model.InputTable.java
/** * Get Input by name.// w ww . ja v a 2s . c o m * @return Input */ public Input getInput(String Name) { // init Input result = null; // if the named Input exists in the table LinkedHashMap index = this.getInputIndex(); if (index.containsKey(Name)) { result = (Input) index.get(Name); } // return result return result; }
From source file:org.openmeetings.app.remote.LanguageService.java
/** * /*from w w w . j av a 2 s. co m*/ * @param SID * @param values * @return */ public Long saveOrUpdateLabel(String SID, LinkedHashMap<Object, Object> values) { try { Long users_id = sessionManagement.checkSession(SID); Long user_level = userManagement.getUserLevelByID(users_id); Long fieldvalues_id = Long.valueOf(values.get("fieldvalues_id").toString()).longValue(); String name = values.get("name").toString(); Long fieldlanguagesvalues_id = Long.valueOf(values.get("fieldlanguagesvalues_id").toString()) .longValue(); Long language_id = Long.valueOf(values.get("language_id").toString()).longValue(); String value = values.get("value").toString(); if (authLevelManagement.checkAdminLevel(user_level)) { if (fieldvalues_id > 0 && fieldlanguagesvalues_id > 0) { log.error("UPDATE LABEL"); return fieldmanagment.updateLabel(fieldvalues_id, name, fieldlanguagesvalues_id, value); } else if (fieldvalues_id > 0 && fieldlanguagesvalues_id == 0) { log.error("INSERT NEW LABEL"); return fieldmanagment.addAndUpdateLabel(fieldvalues_id, name, value, language_id); } else { log.error("INSERT NEW FIELD AND LABEL"); return fieldmanagment.addFieldAndLabel(name, value, language_id); } } return new Long(-26); } catch (Exception e) { log.error("[saveOrUpdateLabel]", e); } return new Long(-1); }
From source file:com.opengamma.analytics.math.interpolation.data.Interpolator1DDataBundleBuilderFunction.java
public Interpolator1DDataBundleBuilderFunction(final LinkedHashMap<String, double[]> knotPoints, final LinkedHashMap<String, Interpolator1D> interpolators) { Validate.notNull(knotPoints, "null knot points"); Validate.notNull(interpolators, "null interpolators"); int count = 0; final Set<String> names = knotPoints.keySet(); for (final String name : names) { final int size = knotPoints.get(name).length; Validate.isTrue(size > 0, "no knot points for " + name); count += size;/*from w w w . ja va 2 s. c o m*/ } _knotPoints = knotPoints; _interpolators = interpolators; _nNodes = count; }
From source file:net.big_oh.resourcestats.dao.ResourceDAOIntegrationTest.java
/** * Test method for/*from ww w .j a v a 2 s . c o m*/ * {@link net.big_oh.resourcestats.dao.ResourceDAO#getMostPopularResources(int)} * . */ @Test public void testGetMostPopularResourcesInt() { try { sf.getCurrentSession().beginTransaction(); LinkedHashMap<Resource, Number> resources = dao.getMostPopularResources(5); assertNotNull(resources); for (Object key : resources.keySet()) { assertTrue(key instanceof Resource); Object value = resources.get(key); assertTrue(value instanceof Number); } // TODO DSW Provide improved assertions sf.getCurrentSession().getTransaction().commit(); } catch (Throwable t) { HibernateUtil.rollback(t, sf, log); throw new RuntimeException(t); } }
From source file:org.jutge.joc.porra.controller.base.BetController.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private Bet createBetInstanceByType(final LinkedHashMap map, final List errorMessages, final Locale locale) { final String betType = (String) map.get("tipus"); if (BetType.ROUNDS.name().equals(betType)) { final RoundsBet roundsBet = new RoundsBet(); final String roundsStr = (String) map.get("rondas"); try {// w ww . ja v a2 s . com final int rounds = Integer.parseInt(roundsStr); roundsBet.setEnduresRounds(rounds); } catch (final NumberFormatException exception) { final String message = this.messageSource.getMessage("exception.roundsFormat", null, locale); final MessageBox messageBox = new MessageBox("roundsFormat", message, new ArrayList<String>()); errorMessages.add(messageBox); } try { final String kudos = (String) map.get("kudos"); final Integer kudosInt = Integer.parseInt(kudos); if (roundsBet != null) { roundsBet.setKudos(kudosInt.doubleValue()); } } catch (NumberFormatException exception) { final String message = this.messageSource.getMessage("exception.kudosFormat", null, locale); final MessageBox messageBox = new MessageBox("kudosFormat", message, new ArrayList<String>()); errorMessages.add(messageBox); } return roundsBet; } else if (BetType.WINNER.name().equals(betType)) { return new WinnerBet(); } return null; }
From source file:net.big_oh.resourcestats.dao.ResourceDAOIntegrationTest.java
/** * Test method for//from ww w . j a v a 2s . c om * {@link net.big_oh.resourcestats.dao.ResourceDAO#getMostPopularResources(int, int)} * . */ @Test public void testGetMostPopularResourcesIntInt() { try { sf.getCurrentSession().beginTransaction(); LinkedHashMap<Resource, Number> resources = dao.getMostPopularResources(5, 7); assertNotNull(resources); for (Object key : resources.keySet()) { assertTrue(key instanceof Resource); Object value = resources.get(key); assertTrue(value instanceof Number); } // TODO DSW Provide improved assertions sf.getCurrentSession().getTransaction().commit(); } catch (Throwable t) { HibernateUtil.rollback(t, sf, log); throw new RuntimeException(t); } }
From source file:net.chris54721.infinitycubed.workers.PackLoader.java
@Override public void run() { try {// ww w . j a va 2 s . com LogHelper.info("Loading and updating modpacks"); String publicJson = Utils.toString(new URL(Reference.FILES_URL + "public.json")); Type stringIntMap = new TypeToken<LinkedHashMap<String, Integer>>() { }.getType(); LinkedHashMap<String, Integer> publicObjects = Reference.DEFAULT_GSON.fromJson(publicJson, stringIntMap); File localJson = new File(Resources.getFolder(Reference.PACKS_FOLDER), "public.json"); List<String> updatePacks = new ArrayList<String>(); if (localJson.isFile()) { String localPublicJson = Files.toString(localJson, Charsets.UTF_8); LinkedHashMap<String, Integer> localPublicObjects = Reference.DEFAULT_GSON.fromJson(localPublicJson, stringIntMap); for (String pack : publicObjects.keySet()) { if (!localPublicObjects.containsKey(pack) || !localPublicObjects.get(pack).equals(publicObjects.get(pack))) { updatePacks.add(pack); } } } else updatePacks.addAll(publicObjects.keySet()); Files.write(publicJson, localJson, Charsets.UTF_8); if (updatePacks.size() > 0) { for (String pack : updatePacks) { LogHelper.info("Updating JSON file for modpack " + pack); URL packJsonURL = Resources.getUrl(Resources.ResourceType.PACK_JSON, pack + ".json"); File packJsonFile = Resources.getFile(Resources.ResourceType.PACK_JSON, pack + ".json"); if (packJsonFile.isFile()) packJsonFile.delete(); Downloadable packJsonDownloadable = new Downloadable(packJsonURL, packJsonFile); if (!packJsonDownloadable.download()) LogHelper.error("Failed updating JSON for modpack " + pack); } } Collection<File> packJsons = FileUtils.listFiles(Resources.getFolder(Reference.DATA_FOLDER), new String[] { "json" }, false); for (File packJsonFile : packJsons) loadPack(FilenameUtils.getBaseName(packJsonFile.getName())); } catch (Exception e) { LogHelper.fatal("Failed updating and loading public packs", e); } }
From source file:com.opengamma.analytics.financial.curve.sensitivity.ParameterSensitivity.java
/** * Create a copy of the sensitivity and add a given named sensitivity to it. If the name / currency pair is in the map, the two sensitivity matrices are added. * Otherwise, a new entry is put into the map * @param nameCcy The name and the currency, not null * @param sensitivity The sensitivity to add, not null * @return The total sensitivity.//from ww w.j a va 2 s . co m */ public ParameterSensitivity plus(final Pair<String, Currency> nameCcy, final DoubleMatrix1D sensitivity) { ArgumentChecker.notNull(nameCcy, "Name/currency"); ArgumentChecker.notNull(sensitivity, "Matrix"); final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA; final LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D> result = new LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D>(); result.putAll(_sensitivity); if (result.containsKey(nameCcy)) { result.put(nameCcy, (DoubleMatrix1D) algebra.add(result.get(nameCcy), sensitivity)); } else { result.put(nameCcy, sensitivity); } return new ParameterSensitivity(result); }
From source file:org.openmeetings.app.remote.LdapConfigService.java
/** * // w ww . jav a 2 s.c o m * @param SID * @param values * @return */ public Long saveOrUpdateLdapConfig(String SID, LinkedHashMap<Object, Object> values) { try { Long users_id = sessionManagement.checkSession(SID); Long user_level = userManagement.getUserLevelByID(users_id); if (authLevelManagement.checkAdminLevel(user_level)) { Long ldapConfigId = Long.valueOf(values.get("ldapConfigId").toString()).longValue(); Boolean addDomainToUserName = Boolean.valueOf(values.get("addDomainToUserName").toString()) .booleanValue(); String configFileName = values.get("configFileName").toString(); String name = values.get("tName").toString(); String domain = values.get("domain").toString(); Boolean isActive = Boolean.valueOf(values.get("isActive").toString()).booleanValue(); if (ldapConfigId <= 0) { return this.ldapConfigDaoImpl.addLdapConfig(name, addDomainToUserName, configFileName, domain, users_id, isActive); } else { return this.ldapConfigDaoImpl.updateLdapConfig(ldapConfigId, name, addDomainToUserName, configFileName, domain, users_id, isActive); } } return new Long(-26); } catch (Exception e) { log.error("[saveOrUpdateLdapConfig]", e); } return new Long(-1); }