List of usage examples for java.util Hashtable size
public synchronized int size()
From source file:org.kepler.kar.KARBuilder.java
private void addEntriesToPrivateItems(Hashtable<KAREntry, InputStream> entries) { if (isDebugging) log.debug("addEntriesToPrivateItems(" + entries.size() + ")"); for (KAREntry karEntryKey : entries.keySet()) { _karItems.put(karEntryKey, entries.get(karEntryKey)); _karItemLSIDs.add(karEntryKey.getLSID()); _karItemNames.add(karEntryKey.getName()); }/*from ww w . jav a2 s .c om*/ }
From source file:imapi.IMAPIClass.java
public void printResultInstances(Hashtable<Float, Vector<ResultSourceTargetPair>> resultInstances) { int resultsCounter = 0; if (resultInstances.size() == 0) { System.out.println("0 results found."); } else {// www . j av a 2s. c o m Vector<Float> sortBySimilarityVec = new Vector<Float>(resultInstances.keySet()); Collections.sort(sortBySimilarityVec); Collections.reverse(sortBySimilarityVec); for (int i = 0; i < sortBySimilarityVec.size(); i++) { float sim = sortBySimilarityVec.get(i); Vector<ResultSourceTargetPair> stPairs = resultInstances.get(sim); Collections.sort(stPairs); for (int k = 0; k < stPairs.size(); k++) { ResultSourceTargetPair resultInfo = stPairs.get(k); SourceTargetPair pair = resultInfo.getSourceTargetPair(); SequenceSimilarityResultVector tripVec = resultInfo.getSimilarityResultsVector(); System.out.println((++resultsCounter) + ".\t" + Utilities.df.format(sim) + "\t" + pair.getSourceInstance().getSourceName() + " " + pair.getSourceInstance().getInstanceUri() + " " + pair.getTargetInstance().getSourceName() + " " + pair.getTargetInstance().getInstanceUri()); //check if uri similarity is encoutered if (pair.getSourceInstance().getInstanceUri() .equals(pair.getTargetInstance().getInstanceUri())) { System.out.println("\t\t\turi similarity 1\n"); continue; } else { this.printSimilaritiesData(tripVec); } System.out.println(); } } } }
From source file:org.hyperic.hq.bizapp.server.session.EmailManagerImpl.java
@SuppressWarnings("unchecked") public void sendFiltered(Integer platId) { Hashtable<EmailRecipient, FilterBuffer> cache; synchronized (_alertBuffer) { if (!_alertBuffer.containsKey(platId)) { return; }/*from w w w. j ava 2 s. c om*/ cache = (Hashtable<EmailRecipient, FilterBuffer>) _alertBuffer.remove(platId); if (cache == null || cache.size() == 0) { return; } // Insert key again so that we continue filtering _alertBuffer.put(platId, null); } AppdefEntityID platEntId = AppdefEntityID.newPlatformID(platId); String platName = resourceManager.getAppdefEntityName(platEntId); // The cache is organized by addresses for (Entry<EmailRecipient, FilterBuffer> ent : cache.entrySet()) { EmailRecipient addr = (EmailRecipient) ent.getKey(); FilterBuffer msg = (FilterBuffer) ent.getValue(); if (msg.getNumEnts() == 1 && addr.useHtml()) { sendEmail(new EmailRecipient[] { addr }, "[HQ] Filtered Notifications for " + platName, new String[] { "" }, new String[] { msg.getHtml() }, null); } else { addr.setHtml(false); sendEmail(new EmailRecipient[] { addr }, "[HQ] Filtered Notifications for " + platName, new String[] { msg.getText() }, new String[] { "" }, null); } } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.fileprofile.FileProfileMainHandler.java
/** * Before being able to create a File Profile, certain objects must exist. * Check that here./*from w ww . ja v a 2 s . c o m*/ */ private void checkPreReqData(HttpServletRequest p_request, HttpSession p_session, Hashtable p_l10nProfilePairs) throws EnvoyServletException { if (p_l10nProfilePairs == null || p_l10nProfilePairs.size() < 1) { ResourceBundle bundle = getBundle(p_session); StringBuffer message = new StringBuffer(); message.append(bundle.getString("msg_prereq_warning_1")); message.append(": "); message.append(bundle.getString("lb_loc_profile")); message.append(". "); message.append(bundle.getString("msg_prereq_warning_2")); p_request.setAttribute("preReqData", message.toString()); } }
From source file:org.apache.usergrid.apm.service.charts.service.CommonStrategy.java
public List<NetworkMetricsChartDTO> compileChartDataWithGrouping( List<? extends CompactNetworkMetrics> cachedMetrics, List<? extends CompactNetworkMetrics> freshMetrics, MetricsChartCriteria cq) {/*from w w w . j a va 2 s.co m*/ Hashtable<String, Integer> groupIndex = getChartGroups(cachedMetrics, cq); //We need to do this because there could be new group such as Sprint network while cached ones only has ATT and Verizon Hashtable<String, Integer> groupIndexFresh = getChartGroups(freshMetrics, cq); Enumeration<String> keys = groupIndexFresh.keys(); while (keys.hasMoreElements()) { String temp = keys.nextElement(); if (!groupIndex.containsKey(temp)) groupIndex.put(temp, groupIndex.size()); } log.info("Total number of chart groups " + groupIndex.size()); //TODO: There probably is a better way List<NetworkMetricsChartDTO> charts = new ArrayList<NetworkMetricsChartDTO>(groupIndex.size()); for (int i = 0; i < groupIndex.size(); i++) { charts.add(new NetworkMetricsChartDTO()); } keys = groupIndex.keys(); String key; NetworkMetricsChartDTO dto; while (keys.hasMoreElements()) { key = keys.nextElement(); dto = charts.get(groupIndex.get(key)); dto.setChartGroupName(key); } populateUIChartDataWithGroup(charts, cachedMetrics, groupIndex, cq); populateUIChartDataWithGroup(charts, freshMetrics, groupIndex, cq); return charts; }
From source file:es.itecban.deployment.executionmanager.DefaultPlanExecutor.java
public ExecutionReportType launchPlan(DeploymentPlanType plan) throws Exception { boolean assetCheckActive = this.isAssetCheckingActive(plan.getEnvironment()); if (assetCheckActive) { Hashtable<String, DeploymentUnitType> notApprovedAssetsHs = null; try {//from ww w. java 2s . c o m // Validate with the RAM if each asset in the plan is approved notApprovedAssetsHs = this.ramManager.validateAssetInPlan(plan); } catch (ServiceUnavailableException e) { logger.info("Error ocurred while communicating with the RAM. " + "Maybe this module is not available as it is optional "); } if (notApprovedAssetsHs != null && notApprovedAssetsHs.size() != 0) { // String messageError = "The following resource is not approved in the " // + "Rational Asset Manager "; // Show only the first in the collection not approved Set<String> notApprovedAssetsSet = notApprovedAssetsHs.keySet(); for (String notApprovedAsset : notApprovedAssetsSet) { // messageError = messageError // + "\r\n" // + notApprovedAsset // + " in component " // + notApprovedAssetsHs.get(notApprovedAsset) // .getName() // + " version_" // + notApprovedAssetsHs.get(notApprovedAsset) // .getVersion(); // not tested throw new MessageException("running.error.assetNotApproved", notApprovedAsset, notApprovedAssetsHs.get(notApprovedAsset).getName(), notApprovedAssetsHs.get(notApprovedAsset).getVersion()); } } } // If here, all the validations has gone succesfully ExecutionReportType report = null; try { report = executorService.launchPlan(plan); if (report == null) throw new Exception("running.error.problemPlan"); } catch (Exception e) { logger.severe("Error launching the plan." + e.getMessage()); throw new Exception(e.getMessage()); } // Set the report launcher user if (report.getResult().equals(PlanResultKindType.OK) && assetCheckActive) { try { this.ramManager.changeDeployedAssetStatus(plan); logger.info("Plan result: " + report.getResult() + ". Changes done in the RAM to the status of the assets"); } catch (ServiceUnavailableException e) { logger.info("Error ocurred while communicating with the RAM. " + "Maybe this module is not available as it is optional "); } } else { logger.info( "Plan result: " + report.getResult() + ". No changes done in RAM to the status of the assets"); } String planName = plan.getName(); String creationUser = planName.split("\\|")[3]; report.setCreationUserId(creationUser); report.setLauncherUserId(AuthenticationManager.getUserName()); reportManager.setCreationUserId(report.getPlanId(), report.getStartTime(), creationUser); reportManager.setLauncherUserId(report.getPlanId(), report.getStartTime(), AuthenticationManager.getUserName()); return report; }
From source file:com.macrosoft.core.orm.hibernate.SimpleHibernateDao.java
/** * ?HQL?Query./*from w w w .j a va 2s . co m*/ * * ?find()T,?T. * * @param values ????,?. */ public Query createQuery(final String queryString, final Object... values) { Assert.hasText(queryString, "queryString?"); Query query = getSession().createQuery(queryString); if (values != null && values.length > 0) { if (values[0] instanceof Hashtable) { Hashtable temp = (Hashtable) values[0]; query = setParamHash(query, temp); } else { if (values[0] instanceof List) { List temp = (List) values[0]; int size = temp.size(); for (int i = 0; i < size; i++) { Object param = temp.get(i); //query.setParameter(i,values[i]); if (param instanceof String) { String paramValue = (String) param; query.setString(i, paramValue); } else { if (param instanceof Integer) { Integer paramValue = (Integer) param; query.setInteger(i, paramValue.intValue()); } else { if (param instanceof Long) { Long paramValue = (Long) param; query.setLong(i, paramValue.longValue()); } else { if (param instanceof Double) { Double paramValue = (Double) param; query.setDouble(i, paramValue.doubleValue()); } else { if (param instanceof Float) { Float paramValue = (Float) param; query.setFloat(i, paramValue.floatValue()); } } } } } } } else { for (int i = 0; i < values.length; i++) { query.setParameter(i, values[i]); } } } } return query; }
From source file:press.gfw.Server.java
/** * //w w w. ja v a 2s.c om */ public void service() { if (System.currentTimeMillis() - lockFile.lastModified() < 30 * 000L) { log("???"); log("? " + lockFile.getAbsolutePath() + "??"); return; } try { lockFile.createNewFile(); } catch (IOException ioe) { } lockFile.deleteOnExit(); log("GFW.Press??......"); log("?" + proxyHost); log("??" + proxyPort); Hashtable<String, String> users = null; // Hashtable<String, Server> threads = new Hashtable<String, Server>(); // while (true) { lockFile.setLastModified(System.currentTimeMillis()); _sleep(20 * 1000L); // ?20 users = config.getUser(); // ? if (users == null || users.size() == 0) { continue; } Enumeration<String> threadPorts = threads.keys(); // ? while (threadPorts.hasMoreElements()) { // ??? String threadPort = threadPorts.nextElement(); String userPassword = users.remove(threadPort); if (userPassword == null) { // threads.remove(threadPort).kill(); log("?" + threadPort); } else { Server thread = threads.get(threadPort); if (!userPassword.equals(thread.getPassword())) { // ? log("??" + threadPort); threads.remove(threadPort); thread.kill(); thread = new Server(proxyHost, proxyPort, threadPort, userPassword); threads.put(threadPort, thread); thread.start(); } } } Enumeration<String> userPorts = users.keys(); while (userPorts.hasMoreElements()) { // String userPort = userPorts.nextElement(); Server thread = new Server(proxyHost, proxyPort, userPort, users.get(userPort)); threads.put(userPort, thread); thread.start(); } users.clear(); } }
From source file:edu.harvard.i2b2.analysis.security.HighEncryption.java
public HighEncryption(String inFileName, Hashtable keys) throws Exception { String key = null;/* ww w.ja v a 2 s .c o m*/ // makearray64(); // create the array regardless of how key will be acquired AHA@20011016 if ((keys != null) && (keys.size() > 0)) key = keys.get(inFileName).toString(); if ((key == null) || (key.length() == 0)) { byte baBuffer[] = new byte[2056]; try { FileInputStream oFileIn = new FileInputStream(inFileName); //int iBytes = oFileIn.read(baBuffer,0,2056); String sString = new String(baBuffer); //new String(baBuffer,0,0,iBytes); key = sString; } catch (FileNotFoundException fnfe) { log.fatal("HighEncryption initialization file-not-found error"); throw new Exception("HighEncryption initialization error"); } catch (Exception e) { log.fatal("HighEncryption initialization error"); throw new Exception("HighEncryption initialization error"); } } try { key = key.trim(); cipher = new RijndaelAlgorithm(key, 128); //, "AES"); //long version for dates } catch (Exception ex) { //Lib.TError("HighEncryption initialization error"); ex.printStackTrace(); throw new Exception("HighEncryption initialization error"); } }
From source file:edu.harvard.i2b2.frclient.security.HighEncryption.java
public HighEncryption(String inFileName, Hashtable keys) throws Exception { String key = null;/*from w w w .j a v a2s . co m*/ // makearray64(); // create the array regardless of how key will be acquired AHA@20011016 if ((keys != null) && (keys.size() > 0)) key = keys.get(inFileName).toString(); if ((key == null) || (key.length() == 0)) { byte baBuffer[] = new byte[2056]; try { FileInputStream oFileIn = new FileInputStream(inFileName); int iBytes = oFileIn.read(baBuffer, 0, 2056); String sString = new String(baBuffer); //new String(baBuffer,0,0,iBytes); key = sString; } catch (FileNotFoundException fnfe) { log.fatal("HighEncryption initialization file-not-found error"); throw new Exception("HighEncryption initialization error"); } catch (Exception e) { log.fatal("HighEncryption initialization error"); throw new Exception("HighEncryption initialization error"); } } try { key = key.trim(); cipher = new RijndaelAlgorithm(key, 128); //, "AES"); //long version for dates } catch (Exception ex) { //Lib.TError("HighEncryption initialization error"); ex.printStackTrace(); throw new Exception("HighEncryption initialization error"); } }