List of usage examples for java.util SortedSet size
int size();
From source file:xbird.xquery.misc.PagedStringChunk2.java
private byte[] readv(final long addr, final SerializationContext serContext) { SortedSet<Long> tails = serContext.textBufferAddresses().tailSet(addr); int nPages = Math.min(tails.size(), 16); // minimum 16 MB final long[] addrs; if (nPages == 0) { addrs = new long[] { addr }; } else {/*from w w w.j av a2s . c o m*/ addrs = new long[nPages]; int n = 0; for (long l : tails) { addrs[n++] = l; if (n == nPages) { break; } } } final byte[][] tmp; try {// read from disk tmp = paged_.readv(addrs); } catch (IOException e) { throw new IllegalStateException("read from disk failed", e); } for (int i = 1; i < nPages; i++) { char[] cc = _compressor.decompressAsChars(tmp[i]); long tmpAddr = addrs[i]; _referenceMap.put(tmpAddr, cc); } return tmp[0]; }
From source file:org.jasig.ssp.web.api.PersonController.java
@RequestMapping(value = "/currentCoachesLite", method = RequestMethod.GET) @PreAuthorize("hasRole('ROLE_PERSON_READ') or hasRole('ROLE_PERSON_FILTERED_READ')") public @ResponseBody PagedResponse<PersonLiteTO> getAllCurrentCoaches() { final SortedSet<CoachPersonLiteTO> coaches = service .getAllCurrentCoachesLite(CoachPersonLiteTO.COACH_PERSON_LITE_TO_NAME_AND_ID_COMPARATOR); return new PagedResponse<PersonLiteTO>(true, new Long(coaches.size()), PersonLiteTO.toTOListFromCoachTOs(coaches)); }
From source file:org.eclipse.jubula.client.core.model.TestDataPO.java
/** * {@inheritDoc}/* w w w . ja va 2 s . c om*/ * @return */ public String toString() { SortedSet<String> sorter = new TreeSet<String>(); for (Entry<String, String> entry : getMap().entrySet()) { sorter.add(entry.getKey() + StringConstants.COLON + entry.getValue()); } StringBuilder result = new StringBuilder(sorter.size() * 100); for (String line : sorter) { result.append(line); result.append(StringConstants.NEWLINE); } return result.toString(); }
From source file:org.jclouds.rackspace.cloudfiles.CloudFilesClientLiveTest.java
@Test public void testListOwnedContainers() throws Exception { String containerPrefix = getContainerName(); try {//w w w . j a v a 2s . co m SortedSet<ContainerMetadata> response = context.getApi().listContainers(); assertNotNull(response); long initialContainerCount = response.size(); assertTrue(initialContainerCount >= 0); // Create test containers String[] containerJsr330 = new String[] { containerPrefix + ".testListOwnedContainers1", containerPrefix + ".testListOwnedContainers2" }; assertTrue(context.getApi().createContainer(containerJsr330[0])); assertTrue(context.getApi().createContainer(containerJsr330[1])); // Test default listing response = context.getApi().listContainers(); // assertEquals(response.size(), initialContainerCount + 2);// if the containers already // exist, this will fail // Test listing with options response = context.getApi().listContainers(ListContainerOptions.Builder .afterMarker(containerJsr330[0].substring(0, containerJsr330[0].length() - 1)).maxResults(1)); assertEquals(response.size(), 1); assertEquals(response.first().getName(), containerJsr330[0]); response = context.getApi() .listContainers(ListContainerOptions.Builder.afterMarker(containerJsr330[0]).maxResults(1)); assertEquals(response.size(), 1); assertEquals(response.first().getName(), containerJsr330[1]); // Cleanup and test containers have been removed assertTrue(context.getApi().deleteContainerIfEmpty(containerJsr330[0])); assertTrue(context.getApi().deleteContainerIfEmpty(containerJsr330[1])); response = context.getApi().listContainers(); // assertEquals(response.size(), initialContainerCount + 2);// if the containers already // exist, this will fail } finally { returnContainer(containerPrefix); } }
From source file:org.apache.hadoop.hbase.master.TestLoadBalancer.java
private String printMock(List<HServerInfo> balancedCluster) { SortedSet<HServerInfo> sorted = new TreeSet<HServerInfo>(balancedCluster); HServerInfo[] arr = sorted.toArray(new HServerInfo[sorted.size()]); StringBuilder sb = new StringBuilder(sorted.size() * 4 + 4); sb.append("{ "); for (int i = 0; i < arr.length; i++) { if (i != 0) { sb.append(" , "); }//from w w w. j a v a 2 s . co m sb.append(arr[i].getLoad().getNumberOfRegions()); } sb.append(" }"); return sb.toString(); }
From source file:org.apache.hadoop.hbase.master.balancer.BalancerTestBase.java
protected String printMock(List<ServerAndLoad> balancedCluster) { SortedSet<ServerAndLoad> sorted = new TreeSet<ServerAndLoad>(balancedCluster); ServerAndLoad[] arr = sorted.toArray(new ServerAndLoad[sorted.size()]); StringBuilder sb = new StringBuilder(sorted.size() * 4 + 4); sb.append("{ "); for (int i = 0; i < arr.length; i++) { if (i != 0) { sb.append(" , "); }// ww w . j av a 2s . co m sb.append(arr[i].getServerName().getHostname()); sb.append(":"); sb.append(arr[i].getLoad()); } sb.append(" }"); return sb.toString(); }
From source file:org.codehaus.mojo.license.LicenseMap.java
public void mergeLicenses(String... licenses) { if (licenses.length == 0) { return;// w w w . j ava 2 s .c o m } String mainLicense = licenses[0].trim(); SortedSet<MavenProject> mainSet = get(mainLicense); if (mainSet == null) { getLog().warn("No license [" + mainLicense + "] found, will create it."); mainSet = new TreeSet<MavenProject>(ArtifactHelper.getProjectComparator()); put(mainLicense, mainSet); } int size = licenses.length; for (int i = 1; i < size; i++) { String license = licenses[i].trim(); SortedSet<MavenProject> set = get(license); if (set == null) { getLog().warn("No license [" + license + "] found, skip this merge."); continue; } getLog().info("Merge license [" + license + "] (" + set.size() + " depedencies)."); mainSet.addAll(set); set.clear(); remove(license); } }
From source file:org.jclouds.rackspace.cloudfiles.CloudFilesClientLiveTest.java
@Test public void testCDNOperations() throws Exception { final long minimumTTL = 60 * 60; // The minimum TTL is 1 hour // Create two new containers for testing final String containerNameWithCDN = getContainerName(); final String containerNameWithoutCDN = getContainerName(); try {/*from w w w . j av a2 s.co m*/ try { context.getApi().disableCDN(containerNameWithCDN); context.getApi().disableCDN(containerNameWithoutCDN); } catch (Exception e) { } ContainerCDNMetadata cdnMetadata = null; // Enable CDN with PUT for one container final URI cdnUri = context.getApi().enableCDN(containerNameWithCDN); assertTrue(cdnUri != null); // Confirm CDN is enabled via HEAD request and has default TTL cdnMetadata = context.getApi().getCDNMetadata(containerNameWithCDN); assertTrue(cdnMetadata.isCDNEnabled()); assertEquals(cdnMetadata.getCDNUri(), cdnUri); final long initialTTL = cdnMetadata.getTTL(); try { cdnMetadata = context.getApi().getCDNMetadata(containerNameWithoutCDN); assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN + " should not have metadata"; } catch (ContainerNotFoundException e) { } catch (HttpResponseException e) { } try { cdnMetadata = context.getApi().getCDNMetadata("DoesNotExist"); assert false : "should not exist"; } catch (ContainerNotFoundException e) { } catch (HttpResponseException e) { } // List CDN metadata for containers, and ensure all CDN info is available for enabled // container SortedSet<ContainerCDNMetadata> cdnMetadataList = context.getApi().listCDNContainers(); assertTrue(cdnMetadataList.size() >= 1); assertTrue(cdnMetadataList .contains(new ContainerCDNMetadata(containerNameWithCDN, true, initialTTL, cdnUri))); // Test listing with options cdnMetadataList = context.getApi().listCDNContainers(ListCdnContainerOptions.Builder.enabledOnly()); assertTrue(Iterables.all(cdnMetadataList, new Predicate<ContainerCDNMetadata>() { public boolean apply(ContainerCDNMetadata cdnMetadata) { return cdnMetadata.isCDNEnabled(); } })); cdnMetadataList = context.getApi() .listCDNContainers(ListCdnContainerOptions.Builder .afterMarker(containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)) .maxResults(1)); assertEquals(cdnMetadataList.size(), 1); // Enable CDN with PUT for the same container, this time with a custom TTL long ttl = 4000; context.getApi().enableCDN(containerNameWithCDN, ttl); cdnMetadata = context.getApi().getCDNMetadata(containerNameWithCDN); assertTrue(cdnMetadata.isCDNEnabled()); assertEquals(cdnMetadata.getTTL(), ttl); // Check POST by updating TTL settings ttl = minimumTTL; context.getApi().updateCDN(containerNameWithCDN, minimumTTL); cdnMetadata = context.getApi().getCDNMetadata(containerNameWithCDN); assertTrue(cdnMetadata.isCDNEnabled()); assertEquals(cdnMetadata.getTTL(), minimumTTL); // Confirm that minimum allowed value for TTL is 3600, lower values are ignored. context.getApi().updateCDN(containerNameWithCDN, 3599L); cdnMetadata = context.getApi().getCDNMetadata(containerNameWithCDN); assertEquals(cdnMetadata.getTTL(), minimumTTL); // Note that TTL is 3600 here, not 3599 // Disable CDN with POST assertTrue(context.getApi().disableCDN(containerNameWithCDN)); cdnMetadata = context.getApi().getCDNMetadata(containerNameWithCDN); assertEquals(cdnMetadata.isCDNEnabled(), false); } finally { recycleContainer(containerNameWithCDN); recycleContainer(containerNameWithoutCDN); } }
From source file:org.apache.hadoop.hbase.master.TestDefaultLoadBalancer.java
private String printMock(List<ServerAndLoad> balancedCluster) { SortedSet<ServerAndLoad> sorted = new TreeSet<ServerAndLoad>(balancedCluster); ServerAndLoad[] arr = sorted.toArray(new ServerAndLoad[sorted.size()]); StringBuilder sb = new StringBuilder(sorted.size() * 4 + 4); sb.append("{ "); for (int i = 0; i < arr.length; i++) { if (i != 0) { sb.append(" , "); }/*w ww .j a v a 2 s . co m*/ sb.append(arr[i].getLoad()); } sb.append(" }"); return sb.toString(); }
From source file:edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail.java
/** * This returns a string of object code names associated with the object code in this org rev change detail. * // w w w. java2 s .com * @return String of distinct object code names */ public String getObjectCodeNames() { String objectCodeNames = ""; if (!StringUtils.isBlank(this.getAccountReversionObjectCode())) { if (this.getParentGlobalAccountReversion().getUniversityFiscalYear() != null && this.getParentGlobalAccountReversion().getAccountReversionGlobalAccounts() != null && this.getParentGlobalAccountReversion().getAccountReversionGlobalAccounts().size() > 0) { // find distinct chart of account codes SortedSet<String> chartCodes = new TreeSet<String>(); for (AccountReversionGlobalAccount acct : this.getParentGlobalAccountReversion() .getAccountReversionGlobalAccounts()) { chartCodes.add(acct.getChartOfAccountsCode()); } String[] chartCodesArray = new String[chartCodes.size()]; int i = 0; for (String chartCode : chartCodes) { chartCodesArray[i] = chartCode; i++; } objectCodeNames = (String) SpringContext.getBean(ObjectCodeService.class) .getObjectCodeNamesByCharts( this.getParentGlobalAccountReversion().getUniversityFiscalYear(), chartCodesArray, this.getAccountReversionObjectCode()); } } return objectCodeNames; }