Example usage for java.lang NumberFormatException printStackTrace

List of usage examples for java.lang NumberFormatException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.onebus.view.MainActivity.java

/**
 *  3 - 19//w  w w . j av  a 2 s .  c  o m
 */
@SuppressLint("NewApi")
private void perfomZoom(boolean isZoomIn) {
    try {
        MapStatusUpdate u;
        zoomLevel = mBaiduMap.getMapStatus().zoom;
        if (isZoomIn) {
            zoomOutButton.setImageResource(R.drawable.main_icon_zoomout);
            if (zoomLevel + 0.5 < mBaiduMap.getMaxZoomLevel() * 0.9) {
                zoomLevel += 0.5;
                u = MapStatusUpdateFactory.zoomTo(zoomLevel);
            } else {
                zoomLevel = (float) (mBaiduMap.getMaxZoomLevel() * 0.9);
                u = MapStatusUpdateFactory.zoomTo(zoomLevel);
                zoomInButton.setImageResource(R.drawable.main_icon_zoomin_dis);
            }
            zoomInButton
                    .setBackground(getResources().getDrawable(R.drawable.main_widget_bottombutton_selector));

        } else {
            zoomInButton.setImageResource(R.drawable.main_icon_zoomin);
            if (zoomLevel - 0.5 > mBaiduMap.getMinZoomLevel() + 5) {
                zoomLevel -= 0.5;
                u = MapStatusUpdateFactory.zoomTo(zoomLevel);
            } else {
                zoomLevel = mBaiduMap.getMinZoomLevel() + 5;
                u = MapStatusUpdateFactory.zoomTo(zoomLevel);
                zoomOutButton.setImageResource(R.drawable.main_icon_zoomout_dis);
            }
            zoomOutButton
                    .setBackground(getResources().getDrawable(R.drawable.main_widget_bottombutton_selector));
        }

        mBaiduMap.animateMapStatus(u);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
}

From source file:org.akaza.openclinica.control.managestudy.ViewStudySubjectServlet.java

@Override
public void processRequest() throws Exception {
    SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    int studySubId = fp.getInt("id", true);// studySubjectId
    String from = fp.getString("from");

    int parentStudyId = currentStudy.getParentStudyId() > 0 ? currentStudy.getParentStudyId()
            : currentStudy.getId();//from   ww w. j  ava  2  s .  c  o m
    StudyParameterValueDao studyParameterValueDao = (StudyParameterValueDao) SpringServletAccess
            .getApplicationContext(context).getBean("studyParameterValueDao");
    StudyParameterValue parentSPV = studyParameterValueDao.findByStudyIdParameter(parentStudyId,
            "subjectIdGeneration");
    currentStudy.getStudyParameterConfig().setSubjectIdGeneration(parentSPV.getValue());

    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);

    // if coming from change crf version -> display message
    String crfVersionChangeMsg = fp.getString("isFromCRFVersionChange");
    if (crfVersionChangeMsg != null && !crfVersionChangeMsg.equals("")) {
        addPageMessage(crfVersionChangeMsg);

    }
    if (studySubId == 0) {
        addPageMessage(respage.getString("please_choose_a_subject_to_view"));
        forwardPage(Page.LIST_STUDY_SUBJECTS);
    } else {
        if (!StringUtils.isBlank(from)) {
            request.setAttribute("from", from); // form ListSubject or
            // ListStudySubject
        } else {
            request.setAttribute("from", "");
        }
        StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);

        request.setAttribute("studySub", studySub);
        request.setAttribute("originatingPage",
                URLEncoder.encode("ViewStudySubject?id=" + studySub.getId(), "UTF-8"));

        int studyId = studySub.getStudyId();
        int subjectId = studySub.getSubjectId();

        StudyDAO studydao = new StudyDAO(sm.getDataSource());
        StudyBean study = (StudyBean) studydao.findByPK(studyId);
        // Check if this StudySubject would be accessed from the Current Study
        if (studySub.getStudyId() != currentStudy.getId()) {
            if (currentStudy.getParentStudyId() > 0) {
                addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " "
                        + respage.getString("change_active_study_or_contact"));
                forwardPage(Page.MENU_SERVLET);
                return;
            } else {
                // The SubjectStudy is not belong to currentstudy and current study is not a site.
                Collection sites = studydao.findOlnySiteIdsByStudy(currentStudy);
                if (!sites.contains(study.getId())) {
                    addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " "
                            + respage.getString("change_active_study_or_contact"));
                    forwardPage(Page.MENU_SERVLET);
                    return;
                }
            }
        }
        // If the study subject derives from a site, and is being viewed
        // from a parent study,
        // then the study IDs will be different. However, since each note is
        // saved with the specific
        // study ID, then its study ID may be different than the study
        // subject's ID.
        boolean subjectStudyIsCurrentStudy = studyId == currentStudy.getId();
        boolean isParentStudy = study.getParentStudyId() < 1;

        // Get any disc notes for this subject : studySubId
        DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(sm.getDataSource());
        List<DiscrepancyNoteBean> allNotesforSubject = new ArrayList<DiscrepancyNoteBean>();

        // These methods return only parent disc notes
        if (subjectStudyIsCurrentStudy && isParentStudy) {
            allNotesforSubject = discrepancyNoteDAO.findAllSubjectByStudyAndId(study, subjectId);
            allNotesforSubject.addAll(discrepancyNoteDAO.findAllStudySubjectByStudyAndId(study, studySubId));
        } else {
            if (!isParentStudy) {
                StudyBean stParent = (StudyBean) studydao.findByPK(study.getParentStudyId());
                allNotesforSubject = discrepancyNoteDAO.findAllSubjectByStudiesAndSubjectId(stParent, study,
                        subjectId);
                allNotesforSubject.addAll(discrepancyNoteDAO
                        .findAllStudySubjectByStudiesAndStudySubjectId(stParent, study, studySubId));
            } else {
                allNotesforSubject = discrepancyNoteDAO.findAllSubjectByStudiesAndSubjectId(currentStudy, study,
                        subjectId);
                allNotesforSubject.addAll(discrepancyNoteDAO
                        .findAllStudySubjectByStudiesAndStudySubjectId(currentStudy, study, studySubId));
            }
        }

        if (!allNotesforSubject.isEmpty()) {
            setRequestAttributesForNotes(allNotesforSubject);
        }

        SubjectBean subject = (SubjectBean) sdao.findByPK(subjectId);
        if (currentStudy.getStudyParameterConfig().getCollectDob().equals("2")) {
            Date dob = subject.getDateOfBirth();
            if (dob != null) {
                Calendar cal = Calendar.getInstance();
                cal.setTime(dob);
                int year = cal.get(Calendar.YEAR);
                request.setAttribute("yearOfBirth", new Integer(year));
            } else {
                request.setAttribute("yearOfBirth", "");
            }
        }

        request.setAttribute("subject", subject);

        /*
         * StudyDAO studydao = new StudyDAO(sm.getDataSource()); StudyBean
         * study = (StudyBean) studydao.findByPK(studyId);
         */
        // YW 11-26-2007 <<
        StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
        if (isParentStudy) {
            study.getStudyParameterConfig()
                    .setCollectDob(spvdao.findByHandleAndStudy(studyId, "collectDob").getValue());
        } else {
            study.getStudyParameterConfig().setCollectDob(
                    spvdao.findByHandleAndStudy(study.getParentStudyId(), "collectDob").getValue());
        }

        // YW >>
        request.setAttribute("subjectStudy", study);

        if (study.getParentStudyId() > 0) {// this is a site,find parent
            StudyBean parentStudy2 = (StudyBean) studydao.findByPK(study.getParentStudyId());
            request.setAttribute("parentStudy", parentStudy2);
        } else {
            request.setAttribute("parentStudy", new StudyBean());
        }

        ArrayList children = (ArrayList) sdao.findAllChildrenByPK(subjectId);
        request.setAttribute("children", children);

        // find study events
        StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());

        StudySubjectService studySubjectService = (StudySubjectService) WebApplicationContextUtils
                .getWebApplicationContext(getServletContext()).getBean("studySubjectService");
        List<DisplayStudyEventBean> displayEvents = studySubjectService
                .getDisplayStudyEventsForStudySubject(studySub, ub, currentRole);
        List<DisplayStudyEventBean> tempList = new ArrayList<>();
        for (DisplayStudyEventBean displayEvent : displayEvents) {
            if (!displayEvent.getStudyEvent().getStudyEventDefinition().getType().equals(COMMON)) {
                tempList.add(displayEvent);
            }
        }
        displayEvents = new ArrayList(tempList);

        for (int i = 0; i < displayEvents.size(); i++) {
            DisplayStudyEventBean decb = displayEvents.get(i);
            if (!(currentRole.isDirector() || currentRole.isCoordinator())
                    && decb.getStudyEvent().getSubjectEventStatus().isLocked()) {
                decb.getStudyEvent().setEditable(false);
            }
        }
        if (currentStudy.getParentStudyId() > 0) {
            HideCRFManager hideCRFManager = HideCRFManager.createHideCRFManager();
            for (DisplayStudyEventBean displayStudyEventBean : displayEvents) {
                hideCRFManager.removeHiddenEventCRF(displayStudyEventBean);
            }
        }

        EntityBeanTable table = fp.getEntityBeanTable();
        table.setSortingIfNotExplicitlySet(1, false);// sort by start
        // date, desc
        ArrayList allEventRows = DisplayStudyEventRow.generateRowsFromBeans(displayEvents);

        String[] columns = { resword.getString("event") + " (" + resword.getString("occurrence_number") + ")",
                resword.getString("start_date1"), resword.getString("status"),
                resword.getString("event_actions"), resword.getString("CRFs") };
        table.setColumns(new ArrayList(Arrays.asList(columns)));
        table.hideColumnLink(4);
        table.hideColumnLink(5);
        if (!"removed".equalsIgnoreCase(studySub.getStatus().getName())
                && !"auto-removed".equalsIgnoreCase(studySub.getStatus().getName())) {
            if (currentStudy.getStatus().isAvailable() && !currentRole.getRole().equals(Role.MONITOR)) {
                table.addLink(resword.getString("add_new"),
                        "CreateNewStudyEvent?"
                                + CreateNewStudyEventServlet.INPUT_STUDY_SUBJECT_ID_FROM_VIEWSUBJECT + "="
                                + studySub.getId());
            }
        }
        HashMap args = new HashMap();
        args.put("id", new Integer(studySubId).toString());
        table.setQuery("ViewStudySubject", args);
        table.setRows(allEventRows);
        table.computeDisplay();

        request.setAttribute("table", table);
        SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
        ArrayList groupMaps = (ArrayList) sgmdao.findAllByStudySubject(studySubId);
        request.setAttribute("groups", groupMaps);

        // find audit log for events
        AuditEventDAO aedao = new AuditEventDAO(sm.getDataSource());
        ArrayList logs = aedao.findEventStatusLogByStudySubject(studySubId);
        // logger.warning("^^^ retrieved logs");
        UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
        ArrayList eventLogs = new ArrayList();
        // logger.warning("^^^ starting to iterate");
        for (int i = 0; i < logs.size(); i++) {
            AuditEventBean avb = (AuditEventBean) logs.get(i);
            StudyEventAuditBean sea = new StudyEventAuditBean();
            sea.setAuditEvent(avb);
            StudyEventBean se = (StudyEventBean) sedao.findByPK(avb.getEntityId());
            StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao
                    .findByPK(se.getStudyEventDefinitionId());
            sea.setDefinition(sed);
            String old = avb.getOldValue().trim();
            try {
                if (!StringUtils.isBlank(old)) {
                    SubjectEventStatus oldStatus = SubjectEventStatus.get(new Integer(old).intValue());
                    sea.setOldSubjectEventStatus(oldStatus);
                }
                String newValue = avb.getNewValue().trim();
                if (!StringUtils.isBlank(newValue)) {
                    SubjectEventStatus newStatus = SubjectEventStatus.get(new Integer(newValue).intValue());
                    sea.setNewSubjectEventStatus(newStatus);
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
            UserAccountBean updater = (UserAccountBean) udao.findByPK(avb.getUserId());
            sea.setUpdater(updater);
            eventLogs.add(sea);
        }
        request.setAttribute("eventLogs", eventLogs);
        String errorData = request.getParameter("errorData");
        if (StringUtils.isNotEmpty(errorData))
            request.setAttribute("errorData", errorData);

        String participateStatus = getParticipateStatus(parentStudyId);
        request.setAttribute("participateStatus", participateStatus);

        forwardPage(Page.VIEW_STUDY_SUBJECT);
    }
}

