Example usage for java.util Collection toArray

List of usage examples for java.util Collection toArray

Introduction

In this page you can find the example usage for java.util Collection toArray.

Prototype

default <T> T[] toArray(IntFunction<T[]> generator) 

Source Link

Document

Returns an array containing all of the elements in this collection, using the provided generator function to allocate the returned array.

Usage

From source file:com.adito.security.DefaultUserDatabase.java

public final User[] listAllUsers(String filter, int maxResults) throws UserDatabaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("List '" + maxResults + "' users with filter '" + filter + "'");
    }//from  w w w.ja v a  2  s.c  om

    Collection<User> users = filterPrincipals(filter, maxResults, allUsers(), false);
    return users.toArray(new User[users.size()]);
}

From source file:com.adito.security.DefaultUserDatabase.java

public final Role[] listAllRoles(String filter, int maxResults) throws UserDatabaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("List '" + maxResults + "' groups with filter '" + filter + "'");
    }//from   w ww.  j a  v a 2  s  .  c o m

    Collection<Role> roles = filterPrincipals(filter, maxResults, allRoles(), false);
    return roles.toArray(new Role[roles.size()]);
}

From source file:com.smartitengineering.version.impl.jgit.service.impl.MetaRCSServiceImpl.java

public Set<com.smartitengineering.version.api.Revision> searchForRevisions(
        Collection<QueryParameter> parameters) {
    Collection<QueryParameter> params = parameters == null ? Collections.<QueryParameter>emptyList()
            : parameters;/*  ww  w.j  a  v  a2 s.c  o  m*/
    List<Revision> revisions = revisionReader.getList(params.toArray(new QueryParameter[0]));
    LinkedHashSet<com.smartitengineering.version.api.Revision> result = new LinkedHashSet<com.smartitengineering.version.api.Revision>();
    if (revisions != null) {
        for (Revision revision : revisions) {
            result.add(MetaFactory.transformMetaRevision(revision));
        }
    }
    return result;
}

From source file:mml.handler.scratch.ScratchVersionSet.java

/**
 * Create a scratchversionset from a database record
 * @param resource the dbase resource fetched from the database
 * @param dbase the dbase collection name it was from
 *//*from  w w  w.  ja  v  a  2 s  . c  om*/
public ScratchVersionSet(String resource, String dbase) {
    parseResource(resource);
    if (format.contains("MVD")) {
        MVD mvd = MVDFile.internalise(body);
        HashMap<String, ScratchVersion> map = new HashMap<String, ScratchVersion>();
        String[] all = listVersions(mvd);
        for (short i = 1; i <= mvd.numVersions(); i++) {
            String vid = mvd.getVersionId(i);
            String localLongName = mvd.getLongNameForVersion(i);
            // the ONLY names in memory are upgraded ones
            String layerName = Layers.upgradeLayerName(all, vid);
            int num = ScratchVersion.layerNumber(layerName);
            String shortName = Layers.stripLayer(layerName);
            ScratchVersion sv = map.get(shortName);
            char[] data = mvd.getVersion(i);
            if (sv == null) {
                sv = new ScratchVersion(shortName, localLongName, docid, dbase, null, false);
                sv.addLayer(data, num);
                map.put(shortName, sv);
            } else if (!sv.containsLayer(num))
                sv.addLayer(data, num);
        }
        // convert to list
        list = new ScratchVersion[map.size()];
        Collection<ScratchVersion> coll = map.values();
        coll.toArray(list);
    } else // single version/layer
    {
        if (version1 == null)
            version1 = "/base";
        if (docid != null && body != null) {
            String longName = null;
            if (otherFields.containsKey(JSONKeys.LONGNAME))
                longName = (String) otherFields.get(JSONKeys.LONGNAME);
            if (otherFields.containsKey(JSONKeys.DESCRIPTION))
                longName = (String) otherFields.get(JSONKeys.DESCRIPTION);
            if (longName == null)
                longName = "Version " + version1;
            ScratchVersion sv = new ScratchVersion(version1, longName, docid, dbase, null, false);
            sv.addLayer(body.toCharArray(), Integer.MAX_VALUE);
            appendToList(sv);
        }
    }
}

