Example usage for java.util SortedSet isEmpty

List of usage examples for java.util SortedSet isEmpty

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this set contains no elements.

Usage

From source file:org.torproject.collector.index.CreateIndexJson.java

private DirectoryNode indexDirectory(File directory) {
    SortedSet<FileNode> fileNodes = new TreeSet<FileNode>();
    SortedSet<DirectoryNode> directoryNodes = new TreeSet<DirectoryNode>();
    logger.trace("indexing: " + directory);
    File[] fileList = directory.listFiles();
    if (null == fileList) {
        logger.warn("Indexing dubious directory: " + directory);
        return null;
    }/*w  w w  .j  ava 2 s .co m*/
    for (File fileOrDirectory : fileList) {
        if (fileOrDirectory.getName().startsWith(".") || fileOrDirectory.getName().endsWith(".tmp")) {
            continue;
        }
        if (fileOrDirectory.isFile()) {
            fileNodes.add(indexFile(fileOrDirectory));
        } else {
            DirectoryNode dn = indexDirectory(fileOrDirectory);
            if (null != dn) {
                directoryNodes.add(dn);
            }
        }
    }
    DirectoryNode directoryNode = new DirectoryNode(directory.getName(), fileNodes.isEmpty() ? null : fileNodes,
            directoryNodes.isEmpty() ? null : directoryNodes);
    return directoryNode;
}

From source file:org.apache.hadoop.hbase.regionserver.Memcache.java

private boolean remove(final NavigableSet<KeyValue> set, final KeyValue kv) {
    SortedSet<KeyValue> s = set.tailSet(kv);
    if (s.isEmpty()) {
        return false;
    }//from  w ww.ja va2s . co m
    boolean removed = false;
    for (KeyValue k : s) {
        if (this.comparatorIgnoreType.compare(k, kv) == 0) {
            // Same r/c/ts.  Remove it.
            s.remove(k);
            removed = true;
            continue;
        }
        break;
    }
    return removed;
}

From source file:org.orcid.persistence.adapter.impl.Jpa2JaxbAdapterImpl.java

private Applications getApplications(ProfileEntity profileEntity) {
    Set<OrcidOauth2TokenDetail> tokenDetails = profileEntity.getTokenDetails();
    if (tokenDetails != null && !tokenDetails.isEmpty()) {
        Applications applications = new Applications();
        for (OrcidOauth2TokenDetail tokenDetail : tokenDetails) {
            if (tokenDetail.getTokenDisabled() == null || !tokenDetail.getTokenDisabled()) {
                ApplicationSummary applicationSummary = new ApplicationSummary();
                ClientDetailsEntity acceptedClient = tokenDetail.getClientDetailsEntity();

                ProfileEntity acceptedClientProfileEntity = acceptedClient != null
                        ? acceptedClient.getProfileEntity()
                        : null;/*w  w w.  jav a2 s .c om*/
                if (acceptedClientProfileEntity != null) {
                    applicationSummary.setApplicationOrcid(new ApplicationOrcid(acceptedClient.getClientId()));
                    applicationSummary.setApplicationName(
                            new ApplicationName(acceptedClientProfileEntity.getCreditName()));
                    SortedSet<ResearcherUrlEntity> researcherUrls = acceptedClient.getProfileEntity()
                            .getResearcherUrls();
                    if (researcherUrls != null && !researcherUrls.isEmpty()) {
                        applicationSummary
                                .setApplicationWebsite(new ApplicationWebsite(researcherUrls.first().getUrl()));
                    }
                    applicationSummary.setApprovalDate(new ApprovalDate(
                            DateUtils.convertToXMLGregorianCalendar(tokenDetail.getDateCreated())));

                    // Scopes
                    Set<ScopePathType> scopesGrantedToClient = ScopePathType
                            .getScopesFromSpaceSeparatedString(tokenDetail.getScope());
                    if (scopesGrantedToClient != null && !scopesGrantedToClient.isEmpty()) {
                        ScopePaths scopePaths = new ScopePaths();
                        for (ScopePathType scopesForClient : scopesGrantedToClient) {
                            scopePaths.getScopePath().add(new ScopePath(scopesForClient));
                        }

                        applicationSummary.setScopePaths(scopePaths);
                    }
                    applications.getApplicationSummary().add(applicationSummary);
                }

            }
        }
        return applications;
    }
    return null;
}

From source file:com.android.mms.transaction.MessagingNotification.java

/**
 * Checks to see if there are any "unseen" messages or delivery
 * reports and builds a sorted (by delivery date) list of unread notifications.
 *
 * @param context the context to use//from ww  w .ja  v  a 2  s .  c  om
 * @param newMsgThreadId The thread ID of a new message that we're to notify about; if there's
 *  no new message, use THREAD_NONE. If we should notify about multiple or unknown thread IDs,
 *  use THREAD_ALL.
 * @param isStatusMessage
 */
public static void blockingUpdateNewMessageIndicator(Context context, long newMsgThreadId,
        boolean isStatusMessage) {
    if (DEBUG) {
        Contact.logWithTrace(TAG, "blockingUpdateNewMessageIndicator: newMsgThreadId: " + newMsgThreadId);
    }
    final boolean isDefaultSmsApp = MmsConfig.isSmsEnabled(context);
    if (!isDefaultSmsApp) {
        cancelNotification(context, NOTIFICATION_ID);
        if (DEBUG || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
            Log.d(TAG,
                    "blockingUpdateNewMessageIndicator: not the default sms app - skipping " + "notification");
        }
        return;
    }

    // notificationSet is kept sorted by the incoming message delivery time, with the
    // most recent message first.
    SortedSet<NotificationInfo> notificationSet = new TreeSet<NotificationInfo>(INFO_COMPARATOR);

    Set<Long> threads = new HashSet<Long>(4);

    addMmsNotificationInfos(context, threads, notificationSet);
    addSmsNotificationInfos(context, threads, notificationSet);

    if (notificationSet.isEmpty()) {
        if (DEBUG) {
            Log.d(TAG, "blockingUpdateNewMessageIndicator: notificationSet is empty, "
                    + "canceling existing notifications");
        }
        cancelNotification(context, NOTIFICATION_ID);
    } else {
        if (DEBUG || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
            Log.d(TAG, "blockingUpdateNewMessageIndicator: count=" + notificationSet.size()
                    + ", newMsgThreadId=" + newMsgThreadId);
        }

        if (isInCurrentConversation(newMsgThreadId, threads)) {
            if (DEBUG) {
                Log.d(TAG,
                        "blockingUpdateNewMessageIndicator: newMsgThreadId == "
                                + "sCurrentlyDisplayedThreadId so NOT showing notification,"
                                + " but playing soft sound. threadId: " + newMsgThreadId);
            }
            playInConversationNotificationSound(context, newMsgThreadId);
            return;
        }
        updateNotification(context, newMsgThreadId, threads.size(), notificationSet);
    }

    // And deals with delivery reports (which use Toasts). It's safe to call in a worker
    // thread because the toast will eventually get posted to a handler.
    MmsSmsDeliveryInfo delivery = getSmsNewDeliveryInfo(context);
    if (delivery != null) {
        delivery.deliver(context, isStatusMessage);
    }

    notificationSet.clear();
    threads.clear();
}

From source file:org.apache.accumulo.shell.commands.DUCommand.java

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
        throws IOException, TableNotFoundException, NamespaceNotFoundException {

    final SortedSet<String> tables = new TreeSet<String>(Arrays.asList(cl.getArgs()));

    if (cl.hasOption(ShellOptions.tableOption)) {
        tables.add(cl.getOptionValue(ShellOptions.tableOption));
    }/*from   ww  w .  j a  v  a2s .c o  m*/

    if (cl.hasOption(optNamespace.getOpt())) {
        Instance instance = shellState.getInstance();
        String namespaceId = Namespaces.getNamespaceId(instance, cl.getOptionValue(optNamespace.getOpt()));
        tables.addAll(Namespaces.getTableNames(instance, namespaceId));
    }

    boolean prettyPrint = cl.hasOption(optHumanReadble.getOpt()) ? true : false;

    // Add any patterns
    if (cl.hasOption(optTablePattern.getOpt())) {
        for (String table : shellState.getConnector().tableOperations().list()) {
            if (table.matches(cl.getOptionValue(optTablePattern.getOpt()))) {
                tables.add(table);
            }
        }
    }

    // If we didn't get any tables, and we have a table selected, add the current table
    if (tables.isEmpty() && !shellState.getTableName().isEmpty()) {
        tables.add(shellState.getTableName());
    }

    // sanity check...make sure the user-specified tables exist
    for (String tableName : tables) {
        if (!shellState.getConnector().tableOperations().exists(tableName)) {
            throw new TableNotFoundException(tableName, tableName, "specified table that doesn't exist");
        }
    }

    try {
        String valueFormat = prettyPrint ? "%9s" : "%,24d";
        for (DiskUsage usage : shellState.getConnector().tableOperations().getDiskUsage(tables)) {
            Object value = prettyPrint ? NumUtil.bigNumberForSize(usage.getUsage()) : usage.getUsage();
            shellState.getReader().println(String.format(valueFormat + " %s", value, usage.getTables()));
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    return 0;
}

From source file:net.sf.jasperreports.engine.export.tabulator.Tabulator.java

protected boolean placeElement(Table table, FrameCell parentCell, int xOffset, int yOffset,
        JRPrintElement element, PrintElementIndex parentIndex, int elementIndex, boolean allowOverlap) {
    DimensionRange<Column> colRange = table.columns.getRange(element.getX() + xOffset,
            element.getX() + element.getWidth() + xOffset);
    DimensionRange<Row> rowRange = table.rows.getRange(element.getY() + yOffset,
            element.getY() + element.getHeight() + yOffset);

    if (log.isTraceEnabled()) {
        log.trace("placing element " + element.getUUID() + " at " + colRange.start + ", " + colRange.end + ", "
                + rowRange.start + ", " + rowRange.end);
    }/*from www  .  j  a v  a2 s  .c o m*/

    boolean overlap = false;
    Bounds overlapBounds = new Bounds(colRange.start, colRange.end, rowRange.start, rowRange.end);

    JROrigin elementOrigin = element.getOrigin();
    if (parentCell == null // top level element
            && elementOrigin != null && elementOrigin.getReportName() == null
            // master background element
            // TODO lucianc do something for subreport background bands as well
            && elementOrigin.getBandTypeValue() == BandTypeEnum.BACKGROUND) {
        // create a layer as big as the table for the master background band
        SortedSet<Column> userColumns = table.columns.getUserEntries();
        SortedSet<Row> userRows = table.rows.getUserEntries();
        // check if we have something in the table
        if (!userColumns.isEmpty() && !userRows.isEmpty()) {
            overlapBounds.grow(userColumns.first().startCoord, userColumns.last().endCoord,
                    userRows.first().startCoord, userRows.last().endCoord);
            // TODO lucianc avoid the following cell overlap checks
        }
    }

    Bounds covered = null;
    Bounds originalBounds;

    overlapLoop: do {
        originalBounds = overlapBounds.cloneBounds();

        if (rowRange.start != overlapBounds.getStartY() || rowRange.end != overlapBounds.getEndY()) {
            rowRange = table.rows.getRange(overlapBounds.getStartY(), overlapBounds.getEndY());
        }
        if (colRange.start != overlapBounds.getStartX() || colRange.end != overlapBounds.getEndX()) {
            colRange = table.columns.getRange(overlapBounds.getStartX(), overlapBounds.getEndX());
        }

        for (Row row : rowRange.rangeSet) {
            for (Column col : colRange.rangeSet) {
                if (covered != null
                        && covered.contains(col.startCoord, col.endCoord, row.startCoord, row.endCoord)) {
                    //we've been here before
                    continue;
                }

                Cell cell = row.getCell(col);
                if (!canOverwrite(cell, parentCell)) {
                    overlap = true;
                    if (!allowOverlap) {
                        break overlapLoop;
                    }

                    // TODO lucianc see if we can avoid some of these checks
                    Cell overlapParentCell = overlapParentCell(cell, parentCell);
                    Pair<Column, Column> colSpanRange = getColumnSpanRange(table, col, row, overlapParentCell);
                    Pair<Row, Row> rowSpanRange = getRowSpanRange(table, col, row, overlapParentCell);

                    if (log.isTraceEnabled()) {
                        log.trace("found overlap with cell " + cell + ", overlap parent " + overlapParentCell
                                + ", column span range " + colSpanRange.first().startCoord + " to "
                                + colSpanRange.second().startCoord + ", row span range "
                                + rowSpanRange.first().startCoord + " to " + rowSpanRange.second().startCoord);
                    }

                    overlapBounds.grow(colSpanRange.first().startCoord, colSpanRange.second().startCoord,
                            rowSpanRange.first().startCoord, rowSpanRange.second().startCoord);
                }
            }
        }

        covered = originalBounds;
    } while (!originalBounds.equals(overlapBounds));

    if (!overlap) {
        setElementCells(table, parentCell, xOffset, yOffset, element, parentIndex, elementIndex, colRange,
                rowRange);
        return true;
    }

    if (!allowOverlap) {
        return false;
    }

    placeOverlappedElement(table, parentCell, xOffset, yOffset, element, parentIndex, elementIndex,
            overlapBounds);
    return true;
}

From source file:de.interactive_instruments.ShapeChange.Target.Mapping.Excel.java

public void process(ClassInfo ci) {
    int cat = ci.category();
    if (cat != Options.FEATURE && cat != Options.OBJECT && cat != Options.MIXIN && cat != Options.DATATYPE
            && cat != Options.BASICTYPE && cat != Options.UNION) {
        return;//  w ww  .  j a v a 2 s. c  o  m
    }
    if (ci.isAbstract())
        return;

    Element e1, e2, e3;

    e1 = document.createElementNS(NS_SS, "Row");
    addAttribute(document, e1, "ss:AutoFitHeight", "1");
    addAttribute(document, e1, "ss:Height", "20.0");
    table.appendChild(e1);

    int rows = createAllPropertyDefinitions(pi, ci, true);

    // Loop over all constraints
    List<Constraint> constraints = ci.constraints();
    for (Constraint co : constraints) {
        rows += createConstraintDefinition(pi, ci, co);
    }

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s4");
    addAttribute(document, e2, "ss:MergeDown", "" + rows);
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);

    Element e4;
    e4 = document.createElementNS(NS_HTML, "B");
    e4.appendChild(document.createTextNode(ci.name()));
    e3.appendChild(e4);

    SortedSet<String> st = ci.supertypes();
    if (st != null && !st.isEmpty()) {

        e3.appendChild(document.createTextNode("\r\r"));

        e4 = document.createElementNS(NS_HTML, "Font");
        addAttribute(document, e4, "html:Size", "8.0");
        addAttribute(document, e4, "html:Color", "#808080");
        e4.appendChild(document.createTextNode("Supertypes:"));
        e3.appendChild(e4);
        e4 = document.createElementNS(NS_HTML, "Font");
        addAttribute(document, e4, "html:Size", "8.0");
        addAttribute(document, e4, "html:Color", "#0000FF");
        supertypelist(e4, st);
        e3.appendChild(e4);
    }

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s5");
    addAttribute(document, e2, "ss:MergeDown", "" + rows);
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    String s = ci.derivedDocumentation(documentationTemplate, documentationNoValue);
    e3.appendChild(document.createTextNode(s));

    for (int i = 0; i < 5; i++) {
        e2 = document.createElementNS(NS_SS, "Cell");
        addAttribute(document, e2, "ss:StyleID", "s5");
        e1.appendChild(e2);
    }

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s1");
    e1.appendChild(e2);

    for (int i = 0; i < 9; i++) {
        e2 = document.createElementNS(NS_SS, "Cell");
        addAttribute(document, e2, "ss:StyleID", "s5");
        e1.appendChild(e2);
    }

    e1 = document.createElementNS(NS_SS, "Row");
    addAttribute(document, e1, "ss:Height", "5.0");
    table.appendChild(e1);

    for (int i = 0; i < 7; i++) {
        e2 = document.createElementNS(NS_SS, "Cell");
        addAttribute(document, e2, "ss:StyleID", "s3");
        e1.appendChild(e2);
    }

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s1");
    e1.appendChild(e2);

    for (int i = 0; i < 9; i++) {
        e2 = document.createElementNS(NS_SS, "Cell");
        addAttribute(document, e2, "ss:StyleID", "s3");
        e1.appendChild(e2);
    }

}

From source file:org.commoncrawl.io.internal.NIODNSCache.java

private void setCannonicalNameForNode(Node node, String cName) {
    SortedSet<String> subset = _cannonicalNames.subSet(cName, cName + "\0");
    if (!subset.isEmpty()) {
        node._cannonicalName = subset.first();
    } else {//  www. j a  va 2s .co m
        node._cannonicalName = cName;
        _cannonicalNames.add(cName);
    }
}

From source file:com.silverpeas.whitePages.control.WhitePagesSessionController.java

public SortedSet<SearchField> getSearchFields() throws UtilException, WhitePagesException {
    SortedSet<SearchField> fields = ServicesFactory.getFactory().getWhitePagesService()
            .getSearchFields(getComponentId());
    if (!fields.isEmpty()) {
        PublicationTemplate template = null;
        Map<String, String> domainProperties = null;
        try {//from   w w  w.  j ava 2 s.  c om
            RecordTemplate recordTemplate = null;
            for (SearchField field : fields) {
                if (field.getFieldId().startsWith(SearchFieldsType.XML.getLabelType())) {
                    if (template == null) {
                        template = getTemplate(getComponentId());
                        recordTemplate = template.getRecordTemplate();
                    }
                    field.setLabel(
                            recordTemplate.getFieldTemplate(field.getFieldName()).getLabel(getLanguage()));
                } else if (field.getFieldId().startsWith(SearchFieldsType.LDAP.getLabelType())) {
                    if (domainProperties == null) {
                        domainProperties = getDomainProperties();
                    }
                    field.setLabel(domainProperties.get(field.getFieldName()));
                } else if (field.getFieldId().startsWith(SearchFieldsType.USER.getLabelType())) {
                    if (field.getFieldName().equals("name")) {
                        field.setLabel(GeneralPropertiesManager.getGeneralMultilang(getLanguage())
                                .getString("GML.lastName"));
                    } else if (field.getFieldName().equals("surname")) {
                        field.setLabel(GeneralPropertiesManager.getGeneralMultilang(getLanguage())
                                .getString("GML.surname"));
                    } else if (field.getFieldName().equals("email")) {
                        field.setLabel(GeneralPropertiesManager.getGeneralMultilang(getLanguage())
                                .getString("GML.eMail"));
                    }
                }
            }
        } catch (Exception e) {
            SilverTrace.error("whitePages", "WhitePagesSessionController.getSearchFields",
                    "whitePages.CANT_GET_XML_FIELDS", e);
        }
    }
    return fields;
}