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.dspace.rest.providers.AbstractBaseProvider.java

public UserRequestParams refreshParams(Context context) {

    UserRequestParams uparam = new UserRequestParams();

    try {/* w w w. j  av  a  2 s  . c o  m*/
        user = reqStor.getStoredValue("user").toString();
    } catch (NullPointerException ex) {
        user = "";
    }

    try {
        pass = reqStor.getStoredValue("pass").toString();
    } catch (NullPointerException ex) {
        pass = "";
    }

    try {
        if (!(userc.isEmpty() && passc.isEmpty())) {
            user = userc;
            pass = passc;
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    } // now try to login user
    loggedUser = "anonymous";

    try {
        EPerson eUser = EPerson.findByEmail(context, user);
        if ((eUser.canLogIn()) && (eUser.checkPassword(pass))) {
            context.setCurrentUser(eUser);
            loggedUser = eUser.getName();
        } else {
            throw new EntityException("Bad username or password", user, 403);
        }
    } catch (SQLException sql) {
        //            System.out.println(sql.toString());
        sql.printStackTrace();
    } catch (AuthorizeException auth) {
        throw new EntityException("Unauthorised", user, 401);
    } catch (NullPointerException ne) {
        if (!(user.equals("") && pass.equals(""))) {
            throw new EntityException("Bad username or password", user, 403);
        }
    }

    this.collections = "true".equals(reqStor.getStoredValue("collections"));
    uparam.setCollections(this.collections);
    this.trim = "true".equals(reqStor.getStoredValue("trim"));
    uparam.setTrim(this.trim);
    this.parents = "true".equals(reqStor.getStoredValue("parents"));
    uparam.setParents(this.parents);
    this.children = "true".equals(reqStor.getStoredValue("children"));
    uparam.setChildren(this.children);
    this.groups = "true".equals(reqStor.getStoredValue("groups"));
    uparam.setGroups(this.groups);
    this.replies = "true".equals(reqStor.getStoredValue("replies"));
    uparam.setReplies(this.replies);

    //        try {
    //            action = reqStor.getStoredValue("action").toString();
    //            uparam.setAction(action);
    //        } catch (NullPointerException ex) {
    //            action = "";
    //        }

    try {
        query = reqStor.getStoredValue("query").toString();
        uparam.setQuery(query);
    } catch (NullPointerException ex) {
        query = "";
    }

    try {
        Object o = reqStor.getStoredValue("fields");
        if (o instanceof String) {
            fields = new String[] { o.toString() };
        } else if (o instanceof String[]) {
            fields = (String[]) o;
        } else if (o == null) {
            fields = null;
        }
        uparam.setFields(fields);
    } catch (NullPointerException ex) {
        fields = null;
    }

    try {
        status = reqStor.getStoredValue("status").toString();
        uparam.setStatus(status);
    } catch (NullPointerException ex) {
        status = "";
    }

    try {
        submitter = reqStor.getStoredValue("submitter").toString();
        uparam.setSubmitter(submitter);
    } catch (NullPointerException ex) {
        submitter = "";
    }

    try {
        reviewer = reqStor.getStoredValue("reviewer").toString();
        uparam.setReviewer(reviewer);
    } catch (NullPointerException ex) {
        reviewer = "";
    }

    try {
        String bundleStr = reqStor.getStoredValue("type").toString();
        uparam.setType(bundleStr.split(","));
    } catch (NullPointerException ex) {
        type = null;
    }

    try {
        _order = reqStor.getStoredValue("order").toString();
        uparam.setOrder(_order);
    } catch (NullPointerException ex) {
        _order = "";
    }

    try {
        _sort = reqStor.getStoredValue("sort").toString();
        uparam.setSort(_sort);
    } catch (NullPointerException ex) {
        _sort = "";

    } // both parameters are used according to requirements
    if (_order.length() > 0 && _sort.equals("")) {
        _sort = _order;
    }

    try {
        _start = Integer.parseInt(reqStor.getStoredValue("start").toString());
        uparam.setStart(_start);
    } catch (NullPointerException ex) {
        _start = 0;
    }

    try {
        _limit = Integer.parseInt(reqStor.getStoredValue("limit").toString());
        uparam.setLimit(_limit);
    } catch (NullPointerException ex) {
        _limit = 0;
    } // some checking for invalid values

    if (_limit < 0) {
        _limit = 0;
    }

    try {
        _sdate = reqStor.getStoredValue("startdate").toString();
    } catch (NullPointerException ex) {
        _sdate = null;
    }

    try {
        _edate = reqStor.getStoredValue("enddate").toString();
    } catch (NullPointerException ex) {
        _edate = null;
    }

    try {
        withdrawn = reqStor.getStoredValue("withdrawn").toString().equalsIgnoreCase("true");
    } catch (NullPointerException ex) {
        withdrawn = false;
    }
    // defining sort fields and values
    _sort = _sort.toLowerCase();
    String[] sort_arr = _sort.split(",");

    for (String option : sort_arr) {
        if (option.startsWith("submitter")) {
            sortOptions.add(UtilHelper.SORT_SUBMITTER);
        } else if (option.startsWith("email")) {
            sortOptions.add(UtilHelper.SORT_EMAIL);
        } else if (option.startsWith("firstname")) {
            sortOptions.add(UtilHelper.SORT_FIRSTNAME);
        } else if (option.startsWith("lastname")) {
            sortOptions.add(UtilHelper.SORT_LASTNAME);
        } else if (option.startsWith("fullname")) {
            sortOptions.add(UtilHelper.SORT_FULL_NAME);
        } else if (option.startsWith("language")) {
            sortOptions.add(UtilHelper.SORT_LANGUAGE);
        } else if (option.startsWith("lastmodified")) {
            sortOptions.add(UtilHelper.SORT_LASTMODIFIED);
        } else if (option.startsWith("countitems")) {
            sortOptions.add(UtilHelper.SORT_COUNT_ITEMS);
        } else if (option.startsWith("name")) {
            sortOptions.add(UtilHelper.SORT_NAME);
        } else {
            sortOptions.add(UtilHelper.SORT_ID);
        }
        if ((option.endsWith("_desc") || option.endsWith("_reverse"))) {
            int i = sortOptions.get(sortOptions.size() - 1);
            sortOptions.remove(sortOptions.size() - 1);
            i += 100;
            sortOptions.add(i);
        }
    }

    int intcommunity = 0;
    int intcollection = 0;

    // integer values used in some parts
    try {
        intcommunity = Integer.parseInt(reqStor.getStoredValue("community").toString());
    } catch (NullPointerException nul) {
    }

    try {
        _community = Community.find(context, intcommunity);
    } catch (SQLException sql) {
    }

    try {
        intcollection = Integer.parseInt(reqStor.getStoredValue("collection").toString());
    } catch (NullPointerException nul) {
    }

    try {
        _collection = Collection.find(context, intcollection);
    } catch (SQLException sql) {
    }

    if ((intcommunity > 0) && (intcollection > 0)) {
        throw new EntityException("Bad request", "Community and collection selected", 400);
    }

    if ((intcommunity > 0) && (_community == null)) {
        throw new EntityException("Bad request", "Unknown community", 400);
    }

    if ((intcollection > 0) && (_collection == null)) {
        throw new EntityException("Bad request", "Unknown collection", 400);
    }

    return uparam;
}

From source file:com.izforge.izpack.panels.shortcut.ShortcutPanelLogic.java

/**
 * Creates all shortcuts based on the information in shortcuts.
 *///ww w.  j av a 2 s  .  c om
private void createShortcuts(List<ShortcutData> shortcuts) {
    if (!createShortcuts) {
        return;
    }
    String groupName;

    List<String> startMenuShortcuts = new ArrayList<String>();
    for (ShortcutData data : shortcuts) {
        try {
            groupName = this.groupName + data.subgroup;
            shortcut.setUserType(userType);
            shortcut.setLinkName(data.name);
            shortcut.setLinkType(data.type);
            shortcut.setArguments(data.commandLine);
            shortcut.setDescription(data.description);
            shortcut.setIconLocation(data.iconFile, data.iconIndex);

            shortcut.setShowCommand(data.initialState);
            shortcut.setTargetPath(data.target);
            shortcut.setWorkingDirectory(data.workingDirectory);
            shortcut.setEncoding(data.deskTopEntryLinux_Encoding);
            shortcut.setMimetype(data.deskTopEntryLinux_MimeType);
            shortcut.setRunAsAdministrator(data.runAsAdministrator);

            shortcut.setTerminal(data.deskTopEntryLinux_Terminal);
            shortcut.setTerminalOptions(data.deskTopEntryLinux_TerminalOptions);
            shortcut.setType(data.deskTopEntryLinux_Type);
            shortcut.setKdeSubstUID(data.deskTopEntryLinux_X_KDE_SubstituteUID);
            shortcut.setKdeUserName(data.deskTopEntryLinux_X_KDE_UserName);
            shortcut.setURL(data.deskTopEntryLinux_URL);
            shortcut.setTryExec(data.TryExec);
            shortcut.setCategories(data.Categories);
            shortcut.setCreateForAll(data.createForAll);
            shortcut.setUninstaller(uninstallData);

            if (data.addToGroup) {
                shortcut.setProgramGroup(groupName);
            } else {
                shortcut.setProgramGroup("");
            }

            shortcut.save();

            if (data.type == Shortcut.APPLICATIONS || data.addToGroup) {
                if (shortcut instanceof com.izforge.izpack.util.os.Unix_Shortcut) {
                    com.izforge.izpack.util.os.Unix_Shortcut unixcut = (com.izforge.izpack.util.os.Unix_Shortcut) shortcut;
                    String f = unixcut.getWrittenFileName();
                    if (f != null) {
                        startMenuShortcuts.add(f);
                    }
                }
            }

            // add the file and directory name to the file list
            String fileName = shortcut.getFileName();
            files.add(0, fileName);

            File file = new File(fileName);
            File base = new File(shortcut.getBasePath());
            Vector<File> intermediates = new Vector<File>();

            execFiles.add(new ExecutableFile(fileName, ExecutableFile.UNINSTALL, ExecutableFile.IGNORE,
                    new ArrayList<OsModel>(), false));
            files.add(fileName);

            while ((file = file.getParentFile()) != null) {
                if (file.equals(base)) {
                    break;
                }
                intermediates.add(file);
            }

            if (file != null) {
                Enumeration<File> filesEnum = intermediates.elements();

                while (filesEnum.hasMoreElements()) {
                    files.add(0, filesEnum.nextElement().toString());
                }
            }
        } catch (Exception ignored) {
        }
    }
    if (OsVersion.IS_UNIX) {
        writeXDGMenuFile(startMenuShortcuts, this.groupName, programGroupIconFile, programGroupComment);
    }
    shortcut.execPostAction();

    try {
        if (execFiles != null) {
            //
            // TODO: Hi Guys,
            // TODO The following commented lines sometimes produces an uncatchable
            // nullpointer Exception!
            // TODO evaluate for what reason the files should exec.
            // TODO if there is a serious explanation, why to do that,
            // TODO the code must be more robust
            //FileExecutor executor = new FileExecutor(execFiles);
            // evaluate executor.executeFiles( ExecutableFile.NEVER, null );
        }
    } catch (NullPointerException nep) {
        nep.printStackTrace();
    } catch (RuntimeException cannot) {
        cannot.printStackTrace();
    }
    shortcut.cleanUp();
}

From source file:com.anp.bdmt.MainActivity.java

public void findLocation() {
    if (!mDialog.isShowing()) {
        mDialog.show();//from   w  w w  . ja  va 2s.c  o m
    }
    mLocationUtil.start();
    TimerTask timerTask = new TimerTask() {
        public void run() {
            mHandler.post(new Runnable() {
                public void run() {

                    try {

                        sLatitude = mLocationUtil.getLastLocation().getLatitude();
                        sLongitude = mLocationUtil.getLastLocation().getLongitude();

                        new AddressJsonTask(mAddressText).execute();

                        String address;
                        // address = mLocationUtil.getAddress(sLatitude,
                        // sLongitude);

                        mAddressText.setVisibility(View.VISIBLE);
                        // mAddressText.setText(address);

                        mGpsFlag = true;

                    } catch (NullPointerException e) {
                        Log.d("JAY", "gps exception");
                        e.printStackTrace();

                        mAddressText.setText("<-  ?   ? .");

                        mDialog.dismiss();

                        mGpsFlag = false;
                    }
                }
            });
        }
    };

    if (mLocationUtil.isRunLocationUtil) {
        mLocationUtil.stop();
    }

    Timer timer = new Timer();
    timer.schedule(timerTask, 1000);
}

From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java

public static void recycleallbitmaps() {

    for (int h = 0; h < floorplancount; h++) {
        view.originalbitmap[h].recycle();
        view.bm[h].recycle();//www  .ja  v a  2  s .  co  m
    }
    //view.bm.recycle();

    for (int h = 0; h < view.originaliconbitmap.length; h++) {
        view.originaliconbitmap[h].recycle();
        view.iconbitmap[h].recycle();
    }

    view.BMS.recycle();
    view.ELC.recycle();
    view.Gateway.recycle();
    view.SAM.recycle();
    view.MINISAM.recycle();
    view.tempsensor.recycle();
    view.ethernetport.recycle();
    view.tinygreencheck.recycle();
    view.tinyredx.recycle();
    view.ethernetport.recycle();
    view.distributionboard.recycle();
    view.samarray.recycle();
    view.datahub.recycle();
    view.portraitlegend.recycle();
    view.squeezedlandscapelegend.recycle();

    view.NGBlegend.recycle();

    view.landscapelegend.recycle();
    for (int h = 0; h < view.ITEMbitmap.length; h++) {

        try {
            view.ITEMbitmap[h].recycle();
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
        try {
            view.ScaledITEMbitmap[h].recycle();
        } catch (NullPointerException e) {
            e.printStackTrace();
        }

    }
    view.canvasbitmap.recycle();

    Addtextbit.recycle();
}

From source file:com.johan.vertretungsplan.background.VertretungsplanService.java

@Override
protected void onHandleIntent(Intent intent) {
    context = this;
    settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    extras = intent.getExtras();// w w  w  .j  a v  a  2 s.c o  m
    Gson gson = new Gson();

    boolean autoSync;
    try {
        autoSync = extras.getBoolean("AutoSync");
    } catch (NullPointerException e) {
        autoSync = false;
    }

    ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

    //wifi
    State wifi = conMan.getNetworkInfo(1).getState();

    if (wifi == NetworkInfo.State.CONNECTED || autoSync == false
            || settings.getBoolean("syncWifi", false) == false) {

        Log.d("Vertretungsplan", "WiFi state: " + wifi);
        Log.d("Vertretungsplan", "autoSync: " + autoSync);
        Log.d("Vertretungsplan", "syncWifi: " + Boolean.valueOf(settings.getBoolean("syncWifi", false)));

        Log.d("Vertretungsplan", "Vertretungsplan wird abgerufen");

        try {
            BaseParser parser = ((VertretungsplanApplication) getApplication()).getParser();

            if (parser == null)
                return;

            Vertretungsplan v = parser.getVertretungsplan();
            settings.edit().putString("Vertretungsplan", gson.toJson(v)).commit();

            AppWidgetManager mgr = AppWidgetManager.getInstance(this);
            int[] ids = mgr.getAppWidgetIds(new ComponentName(this, VertretungsplanWidgetProvider.class));
            new VertretungsplanWidgetProvider().onUpdate(this, mgr, ids);
        } catch (IOException | JSONException e) {
            e.printStackTrace();
        } catch (VersionException e) {
        } catch (UnauthorizedException e) {
        }
    }
}

From source file:guineu.modules.filter.Alignment.RANSAC.RansacAlignerTask.java

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

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

    if (alignedPeakList.getNumberRows() < 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,
            ((SimpleLCMSDataset) alignedPeakList).getRowsRTRange());

    PeakListRow allRows[] = peakList.getRows().toArray(new PeakListRow[0]);

    for (PeakListRow row : allRows) {
        double rt = 0.0;
        try {
            rt = function.value(((SimplePeakListRowLCMS) row).getRT());
        } catch (NullPointerException e) {
            rt = ((SimplePeakListRowLCMS) row).getRT();
        }

        if (Double.isNaN(rt) || rt == -1) {
            rt = ((SimplePeakListRowLCMS) row).getRT();
        }

        Range mzRange = this.mzTolerance.getToleranceRange(((SimplePeakListRowLCMS) row).getMZ());
        Range rtRange = this.rtToleranceAfterRTcorrection.getToleranceRange(rt);
        // Get all rows of the aligned peaklist within parameter limits
        PeakListRow candidateRows[] = ((SimpleLCMSDataset) alignedPeakList).getRowsInsideRTAndMZRange(rtRange,
                mzRange);

        for (PeakListRow candidate : candidateRows) {
            RowVsRowScore score;
            try {
                score = new RowVsRowScore(row, candidate, mzTolerance.getTolerance(),
                        rtToleranceAfterRTcorrection.getTolerance(), rt);

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

            } catch (Exception e) {
                e.printStackTrace();
                setStatus(TaskStatus.ERROR);
                return null;
            }
        }
        progress = (double) processedRows++ / (double) totalRows;
    }

    // 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:diva.rest.model.DivaRoot.java

public void runSimulation(Boolean isAdmin) {
    ServiceCategory serviceCategory = ServiceCategory.INSTANCE;
    Map<String, String> remember = new HashMap<String, String>();
    if (isAdmin) {

        for (Dimension dim : root.getDimension())
            for (Variant variant : dim.getVariant()) {
                String dep = null;
                try {
                    dep = variant.getDependency().getText();
                } catch (NullPointerException e) {
                    continue;
                }//from w  ww. j  a v  a 2s .  co  m
                if (dep == null || dep.length() == 0)
                    continue;
                List<String> group = serviceCategory.getGroup(dep.trim());
                if (group != null && group.size() != 0) {
                    String alternative = org.apache.commons.lang.StringUtils.join(group, " or ");
                    alternative = "(" + alternative + ")";
                    remember.put(variant.getName(), dep);
                    variant.getDependency().setText(alternative);
                    try {
                        Term term = DivaExpressionParser.parse(root, alternative.trim());
                        variant.getDependency().setTerm(term);
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

            }
    }

    _runSimulation();

    if (isAdmin) {
        for (Dimension dim : root.getDimension())
            for (Variant variant : dim.getVariant()) {
                String original = remember.get(variant);
                if (original == null || original.length() == 0)
                    continue;
                variant.getDependency().setText(original);
                try {
                    Term term = DivaExpressionParser.parse(root, original.trim());
                    variant.getDependency().setTerm(term);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
    }

}

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

/**
 * Runs the Program//from   w w w.ja va2  s . co  m
 */
public void run() {
    int its = 0;

    this.select = Properties.getProperty(this.select);
    this.extracondition = Properties.getProperty(this.extracondition);
    this.column = Properties.getProperty(this.column);

    createTables();
    log.info("Starting Parse via JSoup @ " + 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 offenderhash = offset;

    boolean run = true;
    int iteration = 0;

    int currpos = 0;
    do {
        collection = new HashSet<Callable<ArrayList<String>>>(qnums);
        log.info("Getting Data");
        // get data
        currpos = iteration * commitsize + offset;
        iteration += 1;
        String query = select;

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

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

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

        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 {
                    // TODO Get Pages to Parse
                    data.addAll(f.get());
                } catch (NullPointerException e) {
                    log.info("Some Data Returned Null");
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (ExecutionException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

        }

        collection = new HashSet<Callable<ArrayList<String>>>(data.size());
        // checkstring
        if (data.size() == 0 && checkstring != null && its <= maxchecks) {
            its++;
            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 {
                    // TODO Get Pages to Parse
                    data.addAll(f.get());
                } catch (NullPointerException e) {
                    log.info("Some Data Returned Null");
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (ExecutionException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

        }

        if (data.size() == 0) {
            // set to stop if size is0
            log.info("No Pages to Parse. Will Terminate");
            run = false;
        } else {
            // parse
            log.info("Starting JSoup Parse @ " + Calendar.getInstance().getTime().toString());
            for (String json : data) {
                // faster json reader is minimal json but faster parser is
                // Simple Json
                Map<String, Json> jMap = Json.read(json).asJsonMap();

                if (jMap.containsKey("offenderhash")) {
                    // string to int in case it is a string and has some
                    // extra space
                    offenderhash = Integer.parseInt(jMap.get("offenderhash").asString().trim());
                }

                boolean allow = true;

                if (mustcontain != null) {
                    if (jMap.get(column).asString().contains(mustcontain) == false) {
                        allow = false;
                    }
                }

                if (cannotcontain != null) {
                    if (jMap.get(column).asString().contains(cannotcontain)) {
                        allow = false;
                    }
                }

                // this is the fastest way. I was learning before and will
                // rewrite when time permits.
                if (allow == true) {
                    if (jMap.containsKey("offenderhash")) {
                        if (this.singlepaths != null) {
                            collection.add(new ParseSingle(Integer.toString(offenderhash), header, footer,
                                    pagenarrow, singlepaths,
                                    StringEscapeUtils.unescapeXml(jMap.get(column).asString()), replace,
                                    replaceSequence));
                        }

                        if (this.multipaths != null) {
                            collection.add(new ParseRows(Integer.toString(offenderhash), header, footer,
                                    pagenarrow, multipaths,
                                    StringEscapeUtils.unescapeXml(jMap.get(column).asString()), replace,
                                    replaceSequence));
                        }

                        if (this.recordpaths != null) {
                            collection.add(new ParseLoop(Integer.toString(offenderhash), header, footer,
                                    pagenarrow, recordpaths,
                                    StringEscapeUtils.unescapeXml(jMap.get(column).asString()), replace,
                                    replaceSequence));
                        }
                    }
                }
                offenderhash += 1;

            }

            // complete parse
            log.info("Waiting for Parsing to Complete.");
            if (collection.size() > 0) {
                futures = fjp.invokeAll(collection);

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

                log.info("Waited for " + Integer.toString(w) + " Cycles!");
                for (Future<ArrayList<String>> f : futures) {
                    try {
                        outdata.addAll(f.get());
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (ExecutionException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

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

            int cp = 0;
            // post data
            log.info("Posting Data @ " + Calendar.getInstance().getTime().toString());
            if (outdata.size() > 0) {

                for (int i = 0; i < qnums; i++) {

                    ArrayList<String> od = new ArrayList<String>(
                            ((cp + (Math.round(outdata.size() / qnums) - cp))));

                    if (cp + (Math.round(outdata.size() / qnums)) < outdata.size()) {
                        od.addAll(outdata.subList(cp, (cp + (Math.round(outdata.size() / qnums)))));
                    } else {
                        od.addAll(outdata.subList(cp, (outdata.size() - 1)));
                    }
                    fjp.execute(new SplitPost(template, od));
                    cp += Math.round(outdata.size() / qnums);
                }

                int w = 0;
                while (fjp.getActiveThreadCount() > 0 && fjp.isQuiescent() == false) {
                    w++;
                }
                log.info("Waited for " + Integer.toString(w) + " cycles!");

            }
            log.info("Finished Posting to DB @ " + Calendar.getInstance().getTime().toString());

            // size should remain same with 10 slot buffer room
            data.clear();
            outdata.clear();
        }

        // my favorite really desperate attempt to actually invoke garbage
        // collection because of MASSIVE STRINGS
        System.gc();
        Runtime.getRuntime().gc();

    } while (run);

    log.info("Shutting Down FJP");
    // shutdown fjp
    if (fjp.isShutdown() == false) {
        fjp.shutdownNow();
    }

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

}

From source file:org.fao.fenix.web.modules.olap.server.OlapServiceImpl.java

private List<String> createMap(OLAPParameters p, LayerValuesProvider provider, Map<String, String> filters,
        String mapTitle, int intervals, String minColor, String maxColor, boolean showBaseLayer) {

    // initiate result
    List<String> paths = new ArrayList<String>();

    // GAUL level
    int gaulLevel = 0;
    if (provider.getLayerCode().charAt(provider.getLayerCode().length() - 1) == '1')
        gaulLevel = 1;/*from  w w  w .j av a2s .  c o  m*/

    GeometryResolver geometryResolver = new DBFLGeometryResolver(provider);
    ((DBFLGeometryResolver) geometryResolver).setLayerGaulUtils(layerGaulUtils);

    FeatureBuilder featureBuilder = new QuickFeatureBuilder(geometryResolver);

    QuickFeatureCollection fc = new QuickFeatureCollection(provider, featureBuilder);
    QuickMap quickMap = new QuickMap();
    quickMap.setWidth(WIDTH);
    quickMap.setHeight(HEIGHT);
    quickMap.setIntervals(intervals);

    quickMap.setMaxColor(OLAPUtils.getUserColor(minColor));
    quickMap.setMinColor(OLAPUtils.getUserColor(maxColor));

    BufferedImage quickimage = quickMap.render(fc);

    List<Range> ranges = quickMap.getLastRanges();

    CQLFilter gaul1Filters = getFilter(provider, 1);

    try {
        GeoView geoViewG0;

        BoundingBox bbox = quickMap.getLastBbox();

        // building the lower layers
        List<GeoView> lowerLayers = new ArrayList<GeoView>();
        if (showBaseLayer) {
            geoViewG0 = new GeoView(wmsMapProviderDao.findByCode("layer_baseraster"));
            lowerLayers.add(geoViewG0);
        }
        geoViewG0 = new GeoView(wmsMapProviderDao.findByCode("layer_gaul1"));
        lowerLayers.add(geoViewG0);

        // building the upper layers
        List<GeoView> upperLayers = new ArrayList<GeoView>();

        // the style can be created once for all
        Long layerId = olapDao.findLayerIdFromLayerCode(provider.getLayerCode());
        String admName = GaulUtils.getMainLabelFieldname(gaulLevel);
        String labels = createLabelStyle(layerId, admName, "000000");

        geoViewG0 = new GeoView(wmsMapProviderDao.findByCode("layer_gaul1"));
        geoViewG0.setStyleName(labels);
        geoViewG0.setCqlFilter(gaul1Filters);
        upperLayers.add(geoViewG0);
        geoViewG0 = new GeoView(wmsMapProviderDao.findByCode("layer_gaul0"));
        upperLayers.add(geoViewG0);

        BufferedImage lowerImage = getLayerImage(bbox, lowerLayers);
        BufferedImage upperImage = getLayerImage(bbox, upperLayers);

        // create additional layers
        List<BufferedImage> images = new ArrayList<BufferedImage>();

        images.add(lowerImage);
        images.add(quickimage);
        images.add(upperImage);

        // add transparencies
        List<Float> transparencies = new ArrayList<Float>();
        for (int i = 0; i < images.size(); i++)
            transparencies.add(new Float(1.0));

        // merge and save
        BufferedImage merged = ImageMerger.merge(images, transparencies);
        String mergedFileName = String.valueOf(Math.random()) + "_MERGED.png";
        File mergedFile = new File(Setting.getSystemPath() + "/olapMaps/" + mergedFileName);
        ImageIO.write(merged, "png", mergedFile);

        StringBuffer table = createImageTableWithSideLegend(p, mergedFileName, ranges, filters, mapTitle);
        String mapPath = createImageWithLegend(table);
        paths.add(mapPath);

    } catch (IOException ex) {
        LOGGER.error(ex);
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (FenixGWTException e) {
        LOGGER.error(e);
    }

    // return result
    return paths;
}

From source file:com.kdmanalytics.toif.framework.toolAdaptor.ToolAdaptor.java

/**
 * create the house keeping facts.//from www  .  j a  va2 s .c  o m
 * 
 * @param housekeepingFile
 * @throws ToifException
 */
public void createFacts(java.io.File housekeepingFile) throws ToifException {
    try {
        houseKeeping = getHousekeepingProperties(housekeepingFile);

        // creates the housekeeping facts and elements
        getHouseKeepingFacts();

        // creates the project facts and elements
        getProjectFacts();

        // creates the tool facts and elements
        getToolFacts();

        // creates the facts and elements about the organization
        getOrganizationFacts();

        // creates the facts and elements about the person
        getPersonFacts();
    } catch (final NullPointerException e) {
        if (options != null) {
            System.err.println(
                    options.getAdaptor().toString() + ": The house-keeping file is missing some properties. ");
            e.printStackTrace();
        } else {
            System.err.println("The house-keeping file is missing some properties. ");
            e.printStackTrace();
        }
    }
}