Example usage for java.util LinkedList addLast

List of usage examples for java.util LinkedList addLast

Introduction

In this page you can find the example usage for java.util LinkedList addLast.

Prototype

public void addLast(E e) 

Source Link

Document

Appends the specified element to the end of this list.

Usage

From source file:ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixColumnSort.java

/**
 * @return list of factors, sorted from simplest (fewest number of values from the biomaterials passed in) to least
 * simple. Continuous factors will always be first, and batch factors last.
 *///from  w  w w.j  a v  a  2s.c  om
private static List<ExperimentalFactor> orderFactorsByExperimentalDesign(List<BioMaterial> start,
        Collection<ExperimentalFactor> factors) {

    if (factors == null || factors.isEmpty()) {
        ExpressionDataMatrixColumnSort.log.warn("No factors supplied for sorting");
        return new LinkedList<>();
    }

    LinkedList<ExperimentalFactor> sortedFactors = new LinkedList<>();
    Collection<ExperimentalFactor> factorsToTake = new HashSet<>(factors);
    while (!factorsToTake.isEmpty()) {
        ExperimentalFactor simplest = ExpressionDataMatrixColumnSort.chooseSimplestFactor(start, factorsToTake);
        if (simplest == null) {
            // none of the factors have more than one factor value. One-sided t-tests ...

            /*
             * This assertion isn't right -- we now allow this, though we can only have ONE such constant factor.
             * See bug 2390. Unless we are dealing with a subset, in which case there can be any number of constant
             * factors within the subset.
             */
            // assert factors.size() == 1 :
            // "It's possible to have just one factor value, but only if there is only one factor.";

            sortedFactors.addAll(factors);
            return sortedFactors;
        }
        sortedFactors.addLast(simplest);

        factorsToTake.remove(simplest);
    }

    return sortedFactors;
}

From source file:com.rapidminer.operator.preprocessing.discretization.MinimalEntropyDiscretization.java

/**
 * Delivers the maximum range thresholds for all attributes, i.e. the value getRanges()[a][b] is
 * the b-th threshold for the a-th attribute.
 *
 * @throws UserError/*www  . j a v a2s.  c o  m*/
 *             is label is missing
 */
private double[][] getRanges(ExampleSet exampleSet) throws UserError {
    double[][] ranges = new double[exampleSet.getAttributes().size()][];
    Attribute label = exampleSet.getAttributes().getLabel();
    if (label == null) {
        throw new UserError(this, 105);
    }

    int a = 0;
    for (Attribute attribute : exampleSet.getAttributes()) {
        if (attribute.isNumerical()) { // skip nominal and date attributes
            Iterator<Example> reader = exampleSet.iterator();
            LinkedList<double[]> startPartition = new LinkedList<double[]>();
            while (reader.hasNext()) { // Create start partition.
                Example example = reader.next();
                double[] attributeLabelPair = new double[2];
                attributeLabelPair[0] = example.getValue(attribute);
                attributeLabelPair[1] = example.getValue(label);
                startPartition.addLast(attributeLabelPair);
            }
            ArrayList<Double> splitpointsOfAttribute = getSplitpoints(startPartition, label);
            Iterator<Double> it = splitpointsOfAttribute.iterator();
            ranges[a] = new double[splitpointsOfAttribute.size() + 1];
            for (int i = 0; it.hasNext(); i++) {
                ranges[a][i] = it.next();
            }
            ranges[a][ranges[a].length - 1] = exampleSet.getStatistics(attribute, Statistics.MAXIMUM);
            Arrays.sort(ranges[a]);
        }
        a++;
    }
    return ranges;
}

From source file:org.openxdm.xcap.client.test.error.NotFoundTest.java