From source file:net.jsign.PESignerCLI.java

/**
 * Load the certificate chain from the specified PKCS#7 files.
 *//*  w  w w. ja  v a 2  s. c  om*/
@SuppressWarnings("unchecked")
private Certificate[] loadCertificateChain(File file) throws IOException, CertificateException {
    FileInputStream in = null;
    try {
        in = new FileInputStream(file);
        CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
        Collection<Certificate> certificates = (Collection<Certificate>) certificateFactory
                .generateCertificates(in);
        return certificates.toArray(new Certificate[certificates.size()]);
    } finally {
        try {
            if (in != null) {
                in.close();
            }
        } catch (IOException e) {
            // ignore
        }
    }
}

From source file:com.wrightfully.sonar.plugins.dotnet.resharper.ReSharperConfiguration.java

private String[] splitUsingSemiColon(String[] strings) {
    Collection<String> resultCollection = Lists.newArrayList();
    for (int i = 0; i < strings.length; i++) {
        resultCollection.addAll(Arrays.asList(StringUtils.split(strings[i], ';')));
    }/*from   w  w w  .ja v a2  s  . c o  m*/
    return resultCollection.toArray(new String[resultCollection.size()]);
}

From source file:io.github.moosbusch.permagon.application.spi.AbstractPermagonApplicationContext.java

private void loadAnnotationConfig(PermagonApplication<? extends PermagonApplicationContext> application) {
    Collection<String> beanPackages = application.getBeanConfigurationPackages();
    Collection<Class<?>> annotatedClasses = application.getBeanConfigurationClasses();

    if (isValidBeanConfigurationClasses(annotatedClasses)) {

        if (!annotatedClasses.isEmpty()) {
            register(annotatedClasses.toArray(new Class[0]));
        }//w w  w.  j  av  a 2  s. c o  m

        if (beanPackages != null) {
            if (!beanPackages.isEmpty()) {
                scan(beanPackages.toArray(new String[0]));
            }
        }

        return;
    }

    throw new IllegalStateException("No configuration-class of type 'JavaFXBeanConfiguration' is defined!");

}

From source file:eu.domibus.submission.jms.BackendJMSImpl.java

/**
 * This method checks for pending messages received by another gateway and processes them to a JMS destination
 *
 * @param ctx/*  w w  w. j  a  v a2 s.  c o m*/
 */
public void executeInternal(final JobExecutionContext ctx) {
    try {

        final Collection<String> ids = this.messageRetriever.listPendingMessages();

        if (!ids.isEmpty() || ids.size() > 0) {
            final String[] messageIds = ids.toArray(new String[ids.size()]);

            Connection connection;
            MessageProducer producer;

            connection = this.cf.createConnection();
            for (final String messageId : messageIds) {
                final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                producer = session.createProducer(this.receivingQueue);
                producer.setDeliveryMode(DeliveryMode.PERSISTENT);
                final MapMessage resMessage = session.createMapMessage();
                this.downloadMessage(messageId, resMessage);
                producer.send(resMessage);
                producer.close();
                session.close();
            }
            connection.close();
        } else {
            BackendJMSImpl.LOG.debug("No pending messages to send");
        }

    } catch (final JMSException | ValidationException ex) {
        BackendJMSImpl.LOG.error(ex);
    }
}

From source file:net.sf.jabref.external.AutoSetExternalFileForEntries.java

@Override
public void init() {

    Collection<BibtexEntry> col = panel.database().getEntries();
    sel = col.toArray(new BibtexEntry[col.size()]);

    // Ask about rules for the operation:
    if (optDiag == null) {
        optDiag = new OptionsDialog(panel.frame(), fieldName);
    }//from  ww w.  ja v a 2  s  . c  o m
    Util.placeDialog(optDiag, panel.frame());
    optDiag.setVisible(true);
    if (optDiag.canceled()) {
        goOn = false;
        return;
    }
    autoSet = !optDiag.autoSetNone.isSelected();
    overWriteAllowed = optDiag.autoSetAll.isSelected();
    checkExisting = optDiag.checkLinks.isSelected();

    panel.output(Localization.lang("Synchronizing %0 links...", fieldName.toUpperCase()));
}