Example usage for java.util SortedSet size

List of usage examples for java.util SortedSet size

Introduction

In this page you can find the example usage for java.util SortedSet size.

Prototype

int size();

Source Link

Document

Returns the number of elements in this set (its cardinality).

Usage

From source file:org.eclipse.skalli.core.project.ProjectComponent.java

@Override
protected void validateEntity(Project entity) throws ValidationException {
    SortedSet<Issue> issues = validate(entity, Severity.FATAL);
    if (issues.size() > 0) {
        throw new ValidationException("Project could not be saved due to the following reasons:", issues);
    }// w  w  w .j  a v a  2  s  . com
}

From source file:org.deegree.tools.feature.gml.SchemaAnalyzer.java

public String getElementDeclarationSummary(String namespace) {
    StringBuffer sb = new StringBuffer();
    XSNamedMap elementMap = schema.getComponentsByNamespace(XSConstants.ELEMENT_DECLARATION, namespace);
    SortedSet<String> elementNames = new TreeSet<String>();
    for (int i = 0; i < elementMap.getLength(); i++) {
        XSElementDeclaration elementDecl = (XSElementDeclaration) elementMap.item(i);
        sb.append(toString(elementDecl) + "\n");
        elementNames.add(elementDecl.getName());
    }//from w w  w .  j  ava2  s . c o  m
    sb.append(elementNames.size() + " element declarations in namespace: '" + namespace + "':\n");
    for (String elementName : elementNames) {
        sb.append(elementName + "\n");
    }
    return sb.toString();
}

From source file:org.jclouds.azure.storage.blob.AzureBlobClientLiveTest.java

@Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testCreateContainer", "testCreatePublicContainer" })
public void testListOwnedContainers() throws Exception {

    // Test default listing
    SortedSet<ListableContainerProperties> response = connection.listContainers();
    // assertEquals(response.size(), initialContainerCount + 2);// if the containers already
    // exist, this will fail

    // Test listing with options
    response = connection.listContainers(ListOptions.Builder
            .prefix(privateContainer.substring(0, privateContainer.length() - 1)).maxResults(1));
    assertEquals(response.size(), 1);
    assertEquals(response.first().getName(), privateContainer);

    response = connection.listContainers(ListOptions.Builder.prefix(publicContainer).maxResults(1));
    assertEquals(response.size(), 1);/*from   ww  w . ja  v a 2  s. com*/
    assertEquals(response.first().getName(), publicContainer);

}

From source file:org.eclipse.skalli.core.validation.ValidationComponent.java

private <T extends EntityBase> void validateAndPersist(EntityService<T> entityService, T entity,
        Severity minSeverity, String userId) {
    SortedSet<Issue> issues = null;
    try {//www.j  ava2s  .c o  m
        issues = entityService.validate(entity, minSeverity);
    } catch (RuntimeException e) {
        LOG.error(
                MessageFormat.format("Validation of entity {0} failed:\n{1}", entity.getUuid(), e.getMessage()),
                e);
        return;
    }
    if (issuesService != null) {
        try {
            issuesService.persist(entity.getUuid(), issues, userId);
            SortedSet<Issue> fatalIssues = Issues.getIssues(issues, Severity.FATAL);
            if (fatalIssues.size() > 0) {
                LOG.warn(Issue.getMessage(MessageFormat.format("Entity {0} has {1} FATAL issues",
                        entity.getUuid(), fatalIssues.size()), fatalIssues));
            } else if (LOG.isInfoEnabled()) {
                LOG.info(Issue.getMessage(MessageFormat.format("Entity {0}: validated ({1} issues found)",
                        entity.getUuid(), issues.size()), issues));
            }
        } catch (ValidationException e) { // should not happen, but in case...
            LOG.error(MessageFormat.format("Failed to persist issues for entity {0}:\n{1}", entity.getUuid(),
                    e.getMessage()), e);
        }
    }
}

From source file:org.cloudata.core.tabletserver.TabletMapFile.java

public MapFileIndexRecord findNearest(Row.Key targetRowKey, Cell.Key cellKey) throws IOException {
    SortedSet<MapFileIndexRecord> tailMap = mapFileIndexRecords
            .tailSet(new MapFileIndexRecord(targetRowKey, cellKey));
    if (tailMap.size() > 0) {
        return tailMap.first();
    } else {/*  w ww.  j a va 2s .com*/
        return null;
    }
}

From source file:org.apache.sysml.utils.lite.BuildLite.java

/**
 * Examine all java source files for additional classes to load. A
 * relatively easy though not perfect way to do this is to look for imports
 * of specified packages./*from w  w w  . ja  v a2s. co m*/
 * 
 * @throws IOException
 *             if IOException occurs
 * @throws ClassNotFoundException
 *             if ClassNotFoundException occurs
 */
