List of usage examples for java.util HashMap get
public V get(Object key)
From source file:ch.devmine.javaparser.Main.java
private static void parseAndFillSourceFile(Parser parser, SourceFile sourceFile, String javaFile, Language language, HashMap<String, Package> packs, String packName) { try {//from ww w. jav a2 s .c o m parser.parse(); if (!parser.isPackageInfo()) { sourceFile.setPath(javaFile); sourceFile.setLanguage(language); sourceFile.setImports(parser.getImports()); sourceFile.setInterfaces(parser.getInterfaces()); sourceFile.setClasses(parser.getClasses()); sourceFile.setEnums(parser.getEnums()); sourceFile.setLoc(parser.getLoc()); packs.get(packName).getSourceFiles().add(sourceFile); } else { packs.get(packName).setDoc(parser.getPackageInfoComments()); } } catch (ParseException ex) { Log.e(TAG, "File skipped, error : ".concat(ex.getMessage())); } catch (FileNotFoundException ex) { Log.e(TAG, ex.getMessage()); } }
From source file:com.clustercontrol.jobmanagement.util.JobMultiplicityCache.java
/** * status?100(StatusConstant.TYPE_RUNNING)???????????? * * ???runningQueue???????/* w ww . j a v a 2 s. com*/ * ?????????????kick * @param pk */ public static boolean fromRunning(JobSessionNodeEntityPK pk) { m_log.info("fromRunning " + pk); String facilityId = pk.getFacilityId(); try { _lock.writeLock(); HashMap<String, Queue<JobSessionNodeEntityPK>> runningCache = getRunningCache(); Queue<JobSessionNodeEntityPK> runningQueue = runningCache.get(facilityId); if (runningQueue == null) { m_log.warn("fromRunning " + pk); return false; } if (runningQueue.remove(pk)) { //// runningQueue? storeRunningCache(runningCache); } else { // ???????? // (??)?????????? m_log.info("fromRunning(). from not-running to stop : " + pk); } if (m_log.isDebugEnabled()) { for (JobSessionNodeEntityPK q : runningQueue) { m_log.debug("fromRunning runningQueue : " + q); } } // ?facilityID????? kick(facilityId); } finally { _lock.writeUnlock(); } return true; }
From source file:edu.utexas.cs.tactex.utils.BrokerUtils.java
/** * creates a copy of the map, but where keys are Double * instead of Integer. // w ww.j a v a2 s .c o m * * @param customer2tariffSubscriptions * @return * */ public static HashMap<CustomerInfo, HashMap<TariffSpecification, Double>> initializePredictedFromCurrentSubscriptions( HashMap<CustomerInfo, HashMap<TariffSpecification, Integer>> customer2tariffSubscriptions) { HashMap<CustomerInfo, HashMap<TariffSpecification, Double>> predicted = new HashMap<CustomerInfo, HashMap<TariffSpecification, Double>>(); for (CustomerInfo customer : customer2tariffSubscriptions.keySet()) { HashMap<TariffSpecification, Integer> oldmap = customer2tariffSubscriptions.get(customer); HashMap<TariffSpecification, Double> newmap = initializeDoubleSubsMap(oldmap); // copy construct predicted.put(customer, newmap); } return predicted; }
From source file:com.ikon.dao.HibernateUtil.java
/** * Load specific database import/*from w ww . ja v a2 s . c om*/ */ private static void executeImport(final Reader rd) { Session session = null; Transaction tx = null; try { session = sessionFactory.openSession(); tx = session.beginTransaction(); session.doWork(new Work() { @Override public void execute(Connection con) throws SQLException { try { for (HashMap<String, String> error : LegacyDAO.executeScript(con, rd)) { log.error("Error during import script execution at line {}: {} [ {} ]", new Object[] { error.get("ln"), error.get("msg"), error.get("sql") }); } } catch (IOException e) { log.error(e.getMessage(), e); } finally { IOUtils.closeQuietly(rd); } } }); commit(tx); } catch (Exception e) { rollback(tx); log.error(e.getMessage(), e); } }
From source file:models.NotificationMail.java
/** * Sends notification mails for the given event. * * @param event/*w w w. jav a 2 s.co m*/ * @see <a href="https://github.com/nforge/yobi/blob/master/docs/technical/watch.md>watch.md</a> */ private static void sendNotification(NotificationEvent event) { Set<User> receivers = event.receivers; // Remove inactive users. Iterator<User> iterator = receivers.iterator(); while (iterator.hasNext()) { User user = iterator.next(); if (user.state != UserState.ACTIVE) { iterator.remove(); } } receivers.remove(User.anonymous); if (receivers.isEmpty()) { return; } HashMap<String, List<User>> usersByLang = new HashMap<>(); for (User receiver : receivers) { String lang = receiver.lang; if (lang == null) { lang = Locale.getDefault().getLanguage(); } if (usersByLang.containsKey(lang)) { usersByLang.get(lang).add(receiver); } else { usersByLang.put(lang, new ArrayList<>(Arrays.asList(receiver))); } } for (String langCode : usersByLang.keySet()) { final EventEmail email = new EventEmail(event); try { if (hideAddress) { email.setFrom(Config.getEmailFromSmtp(), event.getSender().name); email.addTo(Config.getEmailFromSmtp(), utils.Config.getSiteName()); } else { email.setFrom(event.getSender().email, event.getSender().name); } for (User receiver : usersByLang.get(langCode)) { if (hideAddress) { email.addBcc(receiver.email, receiver.name); } else { email.addTo(receiver.email, receiver.name); } } if (email.getToAddresses().isEmpty()) { continue; } Lang lang = Lang.apply(langCode); String message = event.getMessage(lang); String urlToView = event.getUrlToView(); String reference = Url.removeFragment(event.getUrlToView()); email.setSubject(event.title); Resource resource = event.getResource(); if (resource.getType() == ResourceType.ISSUE_COMMENT) { IssueComment issueComment = IssueComment.find.byId(Long.valueOf(resource.getId())); resource = issueComment.issue.asResource(); } email.setHtmlMsg(getHtmlMessage(lang, message, urlToView, resource)); email.setTextMsg(getPlainMessage(lang, message, Url.create(urlToView))); email.setCharset("utf-8"); email.addReferences(); email.setSentDate(event.created); Mailer.send(email); String escapedTitle = email.getSubject().replace("\"", "\\\""); String logEntry = String.format("\"%s\" %s", escapedTitle, email.getBccAddresses()); play.Logger.of("mail").info(logEntry); } catch (Exception e) { Logger.warn("Failed to send a notification: " + email + "\n" + ExceptionUtils.getStackTrace(e)); } } }
From source file:com.ciphertool.sentencebuilder.dao.IndexedWordMapDao.java
/** * @param allWords/* w w w.ja v a2s . c o m*/ * the List of all Words pulled in from the constructor * @return a Map of all Words keyed by their PartOfSpeech */ protected static Map<PartOfSpeechType, ArrayList<Word>> mapByPartOfSpeech(List<Word> allWords) { if (allWords == null || allWords.isEmpty()) { throw new IllegalArgumentException( "Error mapping Words by PartOfSpeech. The supplied List of Words cannot be null or empty."); } HashMap<PartOfSpeechType, ArrayList<Word>> byPartOfSpeech = new HashMap<PartOfSpeechType, ArrayList<Word>>(); for (Word word : allWords) { PartOfSpeechType pos = word.getId().getPartOfSpeech(); // Add the part of speech to the map if it doesn't exist if (!byPartOfSpeech.containsKey(pos)) { byPartOfSpeech.put(pos, new ArrayList<Word>()); } byPartOfSpeech.get(pos).add(word); } return byPartOfSpeech; }
From source file:de.tudarmstadt.ukp.dkpro.tc.core.util.ReportUtils.java
/** * Creates a confusion matrix by collecting the results from the overall CV run stored in * {@code tempM}/*from www .j a v a 2 s .c o m*/ * * @param tempM * @param actualLabelsList * the label powerset transformed list of actual/true labels * @param predictedLabelsList * the label powerset transformed list of predicted labels * @return */ public static double[][] createConfusionMatrix(HashMap<String, Map<String, Integer>> tempM, List<String> actualLabelsList, List<String> predictedLabelsList) { double[][] matrix = new double[actualLabelsList.size()][predictedLabelsList.size()]; Iterator<String> actualsIter = tempM.keySet().iterator(); while (actualsIter.hasNext()) { String actual = actualsIter.next(); Iterator<String> predsIter = tempM.get(actual).keySet().iterator(); while (predsIter.hasNext()) { String pred = predsIter.next(); int a = actualLabelsList.indexOf(actual); int p = predictedLabelsList.indexOf(pred); matrix[a][p] = tempM.get(actual).get(pred); } } return matrix; }
From source file:eu.eexcess.ddb.recommender.PartnerConnector.java
/** * Opens a HTTP connection, gets the response and converts into to a String. * /*w w w . j av a2 s.com*/ * @param urlStr Servers URL * @param properties Keys and values for HTTP request properties * @return Servers response * @throws IOException If connection could not be established or response code is !=200 */ public static String httpGet(String urlStr, HashMap<String, String> properties) throws IOException { if (properties == null) { properties = new HashMap<String, String>(); } // open HTTP connection with URL URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); // set properties if any do exist for (String key : properties.keySet()) { conn.setRequestProperty(key, properties.get(key)); } // test if request was successful (status 200) if (conn.getResponseCode() != 200) { throw new IOException(conn.getResponseMessage()); } // buffer the result into a string InputStreamReader isr = new InputStreamReader(conn.getInputStream(), "UTF-8"); BufferedReader br = new BufferedReader(isr); StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { sb.append(line); } br.close(); isr.close(); conn.disconnect(); return sb.toString(); }
From source file:fr.mixit.android.utils.NetworkUtils.java
static String buildParams(HashMap<String, String> args) { if (args != null && !args.isEmpty()) { final StringBuilder params = new StringBuilder(); final Set<String> keys = args.keySet(); for (final Iterator<String> iterator = keys.iterator(); iterator.hasNext();) { final String key = iterator.next(); final String value = args.get(key); params.append(key);//w ww. j a va2s .c om params.append(EQUAL); params.append(value); if (iterator.hasNext()) { params.append(AND); } } return params.toString(); } return null; }
From source file:es.pode.soporte.auditoria.registrar.Registrar.java
/** * A partir de los datos enviados se recupera el tipo de bsqueda avanzada, simple, rbol curricular y tesauro * @param tabla Son los datos interceptados en formato HashMap * @return valores Los valores interceptados en formato String * /*from ww w. j a va 2 s.c om*/ */ private static String getValoresInterceptados(HashMap tabla) { StringBuffer valores = new StringBuffer(); try { for (Iterator it = tabla.keySet().iterator(); it.hasNext();) { String s = (String) it.next(); String s1 = (String) tabla.get(s); valores.append(s + ": " + s1 + " "); } } catch (Exception e) { log.error("Error captura valores interceptados: " + e); valores.append(VACIO); } return valores.toString(); }