@Test
public void test() throws HttpException, IOException, JAXBException, InterruptedException {

    // exception for response codes

    NotFoundException exception = new NotFoundException();

    // create content for tests      

    String documentContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
            + "<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\">" + "<list/>"
            + "</resource-lists>";

    String elementContent = "<list xmlns=\"urn:ietf:params:xml:ns:resource-lists\"/>";

    // create uri keys
    UserDocumentUriKey documentKey = new UserDocumentUriKey(appUsage.getAUID(), user, documentName);
    UserDocumentUriKey fakeAppUsageDocumentKey = new UserDocumentUriKey("eduardomartinsappusage", user,
            documentName);/*from  ww w.j av a  2s . c  o  m*/

    LinkedList<ElementSelectorStep> elementSelectorSteps = new LinkedList<ElementSelectorStep>();
    ElementSelectorStep step1 = new ElementSelectorStep("resource-lists");
    ElementSelectorStep step2 = new ElementSelectorStepByPos("list", 2);
    elementSelectorSteps.add(step1);
    elementSelectorSteps.addLast(step2);
    ElementSelector elementSelector = new ElementSelector(elementSelectorSteps);

    UserElementUriKey elementParentKey = new UserElementUriKey(appUsage.getAUID(), user, documentName,
            elementSelector, null);

    UserAttributeUriKey attrWithElementKey = new UserAttributeUriKey(appUsage.getAUID(), user, documentName,
            elementSelector, new AttributeSelector("name"), null);
    UserAttributeUriKey fakeAppUsageAttrWithElementKey = new UserAttributeUriKey("eduardomartinsappusage", user,
            documentName, elementSelector, new AttributeSelector("name"), null);

    ElementSelectorStep step3 = new ElementSelectorStep("display-name");
    elementSelectorSteps.addLast(step3);
    elementSelector = new ElementSelector(elementSelectorSteps);

    UserElementUriKey elementKey = new UserElementUriKey(appUsage.getAUID(), user, documentName,
            elementSelector, null);
    UserElementUriKey fakeAppUsageElementKey = new UserElementUriKey("eduardomartinsappusage", user,
            documentName, elementSelector, null);

    UserAttributeUriKey attrWithoutElementKey = new UserAttributeUriKey(appUsage.getAUID(), user, documentName,
            elementSelector, new AttributeSelector("name"), null);

    // DOCUMENT PARENT NOT FOUND

    client.put(documentKey, appUsage.getMimetype(), documentContent, null);
    client.delete(documentKey, null);

    // 1. get document and document parent not found

    // send get request and get response
    Response response = client.get(fakeAppUsageDocumentKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 2. delete document and document parent not found

    // send delete request and get response
    response = client.delete(fakeAppUsageDocumentKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 3. get element and document parent not found

    // send get request and get response
    response = client.get(fakeAppUsageElementKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 4. delete element and document parent not found

    // send delete request and get response
    response = client.delete(fakeAppUsageElementKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 5. get attribute and document parent not found

    // send get request and get response
    response = client.get(fakeAppUsageAttrWithElementKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 6. delete attribute and document parent not found

    // send delete request and get response
    response = client.delete(fakeAppUsageAttrWithElementKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // DOCUMENT NOT FOUND

    // 7. get document and document not found

    // send get request and get response
    response = client.get(documentKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 8. delete document and document not found

    // send delete request and get response
    response = client.delete(documentKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 9. get element and document not found

    // send get request and get response
    response = client.get(elementKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 10. delete element and document not found

    // send delete request and get response
    response = client.delete(elementKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 11. get attribute and document not found

    // send get request and get response
    response = client.get(attrWithElementKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 12. delete attribute and document not found

    // send delete request and get response
    response = client.delete(attrWithElementKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // ELEMENT PARENT NOT FOUND

    // send put request and get response
    response = client.put(documentKey, appUsage.getMimetype(), documentContent, null);
    // check put response
    assertTrue("Put response must exists", response != null);
    assertTrue("Put response code should be 201", response.getCode() == 201);

    // 13. get element and element parent not found

    // send get request and get response
    response = client.get(elementParentKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 14. get attribute and element parent not found

    // send get request and get response
    response = client.get(attrWithoutElementKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 15. delete element and element parent not found

    // send delete request and get response
    response = client.delete(elementParentKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 16. delete attribute and element parent not found

    // send delete request and get response
    response = client.delete(attrWithoutElementKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // ELEMENT NOT FOUND

    // send put request and get response
    response = client.put(elementParentKey, ElementResource.MIMETYPE, elementContent, null);
    // check put response
    assertTrue("Put response must exists", response != null);
    assertTrue("Put response code should be 201", response.getCode() == 201);

    // 17. get element and element not found

    // send get request and get response
    response = client.get(elementKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 18. delete element and element not found

    // send delete request and get response
    response = client.delete(elementKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 19. get attribute and element not found

    // send get request and get response
    response = client.get(attrWithoutElementKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 20. delete attribute and element not found

    // send delete request and get response
    response = client.delete(attrWithoutElementKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // ATTRIBUTE NOT FOUND

    // 21. get attribute and attribute not found

    // send get request and get response
    response = client.get(attrWithElementKey, null);
    // check get response
    assertTrue("Get response must exists", response != null);
    assertTrue("Get response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // 22. delete attribute and attribute not found

    // send delete request and get response
    response = client.delete(attrWithElementKey, null);
    // check delete response
    assertTrue("Delete response must exists", response != null);
    assertTrue("Delete response code should be " + exception.getResponseStatus(),
            response.getCode() == exception.getResponseStatus());

    // clean up
    client.delete(documentKey, null);
}

From source file:org.gcaldaemon.core.notifier.GmailNotifier.java

public final void run() {
    log.info("Gmail notifier started successfully.");
    try {//  ww w . j  a v  a 2 s . com
        sleep(7000);
    } catch (Exception ignored) {
        return;
    }

    // Processed (displayed) mails
    HashSet processedMails = new HashSet();

    // Polling mailbox
    int i;
    for (;;) {
        try {

            // Verify local username
            if (users != null) {

                // List active users
                String[] activeUsers = getActiveUsers();
                boolean enabled = false;
                if (activeUsers != null && activeUsers.length != 0) {
                    for (i = 0; i < activeUsers.length; i++) {
                        enabled = isUserMatch(activeUsers[i]);
                        if (enabled) {
                            break;
                        }
                    }
                    if (!enabled) {

                        // Sleep for a minute
                        log.debug("Access denied for active local users.");
                        sleep(MINUTE);

                        // Restart loop (verify username)
                        continue;
                    }
                }
            }

            // Get Gmail address book (or null)
            GmailContact[] contacts = configurator.getAddressBook();
            GmailContact contact;

            // Load feed entries
            SyndEntry[] entries = FeedUtilities.getFeedEntries(FEED_URL, username, password);
            SyndEntry entry;
            HashSet newMails = new HashSet();
            for (i = 0; i < entries.length; i++) {
                entry = entries[i];
                String date = getDate(entry);
                String from = getFrom(entry);
                if (contacts != null) {
                    for (int n = 0; n < contacts.length; n++) {
                        contact = contacts[n];
                        if (from.equalsIgnoreCase(contact.email)) {
                            from = contact.name;
                            break;
                        }
                    }
                }
                String title = getTitle(entry);
                if (mailtermSubject != null) {
                    if (title.equals(mailtermSubject) || title.equals("Re:" + mailtermSubject)) {

                        // Do not display mailterm commands and responses
                        continue;
                    }
                }
                String summary = getSummary(entry);
                newMails.add(date + '\t' + from + '\t' + title + '\t' + summary);
            }

            // Remove readed mails
            Iterator iterator = processedMails.iterator();
            Object key;
            while (iterator.hasNext()) {
                key = iterator.next();
                if (!newMails.contains(key)) {
                    iterator.remove();
                }
            }

            // Look up unprocessed mails
            LinkedList unprocessedMails = new LinkedList();
            iterator = newMails.iterator();
            while (iterator.hasNext()) {
                key = iterator.next();
                if (processedMails.contains(key)) {
                    continue;
                }
                processedMails.add(key);
                unprocessedMails.addLast(key);
            }

            // Display unprocessed mails
            if (!unprocessedMails.isEmpty()) {

                String[] array = new String[unprocessedMails.size()];
                unprocessedMails.toArray(array);
                Arrays.sort(array, String.CASE_INSENSITIVE_ORDER);
                window.show(array);
            }

            // Sleep
            sleep(pollingTimeout);

        } catch (InterruptedException interrupt) {

            // Dispose window
            if (window != null) {
                try {
                    window.setVisible(false);
                } catch (Exception ignored) {
                }
            }
            break;
        } catch (Exception loadError) {
            log.error("Unable to load Gmail feed!", loadError);
            try {
                sleep(HOUR);
            } catch (Exception interrupt) {
                return;
            }
        }
    }
}

From source file:com.multimedia.service.wallpaper.CmsWallpaperService.java

@Override
public List<UploadBean> createPageFolders() {
    OnlyFilesFilter filenameFilter = new OnlyFilesFilter();
    //getting layered pages
    List<Pages> pages = getCategoriesLayered();
    //creating vector for results
    LinkedList<UploadBean> rez = new LinkedList<UploadBean>();
    //creating an upload dir if it doesn't exists
    File upload_dir = new File(wallpaper_service.getUploadPath());
    if (!upload_dir.exists())
        upload_dir.mkdirs();/*from w  w  w .j ava  2s.  c  o m*/
    //for saving parent catalogues
    Long last_layer = Long.valueOf(-1);
    LinkedList<File> parents = new LinkedList<File>();
    parents.addLast(upload_dir);
    for (Pages p : pages) {
        while (p.getLayer() <= last_layer) {
            //removing last parent
            parents.removeLast();
            last_layer--;
        }
        boolean b = false;
        File cur_dir = new File(parents.getLast(),
                String.valueOf(p.getId()) + "_" + FileUtils.toTranslit(p.getName()));
        if (cur_dir.exists()) {
            if (!cur_dir.isDirectory()) {
                cur_dir.delete();
                b = cur_dir.mkdir();
            }
        } else {
            b = cur_dir.mkdir();
        }
        createDescriptionFile(cur_dir, p.getId(), p.getName(), false);

        UploadBean ub = new UploadBean();
        ub.setId(p.getId());
        ub.setFolder_name(cur_dir.getName());
        ub.setPage_name(p.getName());
        ub.setItem_count(cur_dir.listFiles(filenameFilter).length - 1);
        rez.addLast(ub);

        parents.addLast(cur_dir);
        last_layer = p.getLayer();
    }
    return rez;
}

From source file:org.springframework.cloud.dataflow.server.service.impl.DefaultSkipperStreamService.java

private void updateStreamDefinitionFromReleaseManifest(String streamName, String releaseManifest) {

    List<SpringCloudDeployerApplicationManifest> appManifests = new SpringCloudDeployerApplicationManifestReader()
            .read(releaseManifest);//w  ww. j  ava2  s  .  c o  m

    Map<String, SpringCloudDeployerApplicationManifest> appManifestMap = new HashMap<>();

    for (SpringCloudDeployerApplicationManifest am : appManifests) {
        String name = am.getSpec().getApplicationProperties().get(DataFlowPropertyKeys.STREAM_APP_LABEL);
        appManifestMap.put(name, am);
    }

    StreamDefinition streamDefinition = this.streamDefinitionRepository.findOne(streamName);

    LinkedList<StreamAppDefinition> updatedStreamAppDefinitions = new LinkedList<>();
    for (StreamAppDefinition appDefinition : streamDefinition.getAppDefinitions()) {
        StreamAppDefinition.Builder appDefinitionBuilder = StreamAppDefinition.Builder.from(appDefinition);
        SpringCloudDeployerApplicationManifest applicationManifest = appManifestMap
                .get(appDefinition.getName());
        // overrides app definition properties with those from the release manifest
        appDefinitionBuilder.setProperties(applicationManifest.getSpec().getApplicationProperties());
        updatedStreamAppDefinitions.addLast(appDefinitionBuilder.build(streamDefinition.getName()));
    }

    String dslText = new StreamDefinitionToDslConverter().toDsl(updatedStreamAppDefinitions);

    StreamDefinition updatedStreamDefinition = new StreamDefinition(streamName, dslText);
    logger.debug("Updated StreamDefinition: " + updatedStreamDefinition);

    // TODO consider adding an explicit UPDATE method to the streamDefRepository
    // Note: Not transactional and can lead to loosing the stream definition
    this.streamDefinitionRepository.delete(updatedStreamDefinition);
    this.streamDefinitionRepository.save(updatedStreamDefinition);
}

From source file:org.guzz.transaction.AbstractTranSessionImpl.java

/**
 * @param bsql//from w  ww.  j  ava 2  s. c  om
 * @param startPos 1
 * @param maxSize
 **/
public List list(BindedCompiledSQL bsql, int startPos, int maxSize) {
    ObjectMapping m = bsql.getCompiledSQLToRun().getMapping();
    String rawSQL = bsql.getSQLToRun();
    if (m == null) {
        throw new ORMException("ObjectMapping is null. sql is:" + rawSQL);
    }

    RowDataLoader loader = bsql.getRowDataLoader();

    DBGroup db = m.getDbGroup();
    Dialect dialect = m.getDbGroup().getDialect();

    //?
    LockMode lock = bsql.getLockMode();

    if (lock == LockMode.UPGRADE) {
        rawSQL = dialect.getForUpdateString(rawSQL);
    } else if (lock == LockMode.UPGRADE_NOWAIT) {
        rawSQL = dialect.getForUpdateNoWaitString(rawSQL);
    }

    //TODO: check if the defaultDialect supports prepared bind in limit clause, and put the limit to compiledSQL

    //add limit clause.   
    if (!(startPos == 1 && maxSize == Integer.MAX_VALUE)) {
        rawSQL = db.getDialect().getLimitedString(rawSQL, startPos - 1, maxSize);
    }

    boolean measureTime = this.debugService.isMeasureTime();
    long startTime = 0L;
    if (measureTime) {
        startTime = System.nanoTime();
    }

    PreparedStatement pstm = null;
    ResultSet rs = null;

    try {
        Connection conn = getConnection(db, bsql.getTableCondition());
        pstm = conn.prepareStatement(rawSQL);
        this.applyQueryTimeout(pstm);

        bsql.prepareNamedParams(db.getDialect(), pstm);

        rs = pstm.executeQuery();

        if (this.debugService.isLogSQL()) {
            long timeCost = 0;
            if (measureTime) {
                timeCost = System.nanoTime() - startTime;
            }

            this.debugService.logSQL(bsql, rawSQL, timeCost);
        }

        //do ORM
        LinkedList results = new LinkedList();

        while (rs.next()) {
            if (loader == null) {
                results.addLast(m.rs2Object(rs, bsql.getResultClass()));
            } else {
                results.addLast(loader.rs2Object(m, rs));
            }
        }

        return results;
    } catch (SQLException e) {
        throw new JDBCException("Error Code:" + e.getErrorCode() + ", sql:" + rawSQL, e, e.getSQLState());
    } finally {
        CloseUtil.close(rs);
        CloseUtil.close(pstm);
    }
}

From source file:org.xdi.util.EasyX509TrustManager.java

/**
 * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],
 *      String authType)//from   w w  w.  j a va 2  s.c o  m
 */
public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
    if (certificates != null && LOG.isDebugEnabled()) {
        LOG.debug("Server certificate chain:");
        for (int i = 0; i < certificates.length; i++) {
            LOG.debug("X509Certificate[" + i + "]=" + certificates[i]);
        }
    }
    if (certificates != null && (certificates.length == 1)) {
        certificates[0].checkValidity();
    } else {
        List<X509Certificate> certs = new ArrayList<X509Certificate>();
        if (certificates != null) {
            certs.addAll(Arrays.asList(certificates));
        }
        X509Certificate certChain = certs.get(0);
        certs.remove(certChain);
        LinkedList<X509Certificate> chainList = new LinkedList<X509Certificate>();
        chainList.add(certChain);
        Principal certIssuer = certChain.getIssuerDN();
        Principal certSubject = certChain.getSubjectDN();
        while (!certs.isEmpty()) {
            List<X509Certificate> tempcerts = new ArrayList<X509Certificate>();
            tempcerts.addAll(certs);
            for (X509Certificate cert : tempcerts) {
                if (cert.getIssuerDN().equals(certSubject)) {
                    chainList.addFirst(cert);
                    certSubject = cert.getSubjectDN();
                    certs.remove(cert);
                    continue;
                }

                if (cert.getSubjectDN().equals(certIssuer)) {
                    chainList.addLast(cert);
                    certIssuer = cert.getIssuerDN();
                    certs.remove(cert);
                    continue;
                }
            }
        }
        standardTrustManager.checkServerTrusted(chainList.toArray(new X509Certificate[] {}), authType);

    }
}

From source file:pl.otros.logview.gui.actions.ShowCallHierarchyAction.java

protected void findCallHierarchyEvents(int selected, LogDataTableModel model,
        Collection<Integer> listEntryEvents, Collection<Integer> listOfEvents2) {
    LogData ld = model.getLogData(selected);
    String thread = ld.getThread();
    LinkedList<LogData> stack = new LinkedList<LogData>();
    HashMap<Integer, ArrayList<Integer>> allEventsInCallHierarchyMap = new HashMap<Integer, ArrayList<Integer>>();

    int rowCount = model.getRowCount();
    for (int i = 0; i < rowCount; i++) {
        LogData logData = model.getLogData(i);
        if (!logData.getThread().equals(thread)) {
            continue;
        }/*from w w  w. java 2s .c  o m*/
        Message m = new Message(logData.getMessage());
        Integer stackSize = stack.size();
        if (!allEventsInCallHierarchyMap.containsKey(stackSize)) {
            allEventsInCallHierarchyMap.put(stackSize, new ArrayList<Integer>());
        }
        ArrayList<Integer> tempListOfEvents = allEventsInCallHierarchyMap.get(stackSize);
        if (m.getType().equals(MessageType.TYPE_ENTRY)) {
            stack.addLast(logData);
        } else if (m.getType().equals(MessageType.TYPE_EXIT) && theSameLogMethod(stack.getLast(), logData)) {
            stack.removeLast();
            tempListOfEvents.clear();
        } else {
            tempListOfEvents.add(logData.getId());
        }
        if (logData.getId() == ld.getId()) {
            break;
        }
    }

    for (ArrayList<Integer> list : allEventsInCallHierarchyMap.values()) {
        listOfEvents2.addAll(list);
    }

    for (LogData aStack : stack) {
        listEntryEvents.add(Integer.valueOf(aStack.getId()));
    }
}

From source file:jext2.DataBlockAccess.java

/** Allocate and set up a chain of blocks.
 * @param  inode   owner/*from ww  w . j  a v  a 2  s.  c o m*/
 * @param  num     depth of the chain (number of blocks to allocate)
 * @param  goal    gloal block
 * @param  offsets offsets in the indirection chain
 * @param  blockNrs    chain of allready allocated blocks
 * @throws NoSpaceLeftOnDevice
 *
 * This function allocates num blocks, zeros out all but the last one, links
 * them into a chain and writes them to disk.
 */
@NotThreadSafe(useLock = true)
private LinkedList<Long> allocBranch(int num, long goal, int[] offsets, long[] blockNrs)
        throws JExt2Exception, NoSpaceLeftOnDevice {

    int n = 0;
    LinkedList<Long> result = new LinkedList<Long>();

    try {
        long parent = allocateBlock(goal);
        result.addLast(parent);

        if (parent > 0) {
            for (n = 1; n < num; n++) {
                /* allocate the next block */
                long nr = allocateBlock(parent);
                if (nr > 0) {
                    result.addLast(nr);

                    ByteBuffer buf = ByteBuffer.allocate(superblock.getBlocksize());
                    Ext2fsDataTypes.putLE32U(buf, nr, offsets[n] * 4);
                    buf.rewind();
                    blocks.write(parent, buf);
                } else {
                    break;
                }

                parent = nr;
            }
        }
    } catch (NoSpaceLeftOnDevice e) {
        for (long nr : result) {
            freeBlocks(new long[] { nr });
        }
    }

    if (num == n) /* Allocation successful */
        return result;
    else /* Allocation failed */
        throw new NoSpaceLeftOnDevice();
}