private static void scanJavaFilesForClassesToLoad() throws IOException, ClassNotFoundException {
    System.out.println("\nScanning java files for additional classes to load");
    int totalMatches = 0;
    SortedSet<String> uniqueMatches = new TreeSet<>();
    File base = new File(BASE_SRC_DIR);
    List<File> javaFiles = (List<File>) FileUtils.listFiles(base, new String[] { "java" }, true);
    for (File javaFile : javaFiles) {
        String content = FileUtils.readFileToString(javaFile);
        for (String additionalPackage : additionalPackages) {
            String s = "import " + additionalPackage + "(.*?);";
            Pattern p = Pattern.compile(s);
            Matcher m = p.matcher(content);
            while (m.find()) {
                totalMatches++;
                String match = m.group(1);
                String matchClass = additionalPackage + match;
                uniqueMatches.add(matchClass);
            }
        }
    }
    System.out.println("Total matches found from scan: " + totalMatches);
    int uniqueMatchesSize = uniqueMatches.size();
    System.out.println("Unique matches found from scan: " + uniqueMatchesSize);
    int numMatches = 0;
    for (String matchClass : uniqueMatches) {
        Class<?> clazz = Class.forName(matchClass);
        String pathToClass = getPathToClass(clazz);
        System.out.println(" #" + ++numMatches + ": Loaded " + clazz.getName() + " from " + pathToClass);
    }
}

From source file:org.jenkinsci.plugins.docker.traceability.core.DockerTraceabilityRootAction.java

/**
 * Queries container statuses via API./*from w  w w .  j  a  v a  2s .  c  o  m*/
 * The output will be retrieved in JSON. Supports filters.
 * @param id ID of the container, for which the info should be retrieved.
 *    Short container IDs are not supported.
 * @param mode {@link QueryMode}. Default value - {@link QueryMode#inspectContainer}
 * @param since Optional starting time. 
 *      If the value equals to 0, the filter will be ignored (default in {@link QueryParameter}).
 * @param until End time. 
 *      If the value equals to 0, the filter will be ignored (default in {@link QueryParameter}).
 * @throws IOException Processing error
 * @throws ServletException Servlet error
 * @return Response containing the output JSON. may be an error if something breaks.
 */
public HttpResponse doQueryContainer(@QueryParameter(required = true) String id,
        @QueryParameter(required = false) String mode, @QueryParameter(required = false) long since,
        @QueryParameter(required = false) long until) throws IOException, ServletException {
    checkPermission(DockerTraceabilityPlugin.READ_DETAILS);

    final QueryMode queryMode = QueryMode.fromString(mode);
    final long maxTime = (until != 0) ? until : Long.MAX_VALUE;
    final long minTime = (since != 0) ? since : Long.MIN_VALUE;

    DockerDeploymentFacet facet = DockerDeploymentFacet.getDeploymentFacet(id);
    if (facet == null) {
        return HttpResponses.error(404, "No info available for the containerId=" + id);
    }

    final SortedSet<DockerContainerRecord> deploymentRecords = facet.getDeploymentRecords();
    List<Object> result = new ArrayList<Object>(deploymentRecords.size());
    for (DockerContainerRecord record : deploymentRecords) {
        // time filters
        final long eventTime = record.getReport().getEvent().getTime();
        if (eventTime < minTime || eventTime > maxTime) {
            continue;
        }

        // Report data
        final DockerTraceabilityReport report = record.getReport();
        switch (queryMode) {
        case all:
            result.add(report);
            break;
        case events:
            result.add(report.getEvent());
            break;
        case inspectContainer:
            InspectContainerResponse containerResponse = report.getContainer();
            if (containerResponse != null) {
                result.add(containerResponse);
            }
            break;
        case inspectImage:
            InspectImageResponse imageResponse = report.getImage();
            if (imageResponse != null) {
                result.add(imageResponse);
            }
            break;
        case hostInfo:
            result.add(report.getHostInfo());
            break;
        default:
            throw new IllegalStateException("Unsupported query mode: " + queryMode);
        }
    }

    // Return raw JSON in the response
    return toJSONResponse(result);
}

From source file:ch.silviowangler.dox.DocumentServiceIntegrationTest.java

@Test
public void findAttributesForDocumentClassInvoice() throws DocumentClassNotFoundException {
    SortedSet<Attribute> attributes = documentService.findAttributes(this.documentClass);

    assertNotNull(attributes);/*from  ww  w . ja va2s  .  co m*/
    assertEquals(INVOICE_AMOUNT_INDICES, attributes.size());

    final Iterator<Attribute> iterator = (attributes).iterator();
    assertEquals("Wrong order", "company", iterator.next().getShortName());
    assertEquals("Wrong order", "invoiceAmount", iterator.next().getShortName());
    assertEquals("Wrong order", "invoiceDate", iterator.next().getShortName());

    for (Attribute attribute : attributes) {
        if (attribute.containsDomain()) {
            Domain domain = attribute.getDomain();
            assertNotNull(domain.getShortName());
            assertThat(domain.getValues().size(), is(not(0)));
            assertNotNull("Translation is missing", domain.getTranslation());
        }
    }
}

From source file:org.paxle.core.filter.impl.FilterManager.java

private String[] getFilterContextPIDs(SortedSet<FilterContext> filtersForTarget, boolean inclDisabled) {
    ArrayList<String> filterContextPIDs = new ArrayList<String>(filtersForTarget.size());

    for (FilterContext fContext : filtersForTarget) {
        if (inclDisabled || fContext.isEnabled()) {
            filterContextPIDs.add(fContext.getFilterContextPID());
        }//from ww  w  . ja v  a 2s.  c o  m
    }

    return filterContextPIDs.toArray(new String[filterContextPIDs.size()]);
}