List of usage examples for java.util SortedSet size
int size();
From source file:org.apache.roller.weblogger.webservices.atomprotocol.MediaCollection.java
public Feed getCollection(AtomRequest areq) throws AtomException { log.debug("Entering"); String[] rawPathInfo = StringUtils.split(areq.getPathInfo(), "/"); try {/*from w ww .j ava2s. c o m*/ int start = 0; int max = maxEntries; String[] pathInfo = rawPathInfo; if (rawPathInfo.length > 2) { try { start = Integer.parseInt(rawPathInfo[rawPathInfo.length - 1]); pathInfo = new String[rawPathInfo.length - 1]; for (int i = 0; i < rawPathInfo.length - 1; i++) { pathInfo[i] = rawPathInfo[i]; } } catch (Exception ingored) { } } String path = filePathFromPathInfo(pathInfo); if (!path.equals("")) path = path + File.separator; String handle = pathInfo[0]; String absUrl = WebloggerRuntimeConfig.getAbsoluteContextURL(); Weblog website = roller.getWeblogManager().getWeblogByHandle(handle); if (website == null) { throw new AtomNotFoundException("Cannot find weblog: " + handle); } if (!RollerAtomHandler.canView(user, website)) { throw new AtomNotAuthorizedException("Not authorized to access website"); } Feed feed = new Feed(); feed.setId(atomURL + "/" + website.getHandle() + "/resources/" + path + start); feed.setTitle(website.getName()); Link link = new Link(); link.setHref(absUrl + "/" + website.getHandle()); link.setRel("alternate"); link.setType("text/html"); feed.setAlternateLinks(Collections.singletonList(link)); MediaFileManager fmgr = roller.getMediaFileManager(); MediaFileDirectory dir = null; if (StringUtils.isNotEmpty(path)) { log.debug("Fetching resource collection from weblog " + handle + " at path: " + path); dir = fmgr.getMediaFileDirectoryByPath(website, path); } else { log.debug("Fetching root resource collection from weblog " + handle); dir = fmgr.getMediaFileRootDirectory(website); } Set<MediaFile> files = dir.getMediaFiles(); SortedSet sortedSet = new TreeSet(new Comparator() { public int compare(Object o1, Object o2) { MediaFile f1 = (MediaFile) o1; MediaFile f2 = (MediaFile) o2; if (f1.getLastModified() < f2.getLastModified()) return 1; else if (f1.getLastModified() == f2.getLastModified()) return 0; else return -1; } }); if (files != null && start < files.size()) { for (MediaFile mf : files) { sortedSet.add(mf); } int count = 0; MediaFile[] sortedResources = (MediaFile[]) sortedSet.toArray(new MediaFile[sortedSet.size()]); List atomEntries = new ArrayList(); for (int i = start; i < (start + max) && i < (sortedResources.length); i++) { Entry entry = createAtomResourceEntry(website, sortedResources[i]); atomEntries.add(entry); if (count == 0) { // first entry is most recent feed.setUpdated(entry.getUpdated()); } count++; } List otherLinks = new ArrayList(); if (start + count < files.size()) { // add next link int nextOffset = start + max; String url = atomURL + "/" + website.getHandle() + "/resources/" + path + nextOffset; Link nextLink = new Link(); nextLink.setRel("next"); nextLink.setHref(url); otherLinks.add(nextLink); } if (start > 0) { // add previous link int prevOffset = start > max ? start - max : 0; String url = atomURL + "/" + website.getHandle() + "/resources/" + path + prevOffset; Link prevLink = new Link(); prevLink.setRel("previous"); prevLink.setHref(url); otherLinks.add(prevLink); } feed.setOtherLinks(otherLinks); feed.setEntries(atomEntries); log.debug("Collection contains: " + count); } else { log.debug("Returning empty collection"); } log.debug("Exiting"); return feed; } catch (WebloggerException re) { throw new AtomException("Getting resource collection", re); } }
From source file:org.hyperic.hq.plugin.dotnet.DotNetDetector.java
private String getVersion() { RegistryKey key = null;/* w w w . java2 s. c om*/ RegistryKey versionKey = null; SortedSet<String> versions = new TreeSet<String>(); try { key = getRegistryKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP"); String[] names = key.getSubKeyNames(); for (String versionKeyName : names) { if (versionKeyName.startsWith("v") && !versionKeyName.startsWith("v4")) { versionKey = key.openSubKey(versionKeyName); findVersion(versionKey, versions); } else if (versionKeyName.startsWith("v4")) { versionKey = key.openSubKey(versionKeyName); for (String subKeyName : versionKey.getSubKeyNames()) { RegistryKey subKey = versionKey.openSubKey(subKeyName); findVersion(subKey, versions); } } } } catch (Win32Exception e) { log.debug(e, e); return null; } finally { if (key != null) { key.close(); } } log.debug("Found .NET versions=" + versions); //all runtime versions have the same metrics, //so just discover the highest version return (versions.size() > 0) ? versions.last() : ""; }
From source file:org.apache.hyracks.storage.am.btree.OrderedIndexTestUtils.java
@SuppressWarnings("unchecked") public void checkRangeSearch(IIndexTestContext ctx, ITupleReference lowKey, ITupleReference highKey, boolean lowKeyInclusive, boolean highKeyInclusive) throws Exception { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Testing Range Search."); }//from w w w . j a va 2 s .c o m MultiComparator lowKeyCmp = BTreeUtils.getSearchMultiComparator(ctx.getComparatorFactories(), lowKey); MultiComparator highKeyCmp = BTreeUtils.getSearchMultiComparator(ctx.getComparatorFactories(), highKey); IIndexCursor searchCursor = ctx.getIndexAccessor().createSearchCursor(false); RangePredicate rangePred = new RangePredicate(lowKey, highKey, lowKeyInclusive, highKeyInclusive, lowKeyCmp, highKeyCmp); ctx.getIndexAccessor().search(searchCursor, rangePred); // Get the subset of elements from the expected set within given key // range. CheckTuple lowKeyCheck = createCheckTupleFromTuple(lowKey, ctx.getFieldSerdes(), lowKeyCmp.getKeyFieldCount()); CheckTuple highKeyCheck = createCheckTupleFromTuple(highKey, ctx.getFieldSerdes(), highKeyCmp.getKeyFieldCount()); SortedSet<CheckTuple> expectedSubset = null; if (lowKeyCmp.getKeyFieldCount() < ctx.getKeyFieldCount() || highKeyCmp.getKeyFieldCount() < ctx.getKeyFieldCount()) { // Searching on a key prefix (low key or high key or both). expectedSubset = getPrefixExpectedSubset((TreeSet<CheckTuple>) ctx.getCheckTuples(), lowKeyCheck, highKeyCheck); } else { // Searching on all key fields. expectedSubset = ((TreeSet<CheckTuple>) ctx.getCheckTuples()).subSet(lowKeyCheck, lowKeyInclusive, highKeyCheck, highKeyInclusive); } Iterator<CheckTuple> checkIter = expectedSubset.iterator(); int actualCount = 0; try { while (searchCursor.hasNext()) { if (!checkIter.hasNext()) { fail("Range search returned more answers than expected.\nExpected: " + expectedSubset.size()); } searchCursor.next(); CheckTuple expectedTuple = checkIter.next(); ITupleReference tuple = searchCursor.getTuple(); compareActualAndExpected(tuple, expectedTuple, ctx.getFieldSerdes()); actualCount++; } if (actualCount < expectedSubset.size()) { fail("Range search returned fewer answers than expected.\nExpected: " + expectedSubset.size() + "\nActual : " + actualCount); } } finally { searchCursor.close(); } }
From source file:com.microsoft.tfs.client.common.ui.teamexplorer.internal.pendingchanges.PendingChangesViewModel.java
private void updateCheckinNoteFieldDefinitions(final String[] teamProjectPaths) { final CheckinNoteFieldDefinition[] definitions; if ((workspace != null && workspace.getLocation() == WorkspaceLocation.LOCAL && workspace.getClient().getConnection().getConnectivityFailureOnLastWebServiceCall()) || teamProjectPaths == null || teamProjectPaths.length == 0) { definitions = new CheckinNoteFieldDefinition[0]; } else {/*from w w w . j av a 2 s . c om*/ final VersionControlClient client = repository.getVersionControlClient(); final SortedSet<CheckinNoteFieldDefinition> set = client .queryCheckinNoteFieldDefinitionsForServerPaths(teamProjectPaths); definitions = set.toArray(new CheckinNoteFieldDefinition[set.size()]); } if (checkinNotesDiffer(checkinNoteFieldDefinitions, definitions)) { checkinNoteFieldDefinitions = definitions; fireCheckinNoteFieldDefinitionsChangedEvent(); } }
From source file:com.google.gwt.emultest.java.util.TreeSetTest.java
/** * Test method for 'java.util.SortedSet.subSet(Object, Object)' and * 'java.util.NavigableSet.subSet(Object, boolean, Object, boolean)'. * * @see java.util.SortedSet#subSet(Object, Object) * @see java.util.NavigableSet#subSet(Object, boolean, Object, boolean) *///from ww w . j ava2 s.c o m public void testSubSet() { NavigableSet<E> sortedSet = createNavigableSet(); // test with no entries assertEquals(0, sortedSet.subSet(getKeys()[0], getKeys()[0]).size()); assertEquals(0, sortedSet.subSet(getKeys()[0], false, getKeys()[0], false).size()); assertEquals(0, sortedSet.subSet(getKeys()[0], true, getKeys()[0], false).size()); assertEquals(0, sortedSet.subSet(getKeys()[0], false, getKeys()[0], true).size()); assertEquals(0, sortedSet.subSet(getKeys()[0], true, getKeys()[0], true).size()); // test with a single entry set sortedSet.add(getKeys()[0]); assertEquals(0, sortedSet.subSet(getKeys()[0], getKeys()[0]).size()); // bounded by a "wide" range assertEquals(1, sortedSet.subSet(getLessThanMinimumKey(), getGreaterThanMaximumKey()).size()); assertEquals(1, sortedSet.subSet(getLessThanMinimumKey(), false, getGreaterThanMaximumKey(), false).size()); assertEquals(1, sortedSet.subSet(getLessThanMinimumKey(), true, getGreaterThanMaximumKey(), false).size()); assertEquals(1, sortedSet.subSet(getLessThanMinimumKey(), false, getGreaterThanMaximumKey(), true).size()); assertEquals(1, sortedSet.subSet(getLessThanMinimumKey(), true, getGreaterThanMaximumKey(), true).size()); // test with two entry set sortedSet.add(getKeys()[1]); assertEquals(1, sortedSet.subSet(getKeys()[0], getKeys()[1]).size()); assertEquals(getKeys()[0], sortedSet.subSet(getKeys()[0], getKeys()[1]).toArray()[0]); assertEquals(0, sortedSet.subSet(getKeys()[0], false, getKeys()[1], false).size()); assertEquals(1, sortedSet.subSet(getKeys()[0], false, getKeys()[1], true).size()); assertEquals(getKeys()[1], sortedSet.subSet(getKeys()[0], false, getKeys()[1], true).toArray()[0]); assertEquals(1, sortedSet.subSet(getKeys()[0], true, getKeys()[1], false).size()); assertEquals(getKeys()[0], sortedSet.subSet(getKeys()[0], true, getKeys()[1], false).toArray()[0]); assertEquals(2, sortedSet.subSet(getKeys()[0], true, getKeys()[1], true).size()); assertEquals(getKeys()[0], sortedSet.subSet(getKeys()[0], true, getKeys()[1], true).toArray()[0]); assertEquals(getKeys()[1], sortedSet.subSet(getKeys()[0], true, getKeys()[1], true).toArray()[1]); // bounded by a "wide" range SortedSet<E> subSet = sortedSet.subSet(getLessThanMinimumKey(), getGreaterThanMaximumKey()); assertEquals(2, subSet.size()); assertEquals(2, sortedSet.subSet(getLessThanMinimumKey(), false, getGreaterThanMaximumKey(), false).size()); assertEquals(1, sortedSet.subSet(getKeys()[0], false, getGreaterThanMaximumKey(), false).size()); assertEquals(0, sortedSet.subSet(getKeys()[0], false, getKeys()[1], false).size()); assertEquals(2, sortedSet.subSet(getKeys()[0], true, getGreaterThanMaximumKey(), false).size()); assertEquals(1, sortedSet.subSet(getKeys()[0], true, getKeys()[1], false).size()); assertEquals(2, sortedSet.subSet(getKeys()[0], true, getGreaterThanMaximumKey(), true).size()); assertEquals(2, sortedSet.subSet(getKeys()[0], true, getKeys()[1], true).size()); }
From source file:com.blackducksoftware.integration.jira.config.HubJiraConfigController.java
@Path("/creatorCandidates") @GET/*from w ww . ja v a 2 s .co m*/ @Produces(MediaType.APPLICATION_JSON) public Response getCreatorCandidates(@Context final HttpServletRequest request) { logger.debug("getCreatorCandidates()"); final Object projectsConfig; try { final PluginSettings settings = pluginSettingsFactory.createGlobalSettings(); final Response response = checkUserPermissions(request, settings); if (response != null) { return response; } projectsConfig = transactionTemplate.execute(new TransactionCallback() { @Override public Object doInTransaction() { final HubJiraConfigSerializable config = new HubJiraConfigSerializable(); config.setCreatorCandidates(new TreeSet<String>()); final SortedSet<String> creatorCandidates = getIssueCreatorCandidates(settings); config.setCreatorCandidates(creatorCandidates); if (creatorCandidates.size() == 0) { config.setGeneralSettingsError(JiraConfigErrors.NO_CREATOR_CANDIDATES_FOUND); } return config; } }); } catch (final Exception e) { final HubJiraConfigSerializable errorConfig = new HubJiraConfigSerializable(); final String msg = "Error getting issue creator candidates config: " + e.getMessage(); logger.error(msg, e); errorConfig.setGeneralSettingsError(msg); return Response.ok(errorConfig).build(); } return Response.ok(projectsConfig).build(); }
From source file:org.torproject.ernie.web.DescriptorServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { /* Measure how long it takes to process this request. */ long started = System.currentTimeMillis(); /* Get print writer and start writing response. */ PrintWriter out = response.getWriter(); writeHeader(out);/*from ww w. ja va 2 s . c om*/ /* Check desc-id parameter. */ String descIdParameter = request.getParameter("desc-id"); String descId = null; if (descIdParameter != null && descIdParameter.length() >= 8 && descIdParameter.length() <= 40) { Pattern descIdPattern = Pattern.compile("^[0-9a-f]{8,40}$"); if (descIdPattern.matcher(descIdParameter.toLowerCase()).matches()) { descId = descIdParameter.toLowerCase(); } } if (descId == null) { out.write(" <br/><p>Sorry, \"" + descIdParameter + "\" is not a " + "valid descriptor identifier. Please provide at least the " + "first 8 hex characters of a descriptor identifier.</p>\n"); writeFooter(out); return; } /* If we were only given a partial descriptor identifier, look up all * descriptor identifiers starting with that part to see if it's * unique. */ if (descId.length() < 40) { SortedSet<String> allDescIds = new TreeSet<String>(); try { Connection conn = this.ds.getConnection(); Statement statement = conn.createStatement(); String query = "SELECT DISTINCT descriptor FROM statusentry " + "WHERE descriptor LIKE '" + descId + "%'"; ResultSet rs = statement.executeQuery(query); while (rs.next()) { allDescIds.add(rs.getString(1)); } rs.close(); statement.close(); conn.close(); } catch (SQLException e) { out.println("<p><font color=\"red\"><b>Warning: </b></font>We " + "experienced an unknown database problem while looking up " + "descriptors with identifier starting with " + descId + ". If this problem persists, please " + "<a href=\"mailto:tor-assistants@freehaven.net\">let us " + "know</a>!</p>\n"); writeFooter(out); return; } if (allDescIds.size() == 0) { out.write("<p>No descriptor found " + (descId.length() < 40 ? "starting " : "") + "with identifier " + descId + ".</p>"); writeFooter(out); return; } else if (allDescIds.size() > 1) { out.println("<p>The descriptor identifier part " + descIdParameter + " is not unique. Please choose one of the following " + "descriptors:</p><ul>"); for (String f : allDescIds) { out.println("<li><a href=\"descriptor.html?desc-id=" + f + "\">" + f + "</a></li>"); } out.write("</ul><br/>"); writeFooter(out); return; } else { descId = allDescIds.first(); } } /* Look up descriptor in the database. */ String descriptor = null, nickname = null, published = null, extrainfo = null; byte[] rawDescriptor = null, rawExtrainfo = null; try { Connection conn = this.ds.getConnection(); Statement statement = conn.createStatement(); String query = "SELECT descriptor, nickname, published, extrainfo, " + "rawdesc FROM descriptor WHERE descriptor = '" + descId + "'"; ResultSet rs = statement.executeQuery(query); if (rs.next()) { descriptor = rs.getString(1); nickname = rs.getString(2); published = rs.getTimestamp(3).toString().substring(0, 19); extrainfo = rs.getString(4); rawDescriptor = rs.getBytes(5); } query = "SELECT rawdesc FROM extrainfo WHERE extrainfo = '" + extrainfo + "'"; rs = statement.executeQuery(query); if (rs.next()) { rawExtrainfo = rs.getBytes(1); } rs.close(); statement.close(); conn.close(); } catch (SQLException e) { out.write("<br/><p><font color=\"red\"><b>Warning: </b></font>" + "Internal server error when looking up descriptor. If this " + "problem persists, please " + "<a href=\"mailto:tor-assistants@freehaven.net\">let us " + "know</a>!</p>\n"); writeFooter(out); return; } /* If no descriptor was found, stop here. */ if (descriptor == null) { out.write("<p>No descriptor found " + (descIdParameter.length() < 40 ? "starting " : "") + "with identifier " + descIdParameter + ".</p>"); writeFooter(out); return; } /* Print out both server and extra-info descriptor. */ out.write("<br/><p>The following server descriptor was published by " + "relay " + nickname + " at " + published + " UTC:</p>"); BufferedReader br = new BufferedReader(new StringReader(new String(rawDescriptor, "US-ASCII"))); String line = null; while ((line = br.readLine()) != null) { out.println(" <tt>" + line + "</tt><br/>"); } br.close(); if (rawExtrainfo != null) { out.println("<br/><p>Together with this server descriptor, the " + "relay published the following extra-info descriptor:</p>"); br = new BufferedReader(new StringReader(new String(rawExtrainfo, "US-ASCII"))); line = null; while ((line = br.readLine()) != null) { out.println(" <tt>" + line + "</tt><br/>"); } } /* Print out in which consensuses this descriptor is referenced. */ try { Connection conn = this.ds.getConnection(); Statement statement = conn.createStatement(); String query = "SELECT validafter, rawdesc FROM statusentry " + "WHERE descriptor = '" + descriptor + "' ORDER BY validafter " + "DESC"; ResultSet rs = statement.executeQuery(query); boolean printedDescription = false; while (rs.next()) { if (!printedDescription) { out.println("<br/><p>This server descriptor is referenced from " + "the following network status consensuses:</p>"); printedDescription = true; } String validAfter = rs.getTimestamp(1).toString().substring(0, 19); out.println(" <br/><tt>valid-after " + "<a href=\"consensus?valid-after=" + validAfter.replaceAll(":", "-").replaceAll(" ", "-") + "\" target=\"_blank\">" + validAfter + "</a></tt><br/>"); byte[] rawStatusEntry = rs.getBytes(2); br = new BufferedReader(new StringReader(new String(rawStatusEntry, "US-ASCII"))); line = null; while ((line = br.readLine()) != null) { out.println(" <tt>" + line + "</tt><br/>"); } } rs.close(); statement.close(); conn.close(); } catch (SQLException e) { out.println("<p><font color=\"red\"><b>Warning: </b></font>We " + "experienced an unknown database problem while looking up " + "the network status consensuses referencing descriptor " + descId + ". If this problem persists, please " + "<a href=\"mailto:tor-assistants@freehaven.net\">let us " + "know</a>!</p>\n"); } /* Provide links to raw descriptors, too. */ out.println("<br/><p>Note that the descriptor" + (rawExtrainfo != null ? "s have" : " has") + " been converted to ASCII and reformatted " + "for display purposes. You may also download the raw " + "<a href=\"serverdesc?desc-id=" + descriptor + "\" target=\"_blank\">server " + "descriptor</a>" + (extrainfo != null ? " and <a href=\"extrainfodesc?desc-id=" + extrainfo + "\" target=\"_blank\">extra-info descriptor</a>" : "") + " as " + (extrainfo != null ? "they were" : "it was") + " published to the directory authorities.</p>"); /* Display total lookup time on the results page. */ long searchTime = System.currentTimeMillis() - started; out.write(" <br/><p>Looking up this descriptor took us " + String.format("%d.%03d", searchTime / 1000, searchTime % 1000) + " seconds.</p>\n"); /* Finish writing response. */ writeFooter(out); }
From source file:uk.co.flax.biosolr.builders.ParentNodeFacetTreeBuilder.java
/** * Recursively build an accumulated facet entry tree. * @param level current level in the tree (used for debugging/logging). * @param fieldValue the current node value. * @param hierarchyMap the map of nodes (either in the original facet set, * or parents of those entries).// w w w. j a v a 2 s . co m * @param facetCounts the facet counts, keyed by node ID. * @return a {@link TreeFacetField} containing details for the current node and all * sub-nodes down to the lowest leaf which has a facet count. */ private TreeFacetField buildAccumulatedEntryTree(int level, String fieldValue, Map<String, Set<String>> hierarchyMap, Map<String, Integer> facetCounts) { // Build the child hierarchy for this entry. // We use a reverse-ordered SortedSet so entries are returned in descending // order by their total count. SortedSet<TreeFacetField> childHierarchy = new TreeSet<>(Collections.reverseOrder()); // childTotal is the total number of facet hits below this node long childTotal = 0; if (hierarchyMap.containsKey(fieldValue)) { // Loop through all the direct child URIs, looking for those which are in the annotation map for (String childId : hierarchyMap.get(fieldValue)) { if (!childId.equals(fieldValue)) { // Found a child of this node - recurse to build its facet tree LOGGER.trace("[{}] Building child tree for {}, with {} children", level, childId, (hierarchyMap.containsKey(childId) ? hierarchyMap.get(childId).size() : 0)); TreeFacetField childTree = buildAccumulatedEntryTree(level + 1, childId, hierarchyMap, facetCounts); // Only add to the total count if this node isn't already in the child hierarchy if (childHierarchy.add(childTree)) { childTotal += childTree.getTotal(); } LOGGER.trace("[{}] child tree total: {} - child Total {}, child count {}", level, childTree.getTotal(), childTotal, childHierarchy.size()); } else { LOGGER.trace("[{}] found self-referring ID {}->{}", level, fieldValue, childId); } } } // Build the accumulated facet entry LOGGER.trace("[{}] Building facet tree for {}", level, fieldValue); return new TreeFacetField(getLabel(fieldValue), fieldValue, getFacetCount(fieldValue, facetCounts), childTotal, childHierarchy); }
From source file:uk.co.flax.biosolr.builders.ChildNodeFacetTreeBuilder.java
/** * Recursively build an accumulated facet entry tree. * @param level current level in the tree (used for debugging/logging). * @param fieldValue the current node value. * @param hierarchyMap the map of nodes (either in the original facet set, * or parents of those entries)./*w ww .j a va 2 s . c o m*/ * @param facetCounts the facet counts, keyed by node ID. * @return a {@link TreeFacetField} containing details for the current node and all * sub-nodes down to the lowest leaf which has a facet count. */ private TreeFacetField buildAccumulatedEntryTree(int level, String fieldValue, Map<String, Set<String>> hierarchyMap, Map<String, Integer> facetCounts) { // Build the child hierarchy for this entry. // We use a reverse-ordered SortedSet so entries are returned in descending // order by their total count. SortedSet<TreeFacetField> childHierarchy = new TreeSet<>(Collections.reverseOrder()); // childTotal is the total number of facet hits below this node long childTotal = 0; if (hierarchyMap.containsKey(fieldValue)) { // Loop through all the direct child URIs, looking for those which are in the annotation map for (String childId : hierarchyMap.get(fieldValue)) { if (hierarchyMap.containsKey(childId) && !childId.equals(fieldValue)) { // Found a child of this node - recurse to build its facet tree LOGGER.trace("[{}] Building child tree for {}, with {} children", level, childId, hierarchyMap.get(childId).size()); TreeFacetField childTree = buildAccumulatedEntryTree(level + 1, childId, hierarchyMap, facetCounts); // Only add to the total count if this node isn't already in the child hierarchy if (childHierarchy.add(childTree)) { childTotal += childTree.getTotal(); } LOGGER.trace("[{}] child tree total: {} - child Total {}, child count {}", level, childTree.getTotal(), childTotal, childHierarchy.size()); } else { LOGGER.trace("[{}] no node entry for {}->{}", level, fieldValue, childId); } } } // Build the accumulated facet entry LOGGER.trace("[{}] Building facet tree for {}", level, fieldValue); return new TreeFacetField(getLabel(fieldValue), fieldValue, getFacetCount(fieldValue, facetCounts), childTotal, childHierarchy); }
From source file:Arguments.java
/** * Gives a short synopsis of how to provide arguments, including which are required and optional, * and which long arguments take values. *//*from www . ja v a2 s . c o m*/ public String getUsage() { StringBuilder buf = new StringBuilder(); if (programName.length() > 0) { buf.append(programName + ": "); } if (shortProgramDoc.length() > 0) { buf.append(shortProgramDoc + "\n"); } else { buf.append("usage synopsis...\n"); } SortedSet<String> smallRequired = new TreeSet<String>(); SortedSet<String> smallNotRequired = new TreeSet<String>(); SortedSet<String> bigRequired = new TreeSet<String>(); SortedSet<String> bigNotRequired = new TreeSet<String>(); for (String f : docs.keySet()) { boolean req = requireFlag.contains(f); boolean sh = f.length() == 1 && !requireValue.contains(f); if (req && sh) { smallRequired.add(f); } else if (req && !sh) { bigRequired.add(f); } else if (!req && sh) { smallNotRequired.add(f); } else if (!req && !sh) { bigNotRequired.add(f); } } if (programName.length() > 0) { buf.append(programName + " "); } for (String f : smallRequired) { buf.append("-" + f + " "); } if (smallNotRequired.size() > 0) { buf.append(" [ "); for (String f : smallNotRequired) { buf.append("-" + f + " "); } buf.append("] "); } for (String f : bigRequired) { if (requireValue.contains(f)) { buf.append("--" + f + "=..." + " "); } else { buf.append("--" + f + "[=...]" + " "); } } if (bigNotRequired.size() > 0) { buf.append(" [ "); for (String f : bigNotRequired) { if (requireValue.contains(f)) { buf.append("--" + f + "=..." + " "); } else { buf.append("--" + f + " "); } } buf.append("] "); } for (int i = 0; i < positionalDocs.size(); i++) { if (i == requiredPositionArgs) { buf.append(" [ "); } buf.append(positionalDocs.get(i).get(0) + " "); if (i == requiredPositionArgs) { buf.append(" ] "); } } return buf.toString(); }