List of usage examples for java.util HashSet size
public int size()
From source file:dk.dma.ais.analysis.viewer.rest.VesselListFilter.java
public VesselListFilter(QueryParams request) { for (String filterName : filterNames) { if (request.containsKey(filterName)) { HashSet<String> values = new HashSet<String>(); String[] arr = StringUtils.split(request.getFirst(filterName), ","); for (String value : arr) { values.add(value);/* w w w. j a va 2s. c om*/ } if (values.size() > 0) { filterMap.put(filterName, values); } } } }
From source file:com.fstx.stdlib.author.old.AuthorizationManagerTest.java
public void testRemoveAuthorizationBean() throws AuthorizationException { AuthorizationBean ab = AuthorizationManager.singleton.getAuthorizationBean("Nicholas"); HashSet myRights = ab.getRights(); assertEquals(myRights.size(), 4); assertTrue(myRights.contains("right1")); assertTrue(myRights.contains("right2")); assertTrue(myRights.contains("right3")); assertTrue(myRights.contains("Otherright2")); assertTrue(AuthorizationManager.singleton.removeAuthorizationBean("Nicholas")); // Should be getting from the builder again. AuthorizationBean ab2 = AuthorizationManager.singleton.getAuthorizationBean("Nicholas"); HashSet myRights2 = ab2.getRights(); assertEquals(myRights2.size(), 4);/* w ww . j a v a2s .c om*/ assertTrue(myRights2.contains("right1")); assertTrue(myRights2.contains("right2")); assertTrue(myRights2.contains("right3")); assertTrue(myRights2.contains("Otherright2")); }
From source file:com.ubershy.streamsis.project.SisScene.java
@Override public void init() { elementInfo.setAsReadyAndHealthy();/*from w ww. ja va2 s .co m*/ if ("".equals(elementInfo.getName())) { elementInfo.setAsBroken("SisScene's name cannot be empty"); return; } if (actorNames.contains(null)) { elementInfo.setAsBroken("SisScene can't have null in the list of Actor names"); return; } if (!actorNames.isEmpty()) { HashSet<String> uniqueNames = new HashSet<String>(actorNames); if (actorNames.size() != uniqueNames.size()) { elementInfo.setAsBroken("SisScene can't have duplicate Actor names"); } } }
From source file:org.apache.james.transport.mailets.HeadersToHTTP.java
/** * Takes the message, serialises it and sends it to the URL * /*from w w w .j a v a 2s. c om*/ * @param mail * the mail being processed * */ public void service(Mail mail) { try { log(mail.getName() + "HeadersToHTTP: Starting"); MimeMessage message = mail.getMessage(); HashSet<NameValuePair> pairs = getNameValuePairs(message); log(mail.getName() + "HeadersToHTTP: " + pairs.size() + " named value pairs found"); String result = httpPost(pairs); if (passThrough) { addHeader(mail, true, result); } else { mail.setState(Mail.GHOST); } } catch (javax.mail.MessagingException me) { log(me.getMessage()); addHeader(mail, false, me.getMessage()); } catch (IOException e) { log(e.getMessage()); addHeader(mail, false, e.getMessage()); } }
From source file:com.fstx.stdlib.author.old.AuthorizationManagerTest.java
public void testGetAuthorizationBean() throws AuthorizationException { //Puts the Bean into the hash. AuthorizationBean ab = AuthorizationManager.singleton.getAuthorizationBean("Nicholas"); HashSet myRights = ab.getRights(); assertEquals(myRights.size(), 4); assertTrue(ab.isAuthorized("right1")); assertTrue(ab.isAuthorized("right2")); assertTrue(ab.isAuthorized("right3")); assertTrue(ab.isAuthorized("Otherright2")); // Should be getting from the hash rather than the Builder AuthorizationBean ab2 = AuthorizationManager.singleton.getAuthorizationBean("Nicholas"); HashSet myRights2 = ab2.getRights(); assertEquals(myRights2.size(), 4);//from w ww . ja v a 2 s . com assertTrue(ab2.isAuthorized("right1")); assertTrue(ab2.isAuthorized("right2")); assertTrue(ab2.isAuthorized("right3")); assertTrue(ab2.isAuthorized("Otherright2")); AuthorizationBean ab3 = AuthorizationManager.singleton.getAuthorizationBean("Jose"); HashSet myRights3 = ab3.getRights(); assertEquals(myRights3.size(), 3); assertTrue(ab3.isAuthorized("right1")); assertTrue(ab3.isAuthorized("right2")); assertTrue(ab3.isAuthorized("right3")); }
From source file:crossspectrumapp.CrossSpectrumApp.java
private void doPlot() throws SQLException, LdvTableException, ViewConfigException, WebUtilException { HashSet<Integer> selections = getSelections(); if (selections.size() < 2) { System.err.println("We need 2 channels to calculate Cross Spectrum."); } else {/*w w w . j ava 2 s. c om*/ ArrayList<TimeInterval> times = getTimes(); ArrayList<ChanDataBuffer> data = getData(selections, times); dataTransferEnd = System.currentTimeMillis(); if (data.size() != 2) { System.err.println("We need 2 channels to calculate Cross Spectrum."); } else { float fftlen = cscl.getSecPerFFT(); float ovlap = cscl.getOverlap(); double[] power = null; double[] phase = null; double[] frequency = null; CrossSpectrum crossSpectrum = null; try { crossSpectrum = new CrossSpectrum(); Object[] results = crossSpectrum.crossSpectrum(3, data.get(0).getData(), data.get(0).getChanInfo().getRate(), data.get(1).getData(), data.get(1).getChanInfo().getRate(), fftlen, ovlap); power = ((MWNumericArray) results[0]).getDoubleData(); phase = ((MWNumericArray) results[1]).getDoubleData(); frequency = ((MWNumericArray) results[2]).getDoubleData(); } catch (MWException ex) { Logger.getLogger(CrossSpectrumApp.class.getName()).log(Level.SEVERE, null, ex); } finally { // release native resources (MCR stuff) that were allocated by object creation if (crossSpectrum != null) { crossSpectrum.dispose(); } } if (power != null && phase != null && frequency != null) { ChanInfo ci1 = data.get(0).getChanInfo(); ChanInfo ci2 = data.get(1).getChanInfo(); String subTitle1 = String.format("%1$s (%2$.0fHz) vs. %3$s (%4$.0f)", ci1.getChanName(), ci1.getRate(), ci2.getChanName(), ci2.getRate()); long startGps = times.get(0).getStartGps(); String startStr = TimeAndDate.gpsAsUtcString(startGps); String subTitle2 = String.format("%1$s (%2$d) t=%3$ds", startStr, startGps, times.get(0).getStopGps() - times.get(0).getStartGps()); plotData(frequency, power, phase, "Cross spectrum", subTitle1, subTitle2); } } } }
From source file:org.nuxeo.connect.update.standalone.registry.SharedFilesTest.java
protected void ensureFiles(String... names) throws Exception { HashSet<String> set = new HashSet<String>(Arrays.asList(bundles.list())); assertEquals("Number of files in " + bundles.toString(), names.length, set.size()); for (String name : names) { assertTrue("Missing file: " + name, set.contains(name)); }//from w ww. j a va 2s .co m for (String name : names) { assertEquals("Wrong file content for " + name, name, FileUtils.readFile(new File(bundles, name))); } }
From source file:org.apache.solr.analytics.AbstractAnalyticsStatsTest.java
public <T extends Comparable<T>> Object calculateStat(ArrayList<T> list, String stat) { Object result;/*from ww w. j av a2 s.co m*/ if (stat.contains("perc_")) { double[] perc = new double[] { Double.parseDouble(stat.substring(5)) / 100 }; result = PercentileCalculator.getPercentiles(list, perc).get(0); } else if (stat.equals("count")) { result = Long.valueOf(list.size()); } else if (stat.equals("unique")) { HashSet<T> set = new HashSet<>(); set.addAll(list); result = Long.valueOf((long) set.size()); } else if (stat.equals("max")) { Collections.sort(list); result = list.get(list.size() - 1); } else if (stat.equals("min")) { Collections.sort(list); result = list.get(0); } else { result = null; } return result; }
From source file:importer.handler.post.stages.Splitter.java
/** * Convert a hashset of versions to a string * @param set the set of version names//from ww w .j ava 2 s . c o m * @return a simple space-delimited string */ private String hashsetToString(HashSet<String> set) { StringBuilder sb = new StringBuilder(); if (set.size() > 0) { sb.append(" "); Iterator<String> iter = set.iterator(); while (iter.hasNext()) { sb.append(iter.next()); if (iter.hasNext()) sb.append(" "); } } return sb.toString(); }
From source file:cc.kave.commons.model.groum.SubGroum.java
private Node findRoot() { HashSet<Node> candidates = new HashSet<>(nodes); for (Node node : nodes) { Set<Node> successors = getSuccessors(node); candidates.removeAll(successors); }//from w w w . j a va 2s. c om if (candidates.size() == 1) { return candidates.iterator().next(); } else { throw new IllegalStateException( "Groum has no uniquly identifiable root (candidates: " + candidates + ")"); } }