Example usage for java.util SortedSet addAll

List of usage examples for java.util SortedSet addAll

Introduction

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

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:org.drugis.addis.presentation.wizard.NetworkMetaAnalysisWizardPM.java

public boolean rebuildRawAlternativesGraph() {
    if (!d_rebuildRawNeeded) {
        return false;
    }/*from ww  w  .  j av a2s  . co  m*/
    // Determine set of treatment definitions
    SortedSet<TreatmentDefinition> definitions = new TreeSet<TreatmentDefinition>();
    if (d_indicationHolder.getValue() != null && d_outcomeHolder.getValue() != null) {
        for (Study s : getStudiesEndpointAndIndication()) {
            definitions.addAll(s.getMeasuredTreatmentDefinitions(d_outcomeHolder.getValue()));
        }
    }
    d_rawTreatmentDefinitions.clear();
    d_rawTreatmentDefinitions.addAll(definitions);

    // Rebuild the graph
    d_rawAlternativesGraph.rebuildGraph();

    d_rebuildRawNeeded = false;
    return true;
}

From source file:org.dbflute.saflute.web.servlet.filter.RequestLoggingFilter.java

protected SortedSet<?> toSortedSet(final Enumeration<?> enu) {
    final SortedSet<Object> set = new TreeSet<Object>();
    set.addAll(Collections.list(enu));
    return set;//from   www. j av  a  2 s . c om
}

From source file:org.apache.accumulo.core.util.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(Shell.tableOption)) {
        String tableName = cl.getOptionValue(Shell.tableOption);
        if (!shellState.getConnector().tableOperations().exists(tableName)) {
            throw new TableNotFoundException(tableName, tableName, "specified table that doesn't exist");
        }/*from w ww  .  j a  v  a  2 s .  com*/
        tables.add(tableName);
    }

    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());
    }

    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:org.mzd.shap.domain.Feature.java

/**
 * A verbose header for fasta output. /*from  ww w  .j  ava2 s. com*/
 * 
 * When a persistence layer is involved (eg. Hibernate), this method should 
 * only be used when extra detail is necessary. It navigates associations 
 * which will result in additional queries.
 * 
 * @return a verbose header for fasta output.
 */
public String verboseFastaHeader() {
    // Create a header from the available fields
    StringBuffer header = new StringBuffer();

    header.append(getQueryId());

    // Select the top annotation by rank and then alphabetically.
    if (getAnnotations().size() > 0) {
        SortedSet<Annotation> sortedAnno = new TreeSet<Annotation>(new Comparator<Annotation>() {
            public int compare(Annotation a1, Annotation a2) {
                Annotator ar1 = a1.getAnnotator();
                Annotator ar2 = a2.getAnnotator();
                return ar2.getRank().compareTo(ar1.getRank());
            }
        });
        sortedAnno.addAll(getAnnotations());
        Annotation topAnno = sortedAnno.first();
        header.append(" " + Fasta.formatAttribute("acc", topAnno.getAccession()));
        header.append(" " + Fasta.formatAttribute("desc", topAnno.getDescription()));
        header.append(" " + Fasta.formatAttribute("anno",
                topAnno.getAnnotator().getName() + "," + topAnno.getConfidence().toString()));
    }

    if (getAliases().size() > 0) {
        StringBuffer aliases = new StringBuffer();
        for (Iterator<String> it = getAliases().iterator(); it.hasNext();) {
            aliases.append(it.next());
            if (it.hasNext()) {
                aliases.append(",");
            }
        }
        header.append(" " + Fasta.formatAttribute("aliases", aliases.toString()));
    }

    header.append(
            " " + Fasta.formatAttribute("coords", getLocation().getStart() + ".." + getLocation().getEnd()));
    header.append(" " + Fasta.formatAttribute("strand", getLocation().getStrand().toString()));
    header.append(" " + Fasta.formatAttribute("orf_conf", getConfidence().toString()));
    header.append(" " + Fasta.formatAttribute("partial", isPartial().toString()));

    return header.toString();
}

From source file:com.opengamma.financial.analytics.ircurve.CurveSpecificationBuilderConfiguration.java

/**
 * Get all available tenors/*from  w  w w  . j a v a2s.  com*/
 *
 * @return the sorted tenors
 */
