Example usage for java.lang NullPointerException printStackTrace

List of usage examples for java.lang NullPointerException printStackTrace

Introduction

In this page you can find the example usage for java.lang NullPointerException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.shareok.data.sagedata.SageJournalIssueDateProcessor.java

/**
 * Somehow some of the issue keys have comma after the issue digit number. Need to find out the reason.
 *//*from w w w  .  ja v a  2 s  . c o m*/
public void cleanIssueKeys() {
    Map<String, Map<String, String>> map = getSavedSageJournalVolIssueDateInformation();
    String journalName = "";
    String data = "";
    try {
        for (String journal : map.keySet()) {
            journalName = journal;
            Map<String, String> journalMap = map.get(journal);
            data = journalMap.get("data");
            if (DocumentProcessorUtil.isEmptyString(data)) {
                System.out.println("Journal " + journal + " has not data to process!");
                continue;
            }
            JSONObject dataJson = new JSONObject(data);
            for (String volume : dataJson.keySet()) {
                JSONObject volJson = dataJson.getJSONObject(volume);
                List<String> wrongKeys = new ArrayList<>();
                for (String issue : volJson.keySet()) {
                    if (issue.contains(",")) {
                        wrongKeys.add(issue);
                    }
                }
                for (String wrongKey : wrongKeys) {
                    String newKey = wrongKey.split("\\,+")[0];
                    String wrongKeyData = volJson.getString(wrongKey);
                    volJson.remove(wrongKey);
                    volJson.put(newKey, wrongKeyData);
                }
            }
            data = dataJson.toString();
            journalMap.put("data", data);
        }
        System.out.println("The data map has been cleaned");
        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(map);
        String sageJournalIssueDateInfoFilePath = ShareokdataManager.getSageJournalIssueDateInfoFilePath();
        File sageFile = new File(sageJournalIssueDateInfoFilePath);
        if (sageFile.exists()) {
            String sageJournalIssueDateInfoFilePathOld = sageJournalIssueDateInfoFilePath.split("\\.")[0] + "_"
                    + DataHandlersUtil.getCurrentTimeString() + ".json";
            sageFile.renameTo(new File(sageJournalIssueDateInfoFilePathOld));
        }
        DocumentProcessorUtil.outputStringToFile(json,
                ShareokdataManager.getSageJournalIssueDateInfoFilePath());
    } catch (NullPointerException ex) {
        System.out
                .println("This data " + data + " for journal " + journalName + " gives null pointer exception");
        ex.printStackTrace();
    } catch (JsonProcessingException ex) {
        logger.error("JSON processing exception", ex);
    } catch (IOException ex) {
        logger.error("IO exception", ex);
    }
}

From source file:com.android.launcher3.Utilities.java

public static void takeScreenshot(Activity activity) {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
        checkPermission(activity);/*w  w w  . j  ava  2s. c o m*/
    }
    try {

        File cacheDir = new File(android.os.Environment.getExternalStorageDirectory(), "FlickLauncher");

        if (!cacheDir.exists()) {
            cacheDir.mkdirs();
        }

        String path = new File(android.os.Environment.getExternalStorageDirectory(), "FlickLauncher")
                + "/Screenshot-" + System.currentTimeMillis() + ".jpg";

        savePic(takeShot(activity), path, activity);

    } catch (NullPointerException ignored) {
        ignored.printStackTrace();
    }
}

From source file:com.siacra.beans.ResponsabilidadBean.java

