List of usage examples for java.lang Float intValue
public int intValue()
From source file:woto.business.PaymentService.java
public JSONArray payAmountAtEnd(DBConnection db, JSONObject methodParam) throws ClassNotFoundException { JSONArray joArray = new JSONArray(); // DBConnection db = new DBConnection(true); int mem_id = Integer.parseInt("" + methodParam.get("mem_id")); int s_id = Integer.parseInt("" + methodParam.get("s_id")); long amount = Long.parseLong("" + methodParam.get("amount")); String pay_date = (String) methodParam.get("pay_date"); int collector_id = Integer.parseInt("" + methodParam.get("collector_id")); int created_by = Integer.parseInt("" + getUserId()); //Insert a new Bill for student ParameterList paramList = new ParameterList(); paramList.add("mem_id", "" + mem_id); paramList.add("s_id", "" + s_id); JSONArray freeSchedules = db.Execute("payment.logic", "getFreeSchedule", paramList.toJSONArray()); if (freeSchedules.size() == 0) { throw new BusinessException("Payment Failed. Reason: All payment already completed."); } else {/*w ww . jav a2 s .c o m*/ Iterator<JSONObject> iterator = freeSchedules.iterator(); while (iterator.hasNext()) { //If all amount is paid if (amount <= 0) { break; } //Read the free sch_id and balance that is not yet paid JSONObject freeSchedule = (JSONObject) iterator.next(); int sch_id = Integer.parseInt("" + freeSchedule.get("sch_id")); Float f = Float.parseFloat("" + freeSchedule.get("balance")); int balance = f.intValue(); //4 50 //5 100 long payamount = 0; if (balance >= amount) { payamount = amount; } else { payamount = balance; } amount = amount - payamount; paramList = new ParameterList(); paramList.add("s_id", "" + s_id); paramList.add("pay_date", pay_date, "Date"); paramList.add("amount", "" + payamount); paramList.add("sch_id", "" + sch_id); paramList.add("collector_id", "" + collector_id); paramList.add("created_by", "" + created_by); JSONArray payments = db.Execute("payment.logic", "insertPayment", paramList.toJSONArray()); int pay_id = Integer.parseInt((String) ((JSONObject) payments.iterator().next()).get("key_value")); JSONObject payment = new JSONObject(); payment.put("pay_id", pay_id); payment.put("sch_id", "" + sch_id); payment.put("pay_date", pay_date); payment.put("amount", "" + payamount); payment.put("collector_id", "" + collector_id); payment.put("created_by", "" + created_by); joArray.add(payment); } } // db.commit(); return joArray; }
From source file:woto.business.PaymentService.java
public JSONArray deletePayment(JSONObject methodParam) throws ClassNotFoundException { JSONArray joArray = new JSONArray(); DBConnection db = new DBConnection(true); try {/*from w w w . jav a2 s. c om*/ int pay_id = Integer.parseInt("" + methodParam.get("pay_id")); //Get Payment detail for pay id to be deleted ParameterList paramList = new ParameterList(); paramList.add("pay_id", "" + pay_id); JSONObject delPayment = (JSONObject) db .Execute("payment.logic", "GetPaymentById", paramList.toJSONArray()).iterator().next(); int sch_id = Integer.parseInt("" + delPayment.get("sch_id")); int s_id = Integer.parseInt("" + delPayment.get("s_id")); paramList = new ParameterList(); paramList.add("s_id", "" + s_id); paramList.add("sch_id", "" + sch_id); JSONArray paymentsFromSchId1 = db.Execute("payment.logic", "GetPaymentAfterSchedule", paramList.toJSONArray()); //Delete the payment paramList = new ParameterList(); paramList.add("pay_id", "" + pay_id); db.Execute("payment.logic", "deletePayment", paramList.toJSONArray()); //Get the payment to be reshuffed. Reschuffle all schedule from deleted scheddule paramList = new ParameterList(); paramList.add("s_id", "" + s_id); paramList.add("sch_id", "" + sch_id); JSONArray paymentsFromSchId = db.Execute("payment.logic", "GetPaymentAfterSchedule", paramList.toJSONArray()); if (paymentsFromSchId.size() > 0) { //Delete all schedule from deleted pay id schedule db.Execute("payment.logic", "deletePaymentFromSchId", paramList.toJSONArray()); paramList = new ParameterList(); paramList.add("s_id", "" + s_id); paramList.add("sch_id", "" + sch_id); JSONArray paymentsFromSchId5 = db.Execute("payment.logic", "GetPaymentAfterSchedule", paramList.toJSONArray()); //REpay the amount without the deleted payid Iterator<JSONObject> iterator = paymentsFromSchId.iterator(); while (iterator.hasNext()) { JSONObject paymentFromSchId = (JSONObject) iterator.next(); Float f = Float.parseFloat("" + paymentFromSchId.get("amount")); int ramount = f.intValue(); JSONObject payment = new JSONObject(); payment.put("mem_id", paymentFromSchId.get("mem_id")); payment.put("s_id", paymentFromSchId.get("s_id")); payment.put("pay_date", paymentFromSchId.get("pay_date")); payment.put("amount", "" + ramount); payment.put("collector_id", paymentFromSchId.get("collector_id")); payment.put("created_by", paymentFromSchId.get("created_by")); joArray.addAll(payAmountAtEnd(db, payment)); } } db.commit(); } catch (Exception e) { db.rollback(); throw e; } return joArray; }
From source file:org.eclipse.wb.internal.swing.MigLayout.model.ui.DimensionResizeComposite.java
/** * Updates this field from {@link MigDimensionInfo}. */// w w w.j a va 2 s . com public void fromDimension(MigDimensionInfo dimension) { if (!m_updatingDimension) { m_dimension = dimension; try { // weight { String methodName = MessageFormat.format("get{0}", m_propertyName); Float weight = (Float) ReflectionUtils.invokeMethod2(m_dimension, methodName); if (weight == null || weight.intValue() == m_defaultWeight) { m_defaultWeightButton.setSelection(true); m_customWeightButton.setSelection(false); m_weightSpinner.setEnabled(false); m_weightSpinner.setSelection(0); } else { m_defaultWeightButton.setSelection(false); m_customWeightButton.setSelection(true); m_weightSpinner.setEnabled(true); m_weightSpinner.setSelection(weight.intValue()); } } // priority { String methodName = MessageFormat.format("get{0}Priority", m_propertyName); int priority = (Integer) ReflectionUtils.invokeMethod2(m_dimension, methodName); if (priority == 100) { m_defaultPriorityButton.setSelection(true); m_customPriorityButton.setSelection(false); m_prioritySpinner.setEnabled(false); } else { m_defaultPriorityButton.setSelection(false); m_customPriorityButton.setSelection(true); m_prioritySpinner.setEnabled(true); } m_prioritySpinner.setSelection(priority); } } catch (Throwable e) { } } }
From source file:com.salesmanager.core.module.impl.application.prices.OneTimePriceModule.java
public String getHtmlPriceFormated(String prefix, ProductPrice productPrice, Locale locale, String currency) { if (locale == null) locale = LocaleUtil.getDefaultLocale(); if (currency == null) currency = CurrencyUtil.getDefaultCurrency(); StringBuffer p = new StringBuffer(); p.append("<div class='product-price product-onetime-price'>"); if (!ProductUtil.hasDiscount(productPrice)) { p.append("<div class='product-price-price' style='width:50%;float:left;'>"); if (!StringUtils.isBlank(prefix)) { p.append("<div class='product-price-text'><strong>").append(prefix).append(" : </strong></div>"); }//www .j ava 2 s .c om p.append( CurrencyUtil.displayFormatedAmountWithCurrency(productPrice.getProductPriceAmount(), currency)); p.append(getPriceSuffixText(currency, locale)); p.append("</div>"); p.append("<div class='product-line'> </div>"); } else { double arith = productPrice.getSpecial().getProductPriceSpecialAmount().doubleValue() / productPrice.getProductPriceAmount().doubleValue(); double fsdiscount = 100 - arith * 100; Float percentagediscount = new Float(fsdiscount); String savediscount = String.valueOf(percentagediscount.intValue()); p.append("<div class='product-price-price' style='width:50%;float:left;'>"); if (!StringUtils.isBlank(prefix)) { p.append("<div class='product-price-text'><strong>").append(prefix).append(" : </strong></div>"); } p.append("<strike>") .append(CurrencyUtil.displayFormatedAmountWithCurrency(productPrice.getProductPriceAmount(), currency)) .append(getPriceSuffixText(currency, locale)).append("</strike>").append("</div>") .append("<div style='width:50%;float:right;'>").append("<font color='red'>") .append(CurrencyUtil.displayFormatedAmountWithCurrency(ProductUtil.determinePrice(productPrice), currency)) .append(getPriceSuffixText(currency, locale)).append("</font>").append("<br>") .append("<font color='red' style='font-size:75%;'>") .append(LabelUtil.getInstance().getText(locale, "label.generic.save")).append(" :") .append(savediscount) .append(LabelUtil.getInstance().getText(locale, "label.generic.percentsign")).append(" ") .append(LabelUtil.getInstance().getText(locale, "label.generic.off")).append("</font>"); Date discountEndDate = ProductUtil.getDiscountEndDate(productPrice); if (discountEndDate != null) { p.append("<br>").append(" <font style='font-size:65%;'>") .append(LabelUtil.getInstance().getText(locale, "label.generic.until")).append(" ") .append(DateUtil.formatDate(discountEndDate)).append("</font>"); } p.append("</div>"); } p.append("</div>"); return p.toString(); }
From source file:org.geppetto.simulator.jlems.JLEMSSimulatorService.java
/** * @param noZeros/*from w w w . j a v a 2 s. c o m*/ * @param unit * @return */ private Unit<?> getUnit(Float scaling, Unit<?> unit) { switch (scaling.intValue()) { case -12: return SI.PICO(unit); case -9: return SI.NANO(unit); case -6: return SI.MICRO(unit); case -3: return SI.MILLI(unit); case -2: return SI.CENTI(unit); case -1: return SI.DECI(unit); case 12: return SI.TERA(unit); case 6: return SI.MEGA(unit); case 3: return SI.KILO(unit); case 2: return SI.HECTO(unit); case 1: return unit; default: return unit.times(scaling); } }
From source file:com.salesmanager.core.module.impl.application.prices.MonthlyPriceModule.java
public String getHtmlPriceFormated(String prefix, ProductPrice productPrice, Locale locale, String currency) { if (locale == null) locale = LocaleUtil.getDefaultLocale(); if (currency == null) currency = CurrencyUtil.getDefaultCurrency(); StringBuffer p = new StringBuffer(); p.append("<div class='product-price product-monthly-price'>"); if (!ProductUtil.hasDiscount(productPrice)) { p.append("<div style='width:50%;float:left;'>"); if (!StringUtils.isBlank(prefix)) { p.append("<div class='product-price-text'><strong>").append(prefix).append(" : </strong></div>"); }// w w w. j a va2 s. co m p.append( CurrencyUtil.displayFormatedAmountWithCurrency(productPrice.getProductPriceAmount(), currency)); p.append(getPriceSuffixText(currency, locale)); p.append("</div>"); p.append("<div class='product-line'> </div>"); } else { double arith = productPrice.getSpecial().getProductPriceSpecialAmount().doubleValue() / productPrice.getProductPriceAmount().doubleValue(); double fsdiscount = 100 - arith * 100; Float percentagediscount = new Float(fsdiscount); String savediscount = String.valueOf(percentagediscount.intValue()); p.append("<div class='product-price product-monthly-price'>"); if (!StringUtils.isBlank(prefix)) { p.append("<div class='product-price-text'><strong>").append(prefix).append(" : </strong></div>"); } p.append("<strike>") .append(CurrencyUtil.displayFormatedAmountWithCurrency(productPrice.getProductPriceAmount(), currency)) .append(getPriceSuffixText(currency, locale)).append("</strike>").append("</div>") .append("<div style='width:50%;float:right;'>").append("<font color='red'>") .append(CurrencyUtil.displayFormatedAmountWithCurrency(ProductUtil.determinePrice(productPrice), currency)) .append(getPriceSuffixText(currency, locale)).append("</font>").append("<br>") .append("<font color='red' style='font-size:75%;'>") .append(LabelUtil.getInstance().getText(locale, "label.generic.save")).append(" :") .append(savediscount) .append(LabelUtil.getInstance().getText(locale, "label.generic.percentsign")).append(" ") .append(LabelUtil.getInstance().getText(locale, "label.generic.off")).append("</font>"); Date discountEndDate = ProductUtil.getDiscountEndDate(productPrice); if (discountEndDate != null) { p.append("<br>").append(" <font style='font-size:65%;'>") .append(LabelUtil.getInstance().getText(locale, "label.generic.until")).append(" ") .append(DateUtil.formatDate(discountEndDate)).append("</font>"); } p.append("</div>"); } p.append("</div>"); return p.toString(); }
From source file:org.apache.shindig.social.dataservice.integration.RestfulJsonPeopleTest.java
private void assertFloatField(JSONObject result, Float expected, Object field) throws JSONException { assertEquals(expected.intValue(), result.getInt(field.toString())); }
From source file:org.asqatasun.webapp.presentation.factory.AuditStatisticsFactory.java
/** * This methods converts the mark of the audit as a string * * @param webresource/*from w w w . ja va 2 s . c om*/ * @param isRawMark * @return */ private String markFormatter(WebResource webresource, boolean isRawMark, boolean isManual) { Float mark = statisticsDataService.getMarkByWebResourceAndAudit(webresource, isRawMark, isManual); if (mark == -1) { return "0"; } return String.valueOf(mark.intValue()); }
From source file:gov.nih.nci.cabig.caaers.web.ae.ListAdverseEventsController.java
protected void processPaginationSubmission(HttpServletRequest request, ListAdverseEventsCommand command, ModelAndView modelAndView) {//w w w. ja v a 2 s . c o m String action = (String) findInRequest(request, PAGINATION_ACTION); String numberOfResultsPerPage = (String) findInRequest(request, "numberOfResultsPerPage"); int numPerPage = 10; if (numberOfResultsPerPage != null) { numPerPage = Integer.parseInt(numberOfResultsPerPage); } Integer currPageNumber = (Integer) request.getSession().getAttribute(CURRENT_PAGE_NUMBER); if (currPageNumber == null) currPageNumber = 1; Integer newPageNumber = 0; if (action == null) { //do nothing. } else if (action.equals("nextPage")) { newPageNumber = ++currPageNumber; } else if (action.equals("prevPage")) { newPageNumber = --currPageNumber; } else if (action.equals("lastPage")) { Float newPageNumberFloat = command.getTotalResultsCount() / Float.parseFloat(numberOfResultsPerPage); newPageNumber = newPageNumberFloat.intValue(); if (command.getTotalResultsCount() % Integer.parseInt(numberOfResultsPerPage) > 0) newPageNumber++; } else if (action.equals("firstPage") || action.equals("numberOfResultsPerPage")) { newPageNumber = 1; } Integer startIndex = (newPageNumber - 1) * numPerPage; Integer endIndex = newPageNumber * numPerPage - 1; if (endIndex > command.getTotalResultsCount()) endIndex = command.getTotalResultsCount() - 1; filterResultMap(command, startIndex, endIndex); request.getSession().setAttribute(CURRENT_PAGE_NUMBER, newPageNumber); modelAndView.getModel().put("totalResults", command.getTotalResultsCount()); modelAndView.getModel().put("startIndex", startIndex + 1); modelAndView.getModel().put("endIndex", endIndex + 1); }
From source file:plugin.exporttokens.SkillSitToken.java
/** * Evaluate the property for the supplied skill and character. For * properties such as ACP and the extended UNTRAINED property, the * property text is required to be further parsed to pull out user * defined text to be output in each case. * * @param skillSit The skill to be reported upon. * @param property The property to be reported. * @param propertyText The original text of the property. * @param pc The character to be reported upon. * @return The value of the property.// w w w. j ava 2 s.c o m */ private String getSkillPropValue(Object skillSit, int property, String propertyText, PlayerCharacter pc) { StringBuilder retValue = new StringBuilder(); if (((property == SkillToken.SKILL_ABMOD) || (property == SkillToken.SKILL_MISC)) && false) //&& aSkill.get(ObjectKey.KEY_STAT) == null) { retValue.append("n/a"); } else { Skill skill; boolean isSituation; String situation; SkillSituation sit; if (skillSit instanceof Skill) { sit = null; skill = (Skill) skillSit; isSituation = false; situation = ""; } else if (skillSit instanceof SkillSituation) { sit = (SkillSituation) skillSit; skill = sit.getSkill(); isSituation = true; situation = sit.getSituation(); } else { Logging.errorPrint("Internal Error: unexpected type: " + skillSit.getClass()); return ""; } switch (property) { case SkillToken.SKILL_NAME: String name = QualifiedName.qualifiedName(pc, skill); if (isSituation) { name += " (" + situation + ')'; } retValue.append(name); break; case SkillToken.SKILL_TOTAL: int rank = SkillRankControl.getTotalRank(pc, skill).intValue() + SkillModifier.modifier(skill, pc).intValue(); if (isSituation) { rank += sit.getSituationBonus(); } if (SettingsHandler.getGame().hasSkillRankDisplayText()) { retValue.append(SettingsHandler.getGame().getSkillRankDisplayText(rank)); } else { retValue.append(Integer.toString(rank)); } break; case SkillToken.SKILL_RANK: Float sRank = SkillRankControl.getTotalRank(pc, skill); if (SettingsHandler.getGame().hasSkillRankDisplayText()) { retValue.append(SettingsHandler.getGame().getSkillRankDisplayText(sRank.intValue())); } else { retValue.append(SkillRankControl.getTotalRank(pc, skill).toString()); } break; case SkillToken.SKILL_MOD: int mod = SkillModifier.modifier(skill, pc).intValue(); if (isSituation) { mod += sit.getSituationBonus(); } retValue.append(Integer.toString(mod)); break; case SkillToken.SKILL_ABILITY: retValue.append(SkillInfoUtilities.getKeyStatFromStats(pc, skill)); break; case SkillToken.SKILL_ABMOD: retValue.append(Integer.toString(SkillModifier.getStatMod(skill, pc))); break; case SkillToken.SKILL_MISC: int misc = SkillModifier.modifier(skill, pc).intValue(); if (isSituation) { misc += sit.getSituationBonus(); } misc -= SkillModifier.getStatMod(skill, pc); retValue.append(Integer.toString(misc)); break; case SkillToken.SKILL_UNTRAINED: retValue.append(skill.getSafe(ObjectKey.USE_UNTRAINED) ? "Y" : "NO"); break; case SkillToken.SKILL_EXCLUSIVE: retValue.append(skill.getSafe(ObjectKey.EXCLUSIVE) ? "Y" : "N"); break; case SkillToken.SKILL_UNTRAINED_EXTENDED: retValue.append(SkillToken.getUntrainedOutput(skill, propertyText)); break; case SkillToken.SKILL_ACP: retValue.append(SkillToken.getAcpOutput(skill, propertyText)); break; case SkillToken.SKILL_COST: SkillCost cost = null; for (PCClass pcc : pc.getDisplay().getClassSet()) { if (cost == null) { cost = pc.getSkillCostForClass(skill, pcc); } else { SkillCost newCost = pc.getSkillCostForClass(skill, pcc); if (SkillCost.CLASS.equals(newCost) || SkillCost.EXCLUSIVE.equals(cost)) { cost = newCost; } } if (SkillCost.CLASS.equals(cost)) { break; } } retValue.append(cost.toString()); break; case SkillToken.SKILL_EXCLUSIVE_TOTAL: int etRank = SkillRankControl.getTotalRank(pc, skill).intValue(); boolean b = (skill.getSafe(ObjectKey.EXCLUSIVE) || !skill.getSafe(ObjectKey.USE_UNTRAINED)) && (etRank == 0); if (b) { retValue.append('0'); } else { int mRank = etRank + SkillModifier.modifier(skill, pc).intValue(); if (isSituation) { mRank += sit.getSituationBonus(); } retValue.append(Integer.toString(mRank)); } break; case SkillToken.SKILL_TRAINED_TOTAL: int tRank = SkillRankControl.getTotalRank(pc, skill).intValue(); boolean isNotTrained = !skill.getSafe(ObjectKey.USE_UNTRAINED) && (tRank == 0); if (isNotTrained) { retValue.append('0'); } else { int mRank = tRank + SkillModifier.modifier(skill, pc).intValue(); if (isSituation) { mRank += sit.getSituationBonus(); } retValue.append(Integer.toString(mRank)); } break; case SkillToken.SKILL_EXPLANATION: boolean shortFrom = !("_LONG".equals(propertyText.substring(7))); String bonusDetails = SkillCostDisplay.getModifierExplanation(skill, pc, shortFrom); if (isSituation) { String sitDetails = SkillCostDisplay.getSituationModifierExplanation(skill, situation, pc, shortFrom); retValue.append(bonusDetails + " situational: " + sitDetails); } else { retValue.append(bonusDetails); } break; case SkillToken.SKILL_TYPE: String type = skill.getType(); retValue.append(type); break; case SkillToken.SKILL_SIZE: int i = (int) (pc.getSizeAdjustmentBonusTo("SKILL", skill.getKeyName())); if (isSituation) { i += pc.getSizeAdjustmentBonusTo("SITUATION", skill.getKeyName() + '=' + situation); } retValue.append(Integer.toString(i)); break; case SkillToken.SKILL_CLASSES: List<String> classes = new ArrayList<>(); for (PCClass aClass : pc.getClassList()) { if (pc.getSkillCostForClass(skill, aClass) == SkillCost.CLASS) { classes.add(aClass.getDisplayName()); } } retValue.append(StringUtils.join(classes, ".")); break; default: Logging.errorPrint( "In ExportHandler._writeSkillProperty the propIdvalue " + property + " is not handled."); break; } } return retValue.toString(); }