From source file:org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail.java

/**
 * Gets the disbVchrVendorIdNumber attribute as an Integer.
 *
 * @return Returns the disbVchrVendorIdNumber in Integer form. This is the format used on the VendorDetail.
 *///from w w w .j a  v a  2 s  .  c o m
public Integer getDisbVchrVendorHeaderIdNumberAsInteger() {
    if (getDisbVchrVendorHeaderIdNumber() != null) {
        try {
            return new Integer(getDisbVchrVendorHeaderIdNumber());
        } catch (NumberFormatException nfe) {
            nfe.printStackTrace();
        }
    }
    return null;
}

From source file:org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail.java

/**
 * This method.../*ww  w  . j  a v  a  2s. c  o m*/
 *
 * @return
 */
public Integer getDisbVchrVendorDetailAssignedIdNumberAsInteger() {
    if (getDisbVchrVendorDetailAssignedIdNumber() != null) {
        try {
            return new Integer(getDisbVchrVendorDetailAssignedIdNumber());
        } catch (NumberFormatException nfe) {
            nfe.printStackTrace();
        }
    }
    return null;
}

From source file:org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail.java

/**
 * Gets the disbVchrVendorAddressIdNumber attribute.
 *
 * @return Returns the disbVchrVendorAddressIdNumber.
 *//*from w w w  . j a v a2s  . co m*/
public Integer getDisbVchrVendorAddressIdNumberAsInteger() {
    if (getDisbVchrVendorAddressIdNumber() != null) {
        try {
            return new Integer(getDisbVchrVendorAddressIdNumber());
        } catch (NumberFormatException nfe) {
            nfe.printStackTrace();
        }
    }
    return null;
}

From source file:com.trukr.shipper.fragment.RequestStatus.java

private void driverEnroute() {
    if (queue == null) {
        queue = Volley.newRequestQueue(mContext);
    }//from  w  w w.j  av  a  2  s.  c  om
    JSONObject object = null;
    try {
        object = new JSONObject();
        object.put("UserType", IConstant.UserType);
        object.put("UserId", userId);
        object.put("AuthToken", authToken);
        object.put("OrderId", orderId);
        System.out.println("usertype---->" + IConstant.UserType);
        System.out.println("UserId---->" + userId);
        System.out.println("AuthToken---->" + authToken);
        System.out.println("OrderId---->" + orderId);
    } catch (JSONException e1) {
        e1.printStackTrace();
    }
    final JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, IConstant.DriverEnroute,
            object, new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Log.d("Test", response.toString());
                    try {
                        String latitude = response.getString("latitude");
                        String longitude = response.getString("longitude");
                        System.out.println("driver enroute-->" + latitude + "   " + longitude);
                        Double lat = null;
                        Double lon = null;
                        try {
                            lat = Double.parseDouble(latitude);
                            lon = Double.parseDouble(longitude);
                        } catch (NumberFormatException e) {
                            e.printStackTrace();
                        }
                        try {
                            LatLng enroute = new LatLng(lat, lon);
                            map.addMarker(new MarkerOptions().position(enroute)
                                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.trucker)));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }

            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.d("Response: ", error.toString());
                    String json;
                    if (error.networkResponse != null && error.networkResponse.data != null) {
                        try {
                            json = new String(error.networkResponse.data,
                                    HttpHeaderParser.parseCharset(error.networkResponse.headers));
                            Log.e("Error list-->", json);
                            try {
                                //   Parsing json object response response will be a json object
                                if (json != null) {
                                    JSONObject jsonObject = new JSONObject(json);
                                    String message = jsonObject.getString("message");
                                    Toast.makeText(RequestStatus.this, message, Toast.LENGTH_LONG).show();
                                    AlertDialog.Builder dlgAlert = new AlertDialog.Builder(RequestStatus.this);
                                    dlgAlert.setMessage(message);
                                    dlgAlert.setTitle("Login ");
                                    dlgAlert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int which) {
                                            //dismiss the dialog
                                            dialog.dismiss();

                                        }
                                    });
                                    dlgAlert.setCancelable(true);
                                    dlgAlert.create().show();
                                }
                            } catch (JSONException e) {
                                e.printStackTrace();
                                Toast.makeText(RequestStatus.this, "Error: " + e.getMessage(),
                                        Toast.LENGTH_LONG).show();
                            }
                        } catch (UnsupportedEncodingException e) {
                            Log.e("Error 111", e.getMessage());
                        }
                    }
                }
            });
    // volley time out error
    request.setRetryPolicy(new DefaultRetryPolicy(500000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    queue.add(request);
}

From source file:massbank.BatchSearchWorker.java

/**
 * Ytt@C???ieLXg`?j//w ww .j  av a2s .  c  o m
 * @param resultFile t@C
 * @param textFile YtpeLXgt@C
 */
private void createTextFile(File resultFile, File textFile) {
    NumberFormat nf = NumberFormat.getNumberInstance();
    LineNumberReader in = null;
    PrintWriter out = null;
    try {
        in = new LineNumberReader(new FileReader(resultFile));
        out = new PrintWriter(new BufferedWriter(new FileWriter(textFile)));

        // wb_?[?o
        String reqIonStr = "Both";
        try {
            if (Integer.parseInt(this.ion) > 0) {
                reqIonStr = "Positive";
            } else if (Integer.parseInt(this.ion) < 0) {
                reqIonStr = "Negative";
            }
        } catch (NumberFormatException nfe) {
            nfe.printStackTrace();
        }
        out.println("***** MassBank Batch Service Results *****");
        out.println();
        out.println("Request Date: " + this.time);
        out.println("# Instrument Type: " + this.inst);
        out.println("# MS Type: " + this.ms);
        out.println("# Ion Mode: " + reqIonStr);
        out.println();
        out.println();

        // ?o
        String line;
        long queryCnt = 0;
        boolean readName = false;
        boolean readHit = false;
        boolean readNum = false;
        boolean isFinalLine = false;
        while ((line = in.readLine()) != null) {
            line = line.trim();
            isFinalLine = false;
            if (!readName) {
                queryCnt++;
                out.println("### Query " + nf.format(queryCnt) + " ###");
                out.println("# Name: " + line);
                readName = true;
            } else if (!readHit) {
                int num = Integer.parseInt(line);
                if (num == -1) {
                    out.println("[ERROR] Invalid query\n");
                    break;
                }
                out.println("# Hit: " + nf.format(num));
                out.println();
                readHit = true;
            } else if (!readNum) {
                out.println("Top " + line + " List");
                out.println("Accession\tTitle\tFormula\tMass\tScore\tHit");
                out.println();
                readNum = true;
            } else {
                if (!line.equals("")) {
                    String[] data = formatLine(line);
                    StringBuilder sb = new StringBuilder();
                    sb.append(data[0]).append("\t").append(data[1]).append("\t").append(data[2]).append("\t")
                            .append(data[3]).append("\t").append(data[4]).append("\t").append(data[5]);
                    out.println(sb.toString());
                } else {
                    out.println();
                    out.println();
                    readName = false;
                    readHit = false;
                    readNum = false;
                    isFinalLine = true;
                }
            }
        }
        if (!isFinalLine) {
            out.println();
            out.println();
        }
        out.println("***** END ********************************");
        out.println();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            if (in != null) {
                in.close();
            }
        } catch (IOException e) {
        }
        if (out != null) {
            out.flush();
            out.close();
        }
    }
}

From source file:org.forumj.web.requesthandler.handler.ForumThreadHandler.java

@Override
protected void doHandle(AsyncContext context) throws FJWebException {
    try {/* w  ww  .  jav  a  2 s  . c  om*/
        HttpServletRequest request = (HttpServletRequest) context.getRequest();
        HttpServletResponse response = (HttpServletResponse) context.getResponse();
        long startTime = new Date().getTime();
        StringBuffer buffer = new StringBuffer();
        HttpSession session = request.getSession();
        cache(response);
        //  ?  ?? ?  ,  
        Integer pageNumber = request.getParameter("page") == null ? 1
                : Integer.valueOf(request.getParameter("page"));
        // id 
        Long threadId = request.getParameter("id") == null ? 1 : Long.valueOf(request.getParameter("id"));
        // ? ?,   
        String replyPostParameter = request.getParameter("reply");
        String end = request.getParameter("end");
        //  ? ??
        String msg = request.getParameter("msg");
        VoiceService voiceService = FJServiceHolder.getVoiceService();
        PostService postService = FJServiceHolder.getPostService();
        SubscribeService subscribeService = FJServiceHolder.getSubscribeService();
        ThreadService treadService = FJServiceHolder.getThreadService();
        IFJThread thread = treadService.readThread(threadId);
        boolean isAnswer = replyPostParameter != null && !"".equals(replyPostParameter.trim());
        LocaleString locale = (LocaleString) session.getAttribute("locale");
        IUser user = (IUser) session.getAttribute("user");
        IgnorService ignorService = FJServiceHolder.getIgnorService();
        List<IIgnor> ignorList = ignorService.readUserIgnor(user.getId());
        //  ??
        Integer count = thread.getPcount();
        Integer couP = (int) (Math.floor((double) count / user.getPt()) + 2);
        // ?   ? ?,    ?
        boolean lastPost = false;
        if (isAnswer || end != null) {
            pageNumber = couP - 1;
            lastPost = true;
        }
        int nfirstpost = (pageNumber - 1) * user.getPt();
        List<IFJPost> posts = postService.readPosts(user, threadId, nfirstpost, user.getPt(), pageNumber,
                lastPost);
        int postsAmount = posts.size();
        //  ?? ?
        session.setAttribute("page", pageNumber);
        session.setAttribute("id", threadId);
        session.setAttribute("where", request.getContextPath() + "?id=" + threadId + "&page=" + pageNumber);
        int countPosts = 0;
        if (msg != null && !"".equals(msg.trim())) {
            try {
                Long msgId = new Long(msg);
                countPosts = postService.getPostsCountInThread(threadId, msgId);
            } catch (NumberFormatException e) {
                e.printStackTrace();
                msg = null;
            }
            pageNumber = (int) (Math.floor(countPosts / user.getPt()) + 1);
        }
        // ? ?
        // ?
        if (!isRobot(request)) {
            // ?
            treadService.setSeen(user, threadId);
        }
        // ?   ?     colspan!
        buffer.append("<div>");
        buffer.append("<table width=100%>");
        buffer.append("<tr>");
        buffer.append("<td>");
        buffer.append("<table>");
        buffer.append("<tr>");
        buffer.append("<td class='page'>");
        buffer.append("<font class=mnuforum><b>" + locale.getString("mess22") + "&nbsp;</b></font>");
        buffer.append("</td>");
        int i2 = 0;
        for (int i1 = 1; i1 < couP; i1++) {
            i2 = i2 + 1;
            if ((i1 > (pageNumber - 5) && i1 < (pageNumber + 5)) || i2 == 10 || i1 == 1 || i1 == (couP - 1)) {
                if (i2 == 10)
                    i2 = 0;
                if (i1 == pageNumber) {
                    buffer.append("<td class='pagecurrent'>");
                    buffer.append("<span class=mnuforum><b>" + i1 + "</b></span>");
                    buffer.append("</td>");
                } else {
                    buffer.append("<td class='page'>");
                    buffer.append("<a class=mnuforum href='" + FJUrl.VIEW_THREAD + "?page=" + i1 + "&id="
                            + threadId + "'>" + i1 + "</a>");
                    buffer.append("</td>");
                }
            }
        }
        buffer.append("</tr>");
        buffer.append("</table>");

        buffer.append("</td>");

        buffer.append("<td align=right>");
        //  ? :)
        buffer.append("<span class=posthead>" + locale.getString("mess91") + "</span>");
        buffer.append("</td>");
        buffer.append("</tr></table>");
        buffer.append("</td>");
        buffer.append("</tr></table></td></tr>");
        //   ?? ?
        // ?  
        buffer.append("<tr><td height='400' valign='top'>");
        //  
        buffer.append("<table border='0' cellpadding='2' cellspacing='0' width='100%'>");
        // ? - ? 
        if (postsAmount > count) {
            postsAmount = count - (pageNumber - 1) * user.getPt();
        } else {
            postsAmount = user.getPt();
        }
        // 
        //  ?
        for (int postIndex = 0; postIndex < posts.size(); postIndex++) {
            IFJPost post = posts.get(postIndex);
            buffer.append(writePost(post, ignorList, user, pageNumber, locale, thread, voiceService));
        }
        // / 
        buffer.append("</table>");
        // "" 
        buffer.append("</td>");
        buffer.append("</tr>");
        //   ??
        // ?  ?
        buffer.append("<tr>");
        buffer.append("<td width='100%'>");
        buffer.append("<table border='0' style='border-collapse: collapse' width='100%'>");
        buffer.append("<tr>");
        buffer.append("<td colspan='5'>");
        buffer.append("<table>");
        buffer.append("<tr>");
        buffer.append("<td class='page'>");
        buffer.append("<font class=mnuforum><b>" + locale.getString("mess22") + "&nbsp;</b></font>");
        buffer.append("</td>");
        i2 = 0;
        for (int i1 = 1; i1 < couP; i1++) {
            i2 = i2 + 1;
            if ((i1 > (pageNumber - 5) && i1 < (pageNumber + 5)) || i2 == 10 || i1 == 1 || i1 == (couP - 1)) {
                if (i2 == 10)
                    i2 = 0;
                if (i1 == pageNumber) {
                    buffer.append("<td class='pagecurrent'>");
                    buffer.append("<span class=mnuforum><b>" + i1 + "</b></span>");
                    buffer.append("</td>");
                } else {
                    buffer.append("<td class='page'>");
                    buffer.append("<a class=mnuforum href='" + FJUrl.VIEW_THREAD + "?page=" + i1 + "&id="
                            + threadId + "'>" + i1 + "</a>");
                    buffer.append("</td>");
                }
            }
        }
        buffer.append("</tr>");
        buffer.append("</table>");
        buffer.append("</td>");
        buffer.append("</tr>");
        //  ""
        buffer.append("</table></td></tr>");
        if (user.isLogined() && !user.isBanned() && !thread.isClosed()) {
            // ?/?   
            //  ??
            String action = "";
            String mess = "";
            if (subscribeService.isUserSubscribed(threadId, user.getId())) {
                //? ?,  ??
                action = FJUrl.DELETE_SUBSCRIBE + "?pg=" + pageNumber;
                mess = locale.getString("mess90");
            } else {
                //?  -   ???
                action = FJUrl.ADD_SUBSCRIBE + "?pg=" + pageNumber;
                mess = locale.getString("mess89");
            }
            buffer.append("<tr>");
            buffer.append("<td align=right>");
            buffer.append("<form id='subs' action='" + action + "' method='post'>");
            buffer.append("<table>");
            buffer.append("<tr>");
            buffer.append("<td>");
            buffer.append(fd_button(mess, "subscribe();", "btn_subs", "1"));
            //  ...
            buffer.append("<input type=hidden name='IDT' value='" + threadId + "'>");
            buffer.append(fd_form_add(user));
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("</table>");
            buffer.append("</form>");
            buffer.append("</td>");
            buffer.append("</tr>");
            String re = "";
            String head = thread.getHead();
            IFJPost replyPost = null;
            // ? /
            if (isAnswer) {
                replyPost = postService.read(Long.valueOf(replyPostParameter));
                head = removeSlashes(replyPost.getHead().getTitle());
            }
            // ? 
            //   ?
            buffer.append("<tr>");
            buffer.append("<td>");
            buffer.append("<a name='edit'>&nbsp;");
            buffer.append("</a>");
            buffer.append("<table>");
            buffer.append("<tr>");
            buffer.append("<td>");
            buffer.append("<form name='post' action='" + FJUrl.ADD_POST + "' method='post'>");
            buffer.append("<table width='100%'>");
            //
            buffer.append("<tr>");
            buffer.append("<td colspan='2' align='CENTER'>");
            buffer.append("<table>");
            buffer.append("<tr>");
            buffer.append("<td>");
            buffer.append(locale.getString("mess59") + ":&nbsp;");
            buffer.append("</td>");
            buffer.append("<td>");
            buffer.append(fd_input("NHEAD", re + HtmlChars.convertHtmlSymbols(head), "70", "1"));
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("</table>");
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("<tr>");
            // 
            buffer.append("<td width='400' align='CENTER'>");
            buffer.append("<p>");
            buffer.append(locale.getString("mess21") + ":");
            buffer.append("</p>");
            buffer.append("</td>");
            //
            buffer.append("<td align='CENTER'>");
            buffer.append("<p>");
            buffer.append(locale.getString("mess12"));
            buffer.append("</p>");
            buffer.append("</td>");
            buffer.append("</tr>");
            //?
            buffer.append("<tr>");
            buffer.append("<td valign='TOP' width='100%' height='100%'>");
            //
            buffer.append(smiles_add(locale.getString("mess11")));
            buffer.append("</td>");
            buffer.append("<td width='500' align='CENTER' valign='top'>");
            //?
            buffer.append(autotags_add());
            // ?
            String textarea = "";
            if (isAnswer) {
                String ans = request.getParameter("ans");
                if (replyPost.getHead().getAuth().equals(user.getId())) {
                    textarea += HtmlChars.convertHtmlSymbols(removeSlashes(replyPost.getBody().getBody()));
                } else if (ans == null) {
                    textarea += "[quote][b]" + HtmlChars.convertHtmlSymbols(
                            removeSlashes(replyPost.getHead().getAuthor().getNick())) + "[/b] ";
                    textarea += locale.getString("mess14") + String.valueOf((char) 13);
                    textarea += HtmlChars.convertHtmlSymbols(removeSlashes(replyPost.getBody().getBody()))
                            + "[/quote]";
                } else {
                    textarea += "[b]" + removeSlashes(replyPost.getHead().getAuthor().getNick()) + "[/b]";
                    textarea += ", ";
                }
            }
            buffer.append("<textarea rows='20' class='mnuforumSm' id='ed1' name='A2' cols='55'>" + textarea
                    + "</textarea>");
            buffer.append("<br>");
            buffer.append("<input type='checkbox' name='no_exit' value='1'>");
            buffer.append(locale.getString("mess123"));
            //
            buffer.append("<table>");
            buffer.append("<tr>");
            buffer.append("<td>");
            if (isAnswer && (replyPost.getHead().getAuth().equals(user.getId()))) {
                buffer.append(fd_button(locale.getString("mess13"), "post_submit(\"write_edit\");", "B1", "1"));
            } else {
                buffer.append(fd_button(locale.getString("mess13"), "post_submit(\"write_new\");", "B1", "1"));
            }
            buffer.append("</td>");
            buffer.append("<td>");
            if (isAnswer && (replyPost.getHead().getAuth().equals(user.getId()))) {
                buffer.append(fd_button(locale.getString("mess63"), "post_submit(\"view_edit\");", "B1", "1"));
            } else {
                buffer.append(fd_button(locale.getString("mess63"), "post_submit(\"view_new\");", "B3", "1"));
            }
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("</table>");
            //? 
            if (isAnswer && (replyPost.getHead().getAuth().equals(user.getId()))) {
                buffer.append("<input type=hidden name='IDB' size='20' value='" + replyPostParameter + "'>");
                buffer.append(
                        "<input type=hidden name='IDTbl' size='20' value='" + replyPost.getTablePost() + "'>");
                buffer.append("<input type=hidden name='IDPst' size='20' value='" + replyPost.getId().toString()
                        + "'>");
                buffer.append("<input type=hidden name='IDTblHead' size='20' value='" + replyPost.getTableHead()
                        + "'>");
                buffer.append("<input type=hidden name='IDHead' size='20' value='"
                        + replyPost.getId().toString() + "'>");
            }
            //id 
            buffer.append("<input type=hidden name='IDT' size='20' value='" + threadId + "'>");
            if (thread.isQuest()) {
                buffer.append("<input type=hidden name='ISQUEST' size='20' value='true'>");
            }
            buffer.append(fd_form_add(user));
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("</table>");
            buffer.append("</form>");
            buffer.append("</td>");
            buffer.append("</tr>");
            buffer.append("</table>");
            buffer.append("</td>");
            buffer.append("</tr>");
        }
        Double allTime = (double) ((new Date().getTime() - startTime));
        DecimalFormat format = new DecimalFormat("##0.###");
        response.setContentType("text/html; charset=UTF-8");
        PrintWriter writer = response.getWriter();
        String out = buffer.toString();
        writer.write(out.replace("_", format.format(allTime / 1000)));
    } catch (Throwable e) {
        throw new FJWebException(e);
    }
}

From source file:org.jlgranda.fede.controller.FacturaElectronicaHome.java

@PostConstruct
private void init() {
    int amount = 0;
    try {//  w w w.j  a  v a 2 s . c om
        //amount = Integer.valueOf(settingService.findByName(SettingNames.DASHBOARD_RANGE).getValue());
        amount = Integer.valueOf(settingHome.getValue(SettingNames.DASHBOARD_RANGE, "360"));
    } catch (java.lang.NumberFormatException nfe) {
        nfe.printStackTrace();
        amount = 30;
    }

    setEnd(Dates.now());
    setStart(Dates.addDays(getEnd(), -1 * amount));

    setFacturaElectronica(facturaElectronicaService.createInstance());
    setSupplier(getDefaultSupplier());
    setUseDefaultSupplier(false); //TODO desde configuraciones

    setPayment(paymentService.createInstance("EFECTIVO", null, null, null));
    setOutcome("fede-inbox");
}

From source file:com.zhongsou.souyue.activity.SplashActivity.java

private void wrapInterest(String str) {
    CircleResponseResultItem item = new CircleResponseResultItem();
    Uri uri = Uri.parse(str);//from w  ww. j  a v  a2 s.  c  om
    if (uri != null) {
        String interest_id = uri.getQueryParameter("interestId");
        String blog_id = uri.getQueryParameter("blogId");
        String user_id = uri.getQueryParameter("userId");
        String isPrime = uri.getQueryParameter("isPrime");
        String top_status = uri.getQueryParameter("isTop");
        try {
            item.setBlog_id(Long.valueOf(blog_id));
            item.setType(Integer.valueOf(uri.getQueryParameter("type")));
            item.setInterest_id(Long.valueOf(interest_id));
            item.setIs_prime(Integer.valueOf(isPrime));
            item.setTop_status(Integer.valueOf(top_status));
            item.setUser_id(Long.valueOf(user_id));
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        pushInfo.setInterestBlog(item);
    }
}