public void showHorasActuales() {
    try {//from  w  w  w. ja v  a  2 s.c om
        if (horasObligatoriasExcedidas()) {
            RequestContext context = RequestContext.getCurrentInstance();
            context.execute("PF('sobrecarga_docente').show();");
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:org.hyperic.hq.api.transfer.impl.ResourceTransferImpl.java

public final Object initResourceConfig(final Context flowContext)
        throws ConfigFetchException, EncodingException, PluginNotFoundException, PluginException,
        PermissionException, AppdefEntityNotFoundException {

    final int iNoOfConfigTypes = ProductPlugin.CONFIGURABLE_TYPES.length;
    ConfigSchemaAndBaseResponse configMetadata = null;

    //load all resource related config metadata&data resources
    String configurableType = null;
    for (int i = 0; i < iNoOfConfigTypes; i++) {
        configurableType = ProductPlugin.CONFIGURABLE_TYPES[i];
        try {/*w  ww.j a  v a 2s.com*/
            flowContext.configResponses[i] = configMetadata = productBoss.getConfigSchemaAndBaseResponse(
                    flowContext.subject, flowContext.entityID, configurableType, false/*validateFlow*/);
            //init the schema map in the config response so as to support key recognition validation 
            configMetadata.getResponse().setSchema(configMetadata.getSchema());
        } catch (PluginNotFoundException pnfe) {
            log.debug("Plugin Config Schema of type: " + configurableType + " was not defined for resource "
                    + flowContext.entityID);
        } //EO catch block 
          // XXX why are we catching an NPE???
        catch (NullPointerException npe) {
            npe.printStackTrace();
        }
    } //EO while there are more configurable types

    //load all cprop metadata
    final Resource prototype = flowContext.backendResource.getPrototype();

    flowContext.cprops = cpropManager.getEntries(flowContext.entityID);

    //TODO: pojo members data 

    return null;
}

From source file:com.edduarte.protbox.core.registry.PReg.java

private PbxEntry evaluate(PbxEntry entry, File sharedFile, File protFile) throws ProtboxException {
    try {/*from w w w.j av  a2 s.c o  m*/
        if (entry == null) {
            // is a file or folder that is not represented by an entry on this PReg
            if (Constants.verbose) {
                logger.info("is a file or folder that is not represented by an entry on this PReg");
            }

            if (sharedFile == null && protFile != null) {
                // new file at prot folder -> add to registry and sync to shared
                if (Constants.verbose) {
                    logger.info("new file at prot folder -> add to registry and sync to shared");
                }
                return add(protFile, FolderOption.PROT);

            } else if (sharedFile != null && protFile == null) {
                // new file at shared folder -> add to registry and sync to prot
                if (Constants.verbose) {
                    logger.info("new file at shared folder -> add to registry and sync to prot");
                }
                return add(sharedFile, FolderOption.SHARED);

            } else if (sharedFile != null && protFile != null) {
                // new files at both folders -> add to registry as conflicted copy and sync to shared
                if (Constants.verbose) {
                    logger.info(
                            "new files at both folders -> add to registry as conflicted copy and sync to shared");
                }
                addConflicted(protFile, FolderOption.PROT);
                return add(sharedFile, FolderOption.SHARED);
            }

        } else if (entry instanceof PbxFile) {
            // is a file that is already represented by an entry on this PReg

            PbxFile entry1 = (PbxFile) entry;
            if ((sharedFile == null || !sharedFile.exists()) && (protFile == null || !protFile.exists())) {
                // entry was deleted from both folders -> keep entry and do nothing
                //                    logger.info("entry was deleted from both folders -> keep entry and do nothing");

            } else if ((sharedFile == null || !sharedFile.exists()) && protFile != null) {
                // file was deleted from shared folder
                Date protLS = new Date(protFile.lastModified());
                Date entryLS = entry1.getLatestSnapshot().getLastModifiedDate();

                if (protLS.compareTo(entryLS) < 0) {
                    // prot file is more recent than entry -> sync prot file to shared folder
                    if (Constants.verbose) {
                        logger.info("prot file is more recent than entry -> sync prot file to shared folder");
                    }
                    SyncModule.toShared(this, entry);

                } else {
                    // prot file is older than entry -> delete it while retaining data
                    if (Constants.verbose) {
                        logger.info("prot file is older than entry -> delete it while retaining data");
                    }
                    delete(protFile, FolderOption.PROT);

                }

            } else if (sharedFile != null && protFile == null) {
                // file was deleted from prot folder
                Date sharedLS = new Date(sharedFile.lastModified());
                Date entryLS = entry1.getLatestSnapshot().getLastModifiedDate();

                if (sharedLS.compareTo(entryLS) < 0) {
                    // shared file is more recent than entry -> sync shared file to prot folder
                    if (Constants.verbose) {
                        logger.info("shared file is more recent than entry -> sync shared file to prot folder");
                    }
                    SyncModule.toProt(this, entry);

                } else {
                    // shared file is older than entry -> delete it while retaining data
                    if (Constants.verbose) {
                        logger.info("shared file is older than entry -> delete it while retaining data");
                    }
                    delete(sharedFile, FolderOption.SHARED);

                }

            } else if (sharedFile != null && protFile != null) {
                // file exists at both folders

                Date sharedLS = new Date(sharedFile.lastModified());
                Date protLS = new Date(protFile.lastModified());
                Date entryLS = entry1.getLatestSnapshot().getLastModifiedDate();
                int compareSharedProt = sharedLS.compareTo(protLS);
                int compareProtEntry = protLS.compareTo(entryLS);
                int compareSharedEntry = sharedLS.compareTo(entryLS);

                if (compareSharedProt == 0 && compareProtEntry == 0) {
                    // all last modified dates are equal -> do nothing
                    //                        logger.info("all last modified dates are equal -> do nothing");

                } else if (compareSharedProt != 0) {

                    if (compareProtEntry == 0 && compareSharedEntry != 0) {
                        // shared file was updated -> sync shared to prot
                        if (Constants.verbose) {
                            logger.info("shared file was updated -> sync shared to prot");
                        }
                        SyncModule.toProt(this, entry);

                    } else if (compareProtEntry != 0 && compareSharedEntry == 0) {
                        // prot file was updated -> sync prot to shared
                        if (Constants.verbose) {
                            logger.info("prot file was updated -> sync prot to shared");
                        }
                        SyncModule.toShared(this, entry);

                    } else if (compareProtEntry != 0 && compareSharedEntry != 0) {
                        // both files were updated -> conflict
                        if (Constants.verbose) {
                            logger.info("both files were updated -> conflict");
                        }
                        addConflicted(protFile, FolderOption.PROT);
                        SyncModule.toProt(this, entry);
                    }
                }
            }
        } else if (entry instanceof PbxFolder) {
            // is a folder that is already represented by an entry on this PReg
            if ((sharedFile == null || !sharedFile.exists()) && (protFile == null || !protFile.exists())) {
                // entry was deleted from both folders -> keep entry and do nothing
                if (Constants.verbose) {
                    logger.info("entry was deleted from both folders -> keep entry and do nothing");
                }

            } else if ((protFile == null || !protFile.exists())
                    && (sharedFile != null && sharedFile.exists())) {
                // entry was deleted at prot folder -> delete it from shared folder but keep entry
                if (Constants.verbose) {
                    logger.info(
                            "entry was deleted at prot folder -> delete it from shared folder but keep entry");
                }
                deleteFilesFromEntry(entry);

            } else if ((sharedFile == null || !sharedFile.exists())
                    && (protFile != null && protFile.exists())) {
                // entry was deleted at shared folder -> assure that it is updated, by syncing from prot to shared
                if (Constants.verbose) {
                    logger.info(
                            "entry was deleted at shared folder -> assure that it is updated, by syncing from prot to shared");
                }
                SyncModule.toShared(this, entry);

            }
        }

    } catch (NullPointerException ex) {
        // This catch is here only to avoid crashing due to non-existent / null files
        ex.printStackTrace();
    }
    return entry;
}

From source file:com.hygenics.parser.KVParser.java

public void run() {
    log.info("Starting Parse @ " + Calendar.getInstance().getTime().toString());
    ForkJoinPool fjp = new ForkJoinPool(Runtime.getRuntime().availableProcessors() * procs);
    Set<Callable<ArrayList<String>>> collection;
    List<Future<ArrayList<String>>> futures;
    ArrayList<String> data = new ArrayList<String>((commitsize + 10));
    ArrayList<String> outdata = new ArrayList<String>(((commitsize + 10) * 3));

    int currpos = 0;
    boolean run = true;

    while (run) {
        log.info("Getting Pages");
        // get pages
        String query = select;//from   w w  w  . ja  v  a  2 s . c  o m

        if (data.size() > 0) {
            data.clear();
        }

        if (extracondition != null) {
            query += " " + extracondition;
        }

        if (extracondition != null) {
            query += " WHERE " + extracondition + " AND ";
        } else {
            query += " WHERE ";
        }

        collection = new HashSet<Callable<ArrayList<String>>>(qnums);
        for (int i = 0; i < qnums; i++) {

            if (currpos + (Math.round(commitsize / qnums * (i + 1))) < currpos + commitsize) {
                collection.add(new SplitQuery((query + pullid + " >= "
                        + Integer.toString(currpos + (Math.round(commitsize / qnums * (i)))) + " AND " + pullid
                        + " < " + Integer.toString(currpos + (Math.round(commitsize / qnums * (i + 1)))))));
            } else {
                collection.add(new SplitQuery((query + pullid + " >= "
                        + Integer.toString(currpos + (Math.round(commitsize / qnums * (i)))) + " AND " + pullid
                        + " < " + Integer.toString(currpos + commitsize))));
            }
        }

        currpos += commitsize;

        if (collection.size() > 0) {

            futures = fjp.invokeAll(collection);

            int w = 0;

            while (fjp.isQuiescent() == false && fjp.getActiveThreadCount() > 0) {
                w++;
            }

            for (Future<ArrayList<String>> f : futures) {
                try {
                    ArrayList<String> darr = f.get();
                    if (darr != null && darr.size() > 0) {
                        data.addAll(darr);
                    }
                } catch (NullPointerException e) {
                    log.info("Some Data Returned Null");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (ExecutionException e) {
                    e.printStackTrace();
                }
            }

        }

        if (data.size() == 0 && checkString != null) {
            collection = new HashSet<Callable<ArrayList<String>>>(1);
            collection.add(new SplitQuery(checkString));

            futures = fjp.invokeAll(collection);
            int w = 0;
            while (fjp.isQuiescent() == false && fjp.getActiveThreadCount() > 0) {
                w++;
            }

            for (Future<ArrayList<String>> f : futures) {
                try {
                    ArrayList<String> arr = f.get();

                    if (arr != null) {
                        for (String a : arr) {
                            if (a != null) {
                                data.add(a);
                            }
                        }
                    }
                    if (!f.isDone()) {
                        f.cancel(true);
                    }
                    f = null;
                } catch (NullPointerException e) {
                    log.info("Some Data Returned Null");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (ExecutionException e) {
                    e.printStackTrace();
                }
            }
        }

        // parse pages
        if (data.size() > 0) {
            log.info("Parsing " + Integer.toString(data.size()) + " Records");
            collection = new HashSet<Callable<ArrayList<String>>>(data.size());

            for (String json : data) {
                Map<String, Object> jmap = Json.read(json).asMap();

                // for each table in the tags Map which is a key
                for (String k : tags.keySet()) {

                    collection.add(new Parser(tags.get(k), jmap.get(htmlColumn).toString(), replacePattern,
                            replacement, jmap.get(hashColumn).toString(), hashColumn, k));

                    if (collection.size() + 1 == data.size()
                            || (collection.size() % commitsize == 0 && collection.size() >= commitsize)) {
                        log.info("Waiting for Tasks to Complete");
                        futures = fjp.invokeAll(collection);

                        // post data
                        int w = 0;
                        while (fjp.isQuiescent() == false && fjp.getActiveThreadCount() > 0) {
                            w++;
                        }

                        for (Future<ArrayList<String>> future : futures) {
                            try {
                                outdata.addAll(future.get());
                            } catch (NullPointerException e) {
                                log.info("Some Data Returned Null");
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            } catch (ExecutionException e) {
                                e.printStackTrace();
                            }
                        }

                        log.info("Parsed " + outdata.size() + " records!");
                        // post data
                        int cp = 0;
                        if (outdata.size() > 0) {
                            checkTables(outdata);
                            this.sendToDb(outdata, true);
                            outdata = new ArrayList<String>(commitsize);
                        }

                    }

                }
            }
            data = new ArrayList<String>(commitsize);
        } else {
            log.info("No Records Found. Terminating!");
            run = false;
        }

    }

    if (outdata.size() > 0) {
        log.info("Posting Last Records");
        // post remaining pages for the iteration
        if (outdata.size() > 0) {
            int cp = 0;
            if (outdata.size() > 0) {
                checkTables(outdata);
                this.sendToDb(outdata, true);
            }
            data.clear();
            outdata.clear();
        }
    }

    // shutdown
    log.info("Complete! Shutting Down FJP.");
    fjp.shutdownNow();

    log.info("Finished Parse @ " + Calendar.getInstance().getTime().toString());
}

From source file:com.marshalchen.ultimaterecyclerview.UltimateRecyclerView.java

protected void enableShoworHideToolbarAndFloatingButton(RecyclerView recyclerView) {
    if (mCallbacks != null) {
        if (getChildCount() > 0) {
            int firstVisiblePosition = recyclerView.getChildAdapterPosition(recyclerView.getChildAt(0));
            int lastVisiblePosition = recyclerView
                    .getChildAdapterPosition(recyclerView.getChildAt(recyclerView.getChildCount() - 1));
            try {
                for (int i = firstVisiblePosition, j = 0; i <= lastVisiblePosition; i++, j++) {
                    int childHeight = 0;
                    View child = recyclerView.getChildAt(j);
                    if (mChildrenHeights.indexOfKey(i) < 0
                            || (child != null && child.getHeight() != mChildrenHeights.get(i))) {
                        if (child != null)
                            childHeight = child.getHeight();
                    }/*from www  . ja v a  2s.c  o m*/
                    mChildrenHeights.put(i, childHeight);
                }

            } catch (NullPointerException e) {
                e.printStackTrace();
                //todo: need to solve this issue when the first child is missing from the scroll. Please also see the debug from the RV error.
                //todo: 07-01 11:50:36.359  32348-32348/com.marshalchen.ultimaterecyclerview.demo D/RVerror? Attempt to invoke virtual method 'int android.view.View.getHeight()' on a null object reference
                URLogs.e(e, "");
            }

            View firstVisibleChild = recyclerView.getChildAt(0);
            if (firstVisibleChild != null) {
                if (mPrevFirstVisiblePosition < firstVisiblePosition) {
                    // scroll down
                    int skippedChildrenHeight = 0;
                    if (firstVisiblePosition - mPrevFirstVisiblePosition != 1) {
                        for (int i = firstVisiblePosition - 1; i > mPrevFirstVisiblePosition; i--) {
                            if (0 < mChildrenHeights.indexOfKey(i)) {
                                skippedChildrenHeight += mChildrenHeights.get(i);
                            } else {
                                // Approximate each item's height to the first visible child.
                                // It may be incorrect, but without this, scrollY will be broken
                                // when scrolling from the bottom.
                                skippedChildrenHeight += firstVisibleChild.getHeight();
                            }
                        }
                    }
                    mPrevScrolledChildrenHeight += mPrevFirstVisibleChildHeight + skippedChildrenHeight;
                    mPrevFirstVisibleChildHeight = firstVisibleChild.getHeight();
                } else if (firstVisiblePosition < mPrevFirstVisiblePosition) {
                    // scroll up
                    int skippedChildrenHeight = 0;
                    if (mPrevFirstVisiblePosition - firstVisiblePosition != 1) {
                        for (int i = mPrevFirstVisiblePosition - 1; i > firstVisiblePosition; i--) {
                            if (0 < mChildrenHeights.indexOfKey(i)) {
                                skippedChildrenHeight += mChildrenHeights.get(i);
                            } else {
                                // Approximate each item's height to the first visible child.
                                // It may be incorrect, but without this, scrollY will be broken
                                // when scrolling from the bottom.
                                skippedChildrenHeight += firstVisibleChild.getHeight();
                            }
                        }
                    }
                    mPrevScrolledChildrenHeight -= firstVisibleChild.getHeight() + skippedChildrenHeight;
                    mPrevFirstVisibleChildHeight = firstVisibleChild.getHeight();
                } else if (firstVisiblePosition == 0) {
                    mPrevFirstVisibleChildHeight = firstVisibleChild.getHeight();
                    mPrevScrolledChildrenHeight = 0;
                }
                if (mPrevFirstVisibleChildHeight < 0) {
                    mPrevFirstVisibleChildHeight = 0;
                }
                mScrollY = mPrevScrolledChildrenHeight - firstVisibleChild.getTop();
                mPrevFirstVisiblePosition = firstVisiblePosition;

                mCallbacks.onScrollChanged(mScrollY, mFirstScroll, mDragging);
                //                    if (mFirstScroll) {
                //                        mFirstScroll = false;
                //                    }

                //                    if (mPrevScrollY < mScrollY) {
                //                        //down
                //                        mObservableScrollState = ObservableScrollState.UP;
                //                    } else if (mScrollY < mPrevScrollY) {
                //                        //up
                //                        mObservableScrollState = ObservableScrollState.DOWN;
                //                    } else {
                //                        mObservableScrollState = ObservableScrollState.STOP;
                //                    }

                if (mPrevScrollY < mScrollY) {
                    //down
                    if (mFirstScroll) { // first scroll down , mPrevScrollY == 0, reach here.
                        mFirstScroll = false;
                        mObservableScrollState = ObservableScrollState.STOP;
                    }
                    mObservableScrollState = ObservableScrollState.UP;
                } else if (mScrollY < mPrevScrollY) {
                    //up
                    mObservableScrollState = ObservableScrollState.DOWN;
                } else {
                    mObservableScrollState = ObservableScrollState.STOP;
                }
                if (mFirstScroll) {
                    mFirstScroll = false;
                }
                mPrevScrollY = mScrollY;
            }
        }
    }
}

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

/**
 * @return All Preferences as String/*w w w  .j a  va 2s.com*/
 */
public String getAllPrefs() {
    SharedPreferences prefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
    String Prefs = "";
    Map<String, ?> prefsMap = prefs.getAll();
    for (Map.Entry<String, ?> entry : prefsMap.entrySet()) {
        /**
         * Skip following Prefs (PREF_KEY_KERNEL_HISTORY, PREF_KEY_RECOVERY_HISTORY ...)
         */
        try {
            if (!entry.getKey().contains(PREF_KEY_KERNEL_HISTORY)
                    && !entry.getKey().contains(PREF_KEY_RECOVERY_HISTORY)
                    && !entry.getKey().contains(FlashUtil.PREF_KEY_FLASH_KERNEL_COUNTER)
                    && !entry.getKey().contains(FlashUtil.PREF_KEY_FLASH_RECOVERY_COUNTER)) {
                Prefs += entry.getKey() + ": " + entry.getValue().toString() + "\n";
            }
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    }
    return Prefs;
}

From source file:net.sf.mzmine.modules.peaklistmethods.alignment.ransac.RansacAlignerTask.java

/**
 * // w ww. j  av a  2s . c  o m
 * @param peakList
 * @return
 */
private HashMap<PeakListRow, PeakListRow> getAlignmentMap(PeakList peakList) {

    // Create a table of mappings for best scores
    HashMap<PeakListRow, PeakListRow> alignmentMapping = new HashMap<PeakListRow, PeakListRow>();

    if (alignedPeakList.getNumberOfRows() < 1) {
        return alignmentMapping;
    }

    // Create a sorted set of scores matching
    TreeSet<RowVsRowScore> scoreSet = new TreeSet<RowVsRowScore>();

    // RANSAC algorithm
    List<AlignStructMol> list = ransacPeakLists(alignedPeakList, peakList);
    PolynomialFunction function = this.getPolynomialFunction(list);

    PeakListRow allRows[] = peakList.getRows();

    for (PeakListRow row : allRows) {
        // Calculate limits for a row with which the row can be aligned
        Range mzRange = mzTolerance.getToleranceRange(row.getAverageMZ());

        double rt;
        try {
            rt = function.value(row.getAverageRT());
        } catch (NullPointerException e) {
            rt = row.getAverageRT();
        }
        if (Double.isNaN(rt) || rt == -1) {
            rt = row.getAverageRT();
        }

        Range rtRange = rtToleranceAfter.getToleranceRange(rt);

        // Get all rows of the aligned peaklist within parameter limits
        PeakListRow candidateRows[] = alignedPeakList.getRowsInsideScanAndMZRange(rtRange, mzRange);

        for (PeakListRow candidate : candidateRows) {
            RowVsRowScore score;
            if (sameChargeRequired && (!PeakUtils.compareChargeState(row, candidate))) {
                continue;
            }

            try {
                score = new RowVsRowScore(row, candidate, mzRange.getSize() / 2, rtRange.getSize() / 2, rt);

                scoreSet.add(score);
                errorMessage = score.getErrorMessage();

            } catch (Exception e) {
                e.printStackTrace();
                setStatus(TaskStatus.ERROR);
                return null;
            }
        }
        processedRows++;
    }

    // Iterate scores by descending order
    Iterator<RowVsRowScore> scoreIterator = scoreSet.iterator();
    while (scoreIterator.hasNext()) {

        RowVsRowScore score = scoreIterator.next();

        // Check if the row is already mapped
        if (alignmentMapping.containsKey(score.getPeakListRow())) {
            continue;
        }

        // Check if the aligned row is already filled
        if (alignmentMapping.containsValue(score.getAlignedRow())) {
            continue;
        }

        alignmentMapping.put(score.getPeakListRow(), score.getAlignedRow());

    }

    return alignmentMapping;
}

From source file:com.sssemil.sonyirremote.ir.ir.java

public void onRemoveClick(View view) {
    try {//ww  w  .j  a v  a  2s. co  m
        Toast.makeText(this, item, Toast.LENGTH_SHORT).show();

        String[] remove = { "rm", "-rf", irpath + item };
        try {
            Process p = Runtime.getRuntime().exec(remove);
            Log.i("rm", "Waiting... " + irpath + item);
            p.waitFor();
            Log.i("rm", "Done! " + irpath + item);
        } catch (Exception e) {
            Log.e("rm", "Failed! " + irpath + item);
            e.printStackTrace();
        }

        spinner = ((Spinner) findViewById(R.id.spinner));
        localArrayList1 = new ArrayList();
        localArrayList1.remove(item);
        ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
                localArrayList1);
        dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(dataAdapter);

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getString(R.string.done));
        builder.setMessage(getString(R.string.done_removing) + " " + item + " " + getString(R.string.files));
        builder.setPositiveButton("OK", null);
        AlertDialog dialog = builder.show();

        TextView messageView = (TextView) dialog.findViewById(android.R.id.message);
        messageView.setGravity(Gravity.CENTER);
    } catch (NullPointerException ex) {
        ex.printStackTrace();
        AlertDialog.Builder adb = new AlertDialog.Builder(this);
        adb.setTitle(getString(R.string.error));
        adb.setMessage(getString(R.string.you_need_to_select));
        adb.setIcon(android.R.drawable.ic_dialog_alert);
        adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        adb.show();
    }
}