public SortedSet<Tenor> getAllTenors() {
    final SortedSet<Tenor> allTenors = new TreeSet<Tenor>();
    if (getBasisSwapInstrumentProviders() != null) {
        allTenors.addAll(getBasisSwapInstrumentProviders().keySet());
    }
    if (getCashInstrumentProviders() != null) {
        allTenors.addAll(getCashInstrumentProviders().keySet());
    }
    if (getCDORInstrumentProviders() != null) {
        allTenors.addAll(getCDORInstrumentProviders().keySet());
    }
    if (getCiborInstrumentProviders() != null) {
        allTenors.addAll(getCiborInstrumentProviders().keySet());
    }
    if (getEuriborInstrumentProviders() != null) {
        allTenors.addAll(getEuriborInstrumentProviders().keySet());
    }
    if (getFra3MInstrumentProviders() != null) {
        allTenors.addAll(getFra3MInstrumentProviders().keySet());
    }
    if (getFra6MInstrumentProviders() != null) {
        allTenors.addAll(getFra6MInstrumentProviders().keySet());
    }
    if (getFutureInstrumentProviders() != null) {
        allTenors.addAll(getFutureInstrumentProviders().keySet());
    }
    if (getLiborInstrumentProviders() != null) {
        allTenors.addAll(getLiborInstrumentProviders().keySet());
    }
    if (getOISSwapInstrumentProviders() != null) {
        allTenors.addAll(getOISSwapInstrumentProviders().keySet());
    }
    if (getStiborInstrumentProviders() != null) {
        allTenors.addAll(getStiborInstrumentProviders().keySet());
    }
    if (getSwap3MInstrumentProviders() != null) {
        allTenors.addAll(getSwap3MInstrumentProviders().keySet());
    }
    if (getSwap6MInstrumentProviders() != null) {
        allTenors.addAll(getSwap6MInstrumentProviders().keySet());
    }
    if (getSwap12MInstrumentProviders() != null) {
        allTenors.addAll(getSwap12MInstrumentProviders().keySet());
    }
    if (getTenorSwapInstrumentProviders() != null) {
        allTenors.addAll(getTenorSwapInstrumentProviders().keySet());
    }
    if (getSimpleZeroDepositInstrumentProviders() != null) {
        allTenors.addAll(getSimpleZeroDepositInstrumentProviders().keySet());
    }
    if (getPeriodicZeroDepositInstrumentProviders() != null) {
        allTenors.addAll(getPeriodicZeroDepositInstrumentProviders().keySet());
    }
    if (getContinuousZeroDepositInstrumentProviders() != null) {
        allTenors.addAll(getContinuousZeroDepositInstrumentProviders().keySet());
    }
    if (getSwap28DInstrumentProviders() != null) {
        allTenors.addAll(getSwap28DInstrumentProviders().keySet());
    }
    return allTenors;
}

From source file:info.rmapproject.core.rmapservice.impl.openrdf.ORMapDiSCOMgr.java

/**
 * Get IRI of next version of a DiSCO.//from  w  ww  .  j a  va  2 s  . c  o m
 *
 * @param discoID  IRI of DISCO
 * @param event2disco Map from events to all versions of DiSCOs
 * @param date2event  Map from date events associated with version of DiSCO
 * @param ts the triplestore instance
 * @return IRI of next version of DiSCO, or null if none found
 * @throws RMapException the RMap exception
 * @throws RMapObjectNotFoundException the RMap object not found exception
 * @throws RMapDefectiveArgumentException the RMap defective argument exception
 */
protected IRI getNextIRI(IRI discoID, Map<IRI, IRI> event2disco, Map<Date, IRI> date2event,
        SesameTriplestore ts)
        throws RMapException, RMapObjectNotFoundException, RMapDefectiveArgumentException {
    if (discoID == null) {
        throw new RMapDefectiveArgumentException("null DiSCO id");
    }
    if (event2disco == null) {
        throw new RMapDefectiveArgumentException("Null event2disco map");
    }
    Map<IRI, IRI> disco2event = Utils.invertMap(event2disco);
    if (date2event == null) {
        date2event = eventmgr.getDate2EventMap(event2disco.keySet(), ts);
    }
    Map<IRI, Date> event2date = Utils.invertMap(date2event);
    IRI discoEventId = disco2event.get(discoID);
    Date eventDate = event2date.get(discoEventId);
    SortedSet<Date> sortedDates = new TreeSet<Date>();
    sortedDates.addAll(date2event.keySet());
    SortedSet<Date> laterDates = sortedDates.tailSet(eventDate);
    IRI nextDiscoId = null;
    if (laterDates.size() > 1) {
        Date[] dateArray = laterDates.toArray(new Date[laterDates.size()]);
        IRI nextEventId = date2event.get(dateArray[1]);
        nextDiscoId = event2disco.get(nextEventId);
    }
    return nextDiscoId;
}

From source file:architecture.common.license.License.java

public byte[] getFingerprint() {
    StringBuffer buf = new StringBuffer(100);
    buf.append(id);//from  ww  w.  jav  a  2  s .  c o m
    buf.append(name);
    buf.append(version);
    buf.append(dateFormat.format(creationDate));
    buf.append(type.name());
    SortedSet<Module> sortedModules = new TreeSet<Module>(new Comparator<Module>() {
        public int compare(Module module, Module module1) {
            return module.name.compareTo(module1.name);
        }
    });

    sortedModules.addAll(modules);

    for (Module m : sortedModules) {
        buf.append(m.name);
    }

    SortedSet<String> sortedKeys = new TreeSet<String>(properties.keySet());
    for (String key : sortedKeys) {
        buf.append(key);
    }

    if (client != null) {
        buf.append(client.getCompany());
        buf.append(client.getName());
        buf.append(client.getUrl());
    }
    try {
        return buf.toString().getBytes(ApplicationConstants.DEFAULT_CHAR_ENCODING);
    } catch (UnsupportedEncodingException ue) {
        log.fatal(ue.getMessage(), ue);
    }
    return buf.toString().getBytes();
}

From source file:pt.ist.expenditureTrackingSystem.presentationTier.actions.statistics.StatisticsAction.java

private Spreadsheet generateSpreadSheet(final SortedMap<Object, BigDecimal> sumMap,
        final SortedMap<Object, BigDecimal> medianMap, final SortedMap<Object, BigDecimal> averageMap,
        final SortedMap<Object, BigDecimal> minsMap, final SortedMap<Object, BigDecimal> maxsMap) {
    final Spreadsheet spreadsheet = new Spreadsheet("Estatsticas");
    spreadsheet.setHeader("Estado");
    spreadsheet.setHeader("Soma");
    spreadsheet.setHeader("Mediana Tempo (em dias)");
    spreadsheet.setHeader("Mdia Tempo (em dias)");
    spreadsheet.setHeader("Tempo Mnimo (em dias)");
    spreadsheet.setHeader("Tempo Mximo (em dias)");
    final SortedSet<Object> types = new TreeSet<Object>();
    types.addAll(sumMap.keySet());
    types.addAll(medianMap.keySet());// w  ww. j a  va2 s.c  o  m
    types.addAll(averageMap.keySet());
    BigDecimal DAYS_CONST = new BigDecimal(1000 * 3600 * 24);
    for (final Object type : types) {
        final BigDecimal sum = sumMap.get(type);
        final BigDecimal median = medianMap.get(type);
        final BigDecimal average = averageMap.get(type);
        final BigDecimal min = minsMap.get(type);
        final BigDecimal max = maxsMap.get(type);

        final Row row = spreadsheet.addRow();
        row.setCell(((IPresentableEnum) type).getLocalizedName());
        row.setCell(sum == null ? "0" : sum.toString());
        row.setCell(median == null ? "" : median.divide(DAYS_CONST, 2, BigDecimal.ROUND_HALF_UP).toString());
        row.setCell(average == null ? "" : average.divide(DAYS_CONST, 2, BigDecimal.ROUND_HALF_UP).toString());
        row.setCell(min == null ? "" : min.divide(DAYS_CONST, 2, BigDecimal.ROUND_HALF_UP).toString());
        row.setCell(max == null ? "" : max.divide(DAYS_CONST, 2, BigDecimal.ROUND_HALF_UP).toString());
    }
    return spreadsheet;
}

From source file:info.rmapproject.core.rmapservice.impl.openrdf.ORMapDiSCOMgr.java

/**
 * Get IRI of previous version of this DiSCO.
 *
 * @param discoID IRI of DiSCO/*from   w  w w  . j ava2  s  .c o  m*/
 * @param event2disco Map from events to all versions of DiSCOs
 * @param date2event  Map from date events associated with version of DiSCO
 * @param ts the triplestore instance
 * @return IRI of previous version of this DiSCO, or null if none found
 * @throws RMapException the RMap exception
 * @throws RMapObjectNotFoundException the RMap object not found exception
 * @throws RMapDefectiveArgumentException the RMap defective argument exception
 */
protected IRI getPreviousIRI(IRI discoID, Map<IRI, IRI> event2disco, Map<Date, IRI> date2event,
        SesameTriplestore ts)
        throws RMapException, RMapObjectNotFoundException, RMapDefectiveArgumentException {
    if (discoID == null) {
        throw new RMapDefectiveArgumentException("null DiSCO id");
    }
    if (event2disco == null) {
        throw new RMapDefectiveArgumentException("Null event2disco map");
    }
    Map<IRI, IRI> disco2event = Utils.invertMap(event2disco);

    if (date2event == null) {
        date2event = eventmgr.getDate2EventMap(event2disco.keySet(), ts);
    }

    Map<IRI, Date> event2date = Utils.invertMap(date2event);

    IRI discoEventId = disco2event.get(discoID);
    Date eventDate = event2date.get(discoEventId);

    SortedSet<Date> sortedDates = new TreeSet<Date>();
    sortedDates.addAll(date2event.keySet());
    SortedSet<Date> earlierDates = sortedDates.headSet(eventDate);
    IRI prevDiscoId = null;
    if (earlierDates.size() > 0) {
        Date previousDate = earlierDates.last();
        IRI prevEventId = date2event.get(previousDate);
        prevDiscoId = event2disco.get(prevEventId);
    }
    return prevDiscoId;
}