List of usage examples for java.text NumberFormat parse
public Number parse(String source) throws ParseException
From source file:web.SavecontactController.java
/** * This method is called by the spring framework. The configuration * for this controller to be invoked is based on the pagetype and * is set in the urlMapping property in the spring config file. * * @param request the <code>HttpServletRequest</code> * @param response the <code>HttpServletResponse</code> * @throws ServletException//from w ww. j a v a2s. c om * @throws IOException * @return ModelAndView this instance is returned to spring */ public synchronized ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // *************************************************************************** // This is the only line of code you need to get all session info initialized! // Always be the first line before anything else is done. Add to each controller's // handlRequest method. Also remember to extend SessionObject. // *************************************************************************** try { ModelAndView m = super.handleRequest(request, response); } catch (Exception e) { return handleError("error in handleRequest"); } outOfSession(request, response); if (RegexStrUtil.isNull(login)) { return handleUserpageError("Login is null in SavecontactController."); } if (getDaoMapper() == null) { return handleError("DaoMapper is null, in SavecontactController." + login); } ContactDao contactDao = (ContactDao) getDaoMapper().getDao(DbConstants.CONTACT); if (contactDao == null) { return handleError("ContactDao is null, in SavecontactController." + login); } String contactId = request.getParameter(DbConstants.CONTACT_ID); if (RegexStrUtil.isNull(contactId)) { return handleError("contactId is null in savecontactController"); } if (contactId.length() > GlobalConst.contactIdSize) { return handleError("contactId.length > WebConstants.contactIdSize, SavecontactController"); } contactId = RegexStrUtil.goodNameStr(contactId); try { NumberFormat nf = NumberFormat.getInstance(); Number myNum = nf.parse(contactId); } catch (ParseException e) { return handleError("contactId has other than [0-9] characters, SavecontactController.", e); } String fname = request.getParameter(DbConstants.FIRST_NAME); if (!RegexStrUtil.isNull(fname)) { if (fname.length() > GlobalConst.firstNameSize) { fname = fname.substring(0, GlobalConst.firstNameSize); } fname = RegexStrUtil.goodNameStr(fname); } String lname = request.getParameter(DbConstants.LAST_NAME); if (!RegexStrUtil.isNull(lname)) { if (lname.length() > GlobalConst.lastNameSize) { lname = lname.substring(0, GlobalConst.lastNameSize); } lname = RegexStrUtil.goodNameStr(lname); } String mname = request.getParameter(DbConstants.MIDDLE_NAME); if (!RegexStrUtil.isNull(mname)) { if (mname.length() > GlobalConst.middleNameSize) { mname = mname.substring(0, GlobalConst.middleNameSize); } mname = RegexStrUtil.goodNameStr(mname); } String nickname = request.getParameter(DbConstants.NICKNAME); if (!RegexStrUtil.isNull(nickname)) { if (nickname.length() > GlobalConst.nickNameSize) { nickname = nickname.substring(0, GlobalConst.nickNameSize); } nickname = RegexStrUtil.goodText(nickname); } String byear = request.getParameter(DbConstants.BYEAR); if (!RegexStrUtil.isNull(byear) && (byear.length() > GlobalConst.yearSize)) { byear = byear.substring(0, GlobalConst.yearSize); } String bmonth = request.getParameter(DbConstants.BMONTH); if (!RegexStrUtil.isNull(bmonth) && (bmonth.length() > GlobalConst.monthSize)) { bmonth = bmonth.substring(0, GlobalConst.monthSize); } String bday = request.getParameter(DbConstants.BDAY); if (!RegexStrUtil.isNull(bday) && (bday.length() > GlobalConst.daySize)) { bday = bday.substring(0, GlobalConst.daySize); } if (RegexStrUtil.isNull(bday)) { bday = "01"; } String dob = byear + "-" + bmonth + "-" + bday; String email = request.getParameter(DbConstants.EMAIL); if (!RegexStrUtil.isNull(email)) { if (email.length() > GlobalConst.emailSize) { email = email.substring(0, GlobalConst.emailSize); } email = RegexStrUtil.goodText(email); } String designation = request.getParameter(DbConstants.DESIGNATION); if (!RegexStrUtil.isNull(designation)) { if (designation.length() > GlobalConst.designationSize) { designation = designation.substring(0, GlobalConst.designationSize); } designation = RegexStrUtil.goodText(designation); } String title = request.getParameter(DbConstants.TITLE); if (!RegexStrUtil.isNull(title)) { if (title.length() > GlobalConst.titleSize) { title = title.substring(0, GlobalConst.titleSize); } title = RegexStrUtil.goodText(title); } String industry = request.getParameter(DbConstants.INDUSTRY); if (!RegexStrUtil.isNull(industry)) { if (industry.length() > GlobalConst.industrySize) { industry = industry.substring(0, GlobalConst.industrySize); } industry = RegexStrUtil.goodText(industry); } String company = request.getParameter(DbConstants.COMPANY); if (!RegexStrUtil.isNull(company)) { if (company.length() > GlobalConst.companySize) { company = company.substring(0, GlobalConst.companySize); } company = RegexStrUtil.goodText(company); } String pwebsite = request.getParameter(DbConstants.PWEBSITE); if (!RegexStrUtil.isNull(pwebsite)) { if (pwebsite.length() > GlobalConst.pWebsiteSize) { pwebsite = pwebsite.substring(0, GlobalConst.pWebsiteSize); } pwebsite = RegexStrUtil.goodText(pwebsite); } String cwebsite = request.getParameter(DbConstants.CWEBSITE); if (!RegexStrUtil.isNull(cwebsite)) { if (cwebsite.length() > GlobalConst.cWebsiteSize) { cwebsite = cwebsite.substring(0, GlobalConst.cWebsiteSize); } cwebsite = RegexStrUtil.goodText(cwebsite); } String blogsite = request.getParameter(DbConstants.BLOGSITE); if (!RegexStrUtil.isNull(blogsite)) { if (blogsite.length() > GlobalConst.blogSiteSize) { blogsite = blogsite.substring(0, GlobalConst.blogSiteSize); } blogsite = RegexStrUtil.goodText(blogsite); } String city = request.getParameter(DbConstants.CITY); if (!RegexStrUtil.isNull(city)) { if (city.length() > GlobalConst.citySize) city = city.substring(0, GlobalConst.citySize); city = RegexStrUtil.goodText(city); } String state = request.getParameter(DbConstants.STATE); if (!RegexStrUtil.isNull(state)) { if (state.length() > GlobalConst.stateSize) state = state.substring(0, GlobalConst.stateSize); state = RegexStrUtil.goodText(state); } String zipcode = request.getParameter(DbConstants.ZIPCODE); if (!RegexStrUtil.isNull(zipcode)) { if (zipcode.length() > GlobalConst.zipcodeSize) { zipcode = zipcode.substring(0, GlobalConst.zipcodeSize); } zipcode = RegexStrUtil.goodText(zipcode); } String country = request.getParameter(DbConstants.COUNTRY); if (!RegexStrUtil.isNull(country)) { if (country.length() > GlobalConst.countrySize) { country = country.substring(0, GlobalConst.countrySize); } country = RegexStrUtil.goodText(country); } String desc = request.getParameter(DbConstants.DESCRIPTION); if (!RegexStrUtil.isNull(desc)) { if (desc.length() > GlobalConst.descriptionSize) { desc = desc.substring(0, GlobalConst.descriptionSize); } desc = RegexStrUtil.goodText(desc); } String bcity = request.getParameter(DbConstants.BCITY); if (!RegexStrUtil.isNull(bcity)) { if (bcity.length() > GlobalConst.bCitySize) { bcity = bcity.substring(0, GlobalConst.bCitySize); } bcity = RegexStrUtil.goodNameStr(city); } String bstate = request.getParameter(DbConstants.BSTATE); if (!RegexStrUtil.isNull(bstate)) { if (bstate.length() > GlobalConst.bStateSize) { bstate = bstate.substring(0, GlobalConst.bStateSize); } bstate = RegexStrUtil.goodNameStr(bstate); } String bzipcode = request.getParameter(DbConstants.BZIPCODE); if (!RegexStrUtil.isNull(bzipcode)) { if (bzipcode.length() > GlobalConst.bZipcodeSize) { bzipcode = bzipcode.substring(0, GlobalConst.bZipcodeSize); } bzipcode = RegexStrUtil.goodText(bzipcode); } String bcountry = request.getParameter(DbConstants.BCOUNTRY); if (!RegexStrUtil.isNull(bcountry)) { if (bcountry.length() > GlobalConst.bCountrySize) { bcountry = bcountry.substring(0, GlobalConst.bCountrySize); } bcountry = RegexStrUtil.goodText(bcountry); } String hphone = request.getParameter(DbConstants.HPHONE); if (!RegexStrUtil.isNull(hphone)) { if (hphone.length() > GlobalConst.hPhoneSize) { hphone = hphone.substring(0, GlobalConst.hPhoneSize); } hphone = RegexStrUtil.goodText(hphone); } String cphone = request.getParameter(DbConstants.CPHONE); if (!RegexStrUtil.isNull(cphone)) { if (cphone.length() > GlobalConst.cPhoneSize) { cphone = cphone.substring(0, GlobalConst.cPhoneSize); } cphone = RegexStrUtil.goodText(cphone); } String bphone = request.getParameter(DbConstants.BPHONE); if (!RegexStrUtil.isNull(bphone)) { if (bphone.length() > GlobalConst.bPhoneSize) { bphone = bphone.substring(0, GlobalConst.bPhoneSize); } bphone = RegexStrUtil.goodText(bphone); } String netphone = request.getParameter(DbConstants.NETPHONE); if (!RegexStrUtil.isNull(netphone)) { if (netphone.length() > GlobalConst.netPhoneSize) { netphone = netphone.substring(0, GlobalConst.netPhoneSize); } netphone = RegexStrUtil.goodText(netphone); } String fax = request.getParameter(DbConstants.FAX); if (!RegexStrUtil.isNull(fax)) { if (fax.length() > GlobalConst.faxSize) { fax = fax.substring(0, GlobalConst.faxSize); } fax = RegexStrUtil.goodText(fax); } String yim = request.getParameter(DbConstants.YIM); if (!RegexStrUtil.isNull(yim)) { if (yim.length() > GlobalConst.yimSize) { yim = yim.substring(0, GlobalConst.yimSize); } yim = RegexStrUtil.goodText(yim); } String aim = request.getParameter(DbConstants.AIM); if (!RegexStrUtil.isNull(aim)) { if (aim.length() > GlobalConst.aimSize) { aim = aim.substring(0, GlobalConst.aimSize); } aim = RegexStrUtil.goodText(aim); } String msn = request.getParameter(DbConstants.MSN); if (!RegexStrUtil.isNull(msn)) { if (msn.length() > GlobalConst.msnSize) { msn = msn.substring(0, GlobalConst.msnSize); } msn = RegexStrUtil.goodText(msn); } String icq = request.getParameter(DbConstants.ICQ); if (!RegexStrUtil.isNull(icq)) { if (icq.length() > GlobalConst.icqSize) { icq = icq.substring(0, GlobalConst.icqSize); } icq = RegexStrUtil.goodText(icq); } String relation = request.getParameter(DbConstants.RELATION); if (!RegexStrUtil.isNull(relation)) { if (relation.length() > GlobalConst.relationSize) { relation = relation.substring(0, GlobalConst.relationSize); } relation = RegexStrUtil.goodText(relation); } String published = "0"; if ((!RegexStrUtil.isNull(request.getParameter(DbConstants.PUBLISHED))) && (request.getParameter(DbConstants.PUBLISHED).equalsIgnoreCase("on"))) { published = "1"; } String usertags = request.getParameter(DbConstants.USER_TAGS); if (!RegexStrUtil.isNull(usertags)) { if (usertags.length() > GlobalConst.usertagsSize) usertags = usertags.substring(0, GlobalConst.usertagsSize); usertags = RegexStrUtil.goodText(usertags); } String street = request.getParameter(DbConstants.STREET); if (!RegexStrUtil.isNull(street)) { if (street.length() > GlobalConst.streetSize) street = street.substring(0, GlobalConst.streetSize); street = RegexStrUtil.goodText(street); } String bstreet = request.getParameter(DbConstants.STREET); if (!RegexStrUtil.isNull(bstreet)) { if (bstreet.length() > GlobalConst.streetSize) bstreet = bstreet.substring(0, GlobalConst.streetSize); bstreet = RegexStrUtil.goodText(bstreet); } // default is male String mygender = "0"; if ((!RegexStrUtil.isNull(request.getParameter(DbConstants.GENDER))) && (request.getParameter(DbConstants.GENDER).equalsIgnoreCase(DbConstants.FEMALE))) { mygender = "1"; } List contacts = null; List allContacts = null; List sharedContacts = null; String alphabet = "a"; try { if (!RegexStrUtil.isNull(fname)) { alphabet = fname.substring(0, 1); } else { if (!RegexStrUtil.isNull(lname)) { alphabet = lname.substring(0, 1); } } contactDao.updateContact(contactId, loginInfo.getValue(DbConstants.LOGIN_ID), dob, title, industry, company, pwebsite, cwebsite, blogsite, city, state, country, desc, zipcode, fname, lname, mname, email, mygender, nickname, designation, bcity, bstate, bcountry, bzipcode, hphone, cphone, bphone, yim, aim, msn, icq, fax, netphone, relation, published, usertags, alphabet, street, bstreet); contacts = contactDao.getContacts(loginInfo.getValue(DbConstants.LOGIN_ID), DbConstants.READ_FROM_MASTER, alphabet, ""); allContacts = contactDao.getAllContacts(loginInfo.getValue(DbConstants.LOGIN_ID), DbConstants.READ_FROM_MASTER); sharedContacts = contactDao.getSharedContacts(loginInfo.getValue(DbConstants.LOGIN_ID)); } catch (BaseDaoException e) { return handleError( "Exception in updateContact/getAllContacts()/getContacts/getSharedContacts(), SavecontactController, for login " + login, e); } /** * cobrand */ Userpage cobrand = null; CobrandDao cobrandDao = (CobrandDao) getDaoMapper().getDao(DbConstants.COBRAND); if (cobrandDao == null) { return handleError("CobrandDao is null, SavecontactController"); } try { cobrand = cobrandDao.getUserCobrand(loginInfo.getValue(DbConstants.LOGIN_ID)); } catch (BaseDaoException e) { return handleError("cobrand is null, SavecontactController.", e); } String viewName = "showcontacts"; Map myModel = new HashMap(); /** * set this to published mode to zero because user cannot add contact in published mode */ myModel.put(DbConstants.PUBLISHED, "0"); myModel.put(DbConstants.COBRAND, cobrand); myModel.put(DbConstants.LOGIN_INFO, loginInfo); myModel.put(DbConstants.CONTACTS_ALPHABET, contacts); myModel.put(DbConstants.CONTACTS, allContacts); myModel.put(DbConstants.SHARED_CONTACTS, sharedContacts); myModel.put(DbConstants.ALPHABET, alphabet); myModel.put(DbConstants.DIR_EXISTS, rbDirectoryExists); myModel.put(DbConstants.USER_PAGE, userpage); myModel.put(DbConstants.SHARE_INFO, shareInfo); myModel.put(DbConstants.BUSINESS_EXISTS, isBizExists(login)); // myModel.put(DbConstants.VISITOR_PAGE, memberUserpage); return new ModelAndView(viewName, "model", myModel); }
From source file:org.sakaiproject.tool.gradebook.ui.AssignmentBean.java
/** * Used to check if all gradebook items are valid before saving. Due to the way JSF works, had to turn off * validators for bulk assignments so had to perform checks here. * This is an all-or-nothing save, ie, either all items are OK and we save them all, or return to add page * and highlight errors./*from w ww . jav a 2s.c o m*/ */ public String saveNewAssignment() { String resultString = "overview"; boolean saveAll = true; // keep list of new assignment names just in case // duplicates entered on screen List newAssignmentNameList = new ArrayList(); // used to hold assignments that are OK since we // need to determine if all are correct before saving List itemsToSave = new ArrayList(); Iterator assignIter = newBulkItems.iterator(); int i = 0; Map<String, Category> categoryCache = new HashMap<String, Category>(); while (i < numTotalItems && assignIter.hasNext()) { BulkAssignmentDecoratedBean bulkAssignDecoBean = (BulkAssignmentDecoratedBean) assignIter.next(); if (bulkAssignDecoBean.getBlnSaveThisItem()) { Assignment bulkAssignment = bulkAssignDecoBean.getAssignment(); // Check for blank entry else check if duplicate within items to be // added or with item currently in gradebook. if ("".equals(bulkAssignment.getName().toString().trim())) { bulkAssignDecoBean.setBulkNoTitleError("blank"); saveAll = false; resultString = "failure"; } else if (newAssignmentNameList.contains(bulkAssignment.getName().trim()) || !getGradebookManager().checkValidName(getGradebookId(), bulkAssignment)) { bulkAssignDecoBean.setBulkNoTitleError("dup"); saveAll = false; resultString = "failure"; } else { bulkAssignDecoBean.setBulkNoTitleError("OK"); newAssignmentNameList.add(bulkAssignment.getName().trim()); } Category selectedCategory; if (categoryCache.containsKey(bulkAssignDecoBean.getCategory())) { selectedCategory = categoryCache.get(bulkAssignDecoBean.getCategory()); } else { selectedCategory = retrieveSelectedCategory(bulkAssignDecoBean.getCategory(), true); categoryCache.put(bulkAssignDecoBean.getCategory(), selectedCategory); } boolean categoryDropsScores = false; if (selectedCategory != null && selectedCategory.isDropScores() && selectedCategory.getAssignmentList() != null && selectedCategory.getAssignmentList().size() > 0) { categoryDropsScores = true; if (!GB_ADJUSTMENT_ENTRY.equals(bulkAssignDecoBean.getSelectedGradeEntryValue())) { bulkAssignDecoBean.setPointsPossible(selectedCategory.getItemValue().toString()); // if category drops scores and is not adjustment, point value will come from the category level } } // Check if points possible is blank else convert to double. Exception at else point // means non-numeric value entered. if (bulkAssignDecoBean.getPointsPossible() == null || ("".equals(bulkAssignDecoBean.getPointsPossible().trim()))) { bulkAssignDecoBean.setBulkNoPointsError("blank"); saveAll = false; resultString = "failure"; } else { try { // Check if PointsPossible uses local number format String strPointsPossible = bulkAssignDecoBean.getPointsPossible(); NumberFormat nf = NumberFormat.getInstance(new ResourceLoader().getLocale()); double dblPointsPossible = new Double(nf.parse(strPointsPossible).doubleValue()); // Added per SAK-13459: did not validate if point value was valid (> zero) if (dblPointsPossible > 0) { // No more than 2 decimal places can be entered. BigDecimal bd = new BigDecimal(dblPointsPossible); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); // Two decimal places double roundedVal = bd.doubleValue(); double diff = dblPointsPossible - roundedVal; if (diff != 0) { saveAll = false; resultString = "failure"; bulkAssignDecoBean.setBulkNoPointsError("precision"); } else { bulkAssignDecoBean.setBulkNoPointsError("OK"); bulkAssignDecoBean.getAssignment() .setPointsPossible(new Double(bulkAssignDecoBean.getPointsPossible())); } } else { saveAll = false; resultString = "failure"; bulkAssignDecoBean.setBulkNoPointsError("invalid"); } } catch (Exception e) { bulkAssignDecoBean.setBulkNoPointsError("NaN"); saveAll = false; resultString = "failure"; } } if (saveAll) { bulkAssignDecoBean.getAssignment() .setCategory(retrieveSelectedCategory(bulkAssignDecoBean.getCategory(), false)); // if points possible is still 0 at this point, set it to null to avoid Division By Zero exceptions. These should never be allowed in the database. if (null != bulkAssignDecoBean.getAssignment().getPointsPossible() && bulkAssignDecoBean.getAssignment().getPointsPossible() == 0) bulkAssignDecoBean.getAssignment().setPointsPossible(null); itemsToSave.add(bulkAssignDecoBean.getAssignment()); } // Even if errors increment since we need to go back to add page i++; } } // Now ready to save, the only problem is due to duplicate names. if (saveAll) { try { getGradebookManager().createAssignments(getGradebookId(), itemsToSave); String authzLevel = (getGradebookBean().getAuthzService().isUserAbleToGradeAll(getGradebookUid())) ? "instructor" : "TA"; for (Iterator gbItemIter = itemsToSave.iterator(); gbItemIter.hasNext();) { String itemName = ((Assignment) gbItemIter.next()).getName(); FacesUtil.addRedirectSafeMessage( getLocalizedString("add_assignment_save", new String[] { itemName })); getGradebookBean().getEventTrackingService().postEvent("gradebook.newItem", "/gradebook/" + getGradebookId() + "/" + itemName + "/" + authzLevel); } } catch (MultipleAssignmentSavingException e) { FacesUtil.addErrorMessage(FacesUtil.getLocalizedString("validation_messages_present")); resultString = "failure"; } } else { // There are errors so need to put an error message at top FacesUtil.addErrorMessage(FacesUtil.getLocalizedString("validation_messages_present")); } return resultString; }
From source file:org.opentaps.common.util.UtilCommon.java
/** * Converts a localized number <code>String</code> to a <code>BigDecimal</code> using the given <code>Locale</code>, defaulting to the system <code>Locale</code>. * @param locale the <code>Locale</code> to use for parsing the number, optional, defaults to the system <code>Locale</code> * @param numberString a <code>String</code> to convert to a <code>BigDecimal</code> * @return the corresponding <code>BigDecimal</code> value * @throws ParseException if an occurs during parsing */// w ww .java2 s .c om public static BigDecimal parseLocalizedNumber(Locale locale, String numberString) throws ParseException { locale = UtilMisc.ensureLocale(locale); NumberFormat parser = NumberFormat.getNumberInstance(locale); Number n = parser.parse(numberString); return new BigDecimal(n.toString()); }
From source file:views.MetadataUploadView.java
protected void checkForNumberConsistency(String headline, DataTypeCode dType) { boolean consistent = true; boolean needsDelimiterChange = false; String moreInfo = "Not a number."; String barcode = ""; for (Object item : getActiveTable().getItemIds()) { int id = (int) item; if (id != -1) { String val = parseLabelCell(id, headline); if (!val.isEmpty()) { if (dType.equals(DataTypeCode.INTEGER)) { try { Integer.parseInt(val); } catch (NumberFormatException e) { consistent = false; }/*from w w w.j a v a2 s . c o m*/ } if (dType.equals(DataTypeCode.REAL)) { // try normal parse try { Double.parseDouble(val); } catch (NumberFormatException e) { // normal parse unsuccessful, check for different delimiter NumberFormat format = NumberFormat.getInstance(Locale.GERMANY); try { format.parse(val); // worked, needs different delimiter needsDelimiterChange = true; } catch (ParseException e1) { // didn't work, not a double value barcode = getBarcodeInRow(id); consistent = false; } } } } } } if (consistent) { if (needsDelimiterChange) createDelimiterChangeDialogue(headline); } else { createNotRightTypeDialogue(headline, moreInfo, barcode); } }
From source file:org.jboss.dashboard.displayer.chart.MeterChartDisplayerXMLFormat.java
protected void parseMeterProperties(DataDisplayer displayer, Node item, ImportResults results) throws Exception { Locale locale = LocaleManager.currentLocale(); NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); MeterChartDisplayer meterDisplayer = (MeterChartDisplayer) displayer; if (item.getNodeName().equals("meter") && item.hasChildNodes()) { NodeList meterNodes = item.getChildNodes(); for (int k = 0; k < meterNodes.getLength(); k++) { Node meterItem = meterNodes.item(k); if (meterItem.getNodeName().equals("positionType") && meterItem.hasChildNodes()) { meterDisplayer.setPositionType( StringEscapeUtils.unescapeXml(meterItem.getFirstChild().getNodeValue())); }//from w w w . jav a 2 s.co m if (meterItem.getNodeName().equals("minValue") && meterItem.hasChildNodes()) { meterDisplayer.setMinValue(numberFormat .parse(StringEscapeUtils.unescapeXml(meterItem.getFirstChild().getNodeValue())) .doubleValue()); } if (meterItem.getNodeName().equals("maxValue") && meterItem.hasChildNodes()) { meterDisplayer.setMaxValue(numberFormat .parse(StringEscapeUtils.unescapeXml(meterItem.getFirstChild().getNodeValue())) .doubleValue()); } if (meterItem.getNodeName().equals("maxMeterTicks") && meterItem.hasChildNodes()) { meterDisplayer.setMaxMeterTicks(numberFormat .parse(StringEscapeUtils.unescapeXml(meterItem.getFirstChild().getNodeValue())) .intValue()); } // Thresholds. if (meterItem.getNodeName().equals("warningThreshold") && meterItem.hasChildNodes()) { meterDisplayer.setWarningThreshold(numberFormat .parse(StringEscapeUtils.unescapeXml(meterItem.getFirstChild().getNodeValue())) .doubleValue()); } if (meterItem.getNodeName().equals("criticalThreshold") && meterItem.hasChildNodes()) { meterDisplayer.setCriticalThreshold(numberFormat .parse(StringEscapeUtils.unescapeXml(meterItem.getFirstChild().getNodeValue())) .doubleValue()); } // Critical interval. if (meterItem.getNodeName().equals("descripCriticalInterval") && meterItem.hasChildNodes()) { String descripCriticalInterval = meterItem.getFirstChild().getNodeValue(); Node languageNode = meterItem.getAttributes().getNamedItem("language"); if (languageNode != null) locale = new Locale(languageNode.getNodeValue()); meterDisplayer.setDescripCriticalInterval( StringEscapeUtils.unescapeXml(descripCriticalInterval), locale); } // Warning interval. if (meterItem.getNodeName().equals("descripWarningInterval") && meterItem.hasChildNodes()) { String descripWarningInterval = meterItem.getFirstChild().getNodeValue(); Node languageNode = meterItem.getAttributes().getNamedItem("language"); if (languageNode != null) locale = new Locale(languageNode.getNodeValue()); meterDisplayer.setDescripWarningInterval(StringEscapeUtils.unescapeXml(descripWarningInterval), locale); } // Normal interval. if (meterItem.getNodeName().equals("descripNormalInterval") && meterItem.hasChildNodes()) { String descripNormalInterval = meterItem.getFirstChild().getNodeValue(); Node languageNode = meterItem.getAttributes().getNamedItem("language"); if (languageNode != null) locale = new Locale(languageNode.getNodeValue()); meterDisplayer.setDescripNormalInterval(StringEscapeUtils.unescapeXml(descripNormalInterval), locale); } } } else if (item.getNodeName().equals("thermometer") && item.hasChildNodes()) { NodeList thermoNodes = item.getChildNodes(); for (int k = 0; k < thermoNodes.getLength(); k++) { Node thermoItem = thermoNodes.item(k); if (thermoItem.getNodeName().equals("positionType") && thermoItem.hasChildNodes()) { meterDisplayer.setPositionType( StringEscapeUtils.unescapeXml(thermoItem.getFirstChild().getNodeValue())); } if (thermoItem.getNodeName().equals("thermoLowerBound") && thermoItem.hasChildNodes()) { meterDisplayer.setThermoLowerBound(numberFormat .parse(StringEscapeUtils.unescapeXml(thermoItem.getFirstChild().getNodeValue())) .doubleValue()); } if (thermoItem.getNodeName().equals("thermoUpperBound") && thermoItem.hasChildNodes()) { meterDisplayer.setThermoUpperBound(numberFormat .parse(StringEscapeUtils.unescapeXml(thermoItem.getFirstChild().getNodeValue())) .doubleValue()); } // Thresholds. if (thermoItem.getNodeName().equals("warningThermoThreshold") && thermoItem.hasChildNodes()) { meterDisplayer.setWarningThermoThreshold(numberFormat .parse(StringEscapeUtils.unescapeXml(thermoItem.getFirstChild().getNodeValue())) .doubleValue()); } if (thermoItem.getNodeName().equals("criticalThermoThreshold") && thermoItem.hasChildNodes()) { meterDisplayer.setCriticalThermoThreshold(numberFormat .parse(StringEscapeUtils.unescapeXml(thermoItem.getFirstChild().getNodeValue())) .doubleValue()); } } } else if (item.getNodeName().equals("dial")) { NodeList dialNodes = item.getChildNodes(); for (int k = 0; k < dialNodes.getLength(); k++) { Node dialItem = dialNodes.item(k); if (dialItem.getNodeName().equals("positionType") && dialItem.hasChildNodes()) { meterDisplayer.setPositionType( StringEscapeUtils.unescapeXml(dialItem.getFirstChild().getNodeValue())); } if (dialItem.getNodeName().equals("pointerType") && dialItem.hasChildNodes()) { meterDisplayer .setPointerType(StringEscapeUtils.unescapeXml(dialItem.getFirstChild().getNodeValue())); } if (dialItem.getNodeName().equals("dialLowerBound") && dialItem.hasChildNodes()) { meterDisplayer.setDialLowerBound(numberFormat .parse(StringEscapeUtils.unescapeXml(dialItem.getFirstChild().getNodeValue())) .doubleValue()); } if (dialItem.getNodeName().equals("dialUpperBound") && dialItem.hasChildNodes()) { meterDisplayer.setDialUpperBound(numberFormat .parse(StringEscapeUtils.unescapeXml(dialItem.getFirstChild().getNodeValue())) .doubleValue()); } if (dialItem.getNodeName().equals("maxTicks") && dialItem.hasChildNodes()) { meterDisplayer.setMaxTicks(numberFormat .parse(StringEscapeUtils.unescapeXml(dialItem.getFirstChild().getNodeValue())) .intValue()); } if (dialItem.getNodeName().equals("minorTickCount") && dialItem.hasChildNodes()) { meterDisplayer.setMinorTickCount(numberFormat .parse(StringEscapeUtils.unescapeXml(dialItem.getFirstChild().getNodeValue())) .intValue()); } } } }
From source file:controllers.AnyplaceMapping.java
private static double calculateWeightOfConnection(String pois_a, String pois_b) throws DatasourceException { double lat_a = 0, lon_a = 0, lat_b = 0, lon_b = 0; NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH); JsonNode pa = ProxyDataSource.getIDatasource().getFromKeyAsJson(pois_a); if (pa == null) { lat_a = 0.0;//from w ww . j a v a2 s . co m lon_a = 0.0; } else { // everything is ok try { lat_a = nf.parse(pa.path("coordinates_lat").textValue()).doubleValue(); lon_a = nf.parse(pa.path("coordinates_lon").textValue()).doubleValue(); } catch (ParseException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } JsonNode pb = ProxyDataSource.getIDatasource().getFromKeyAsJson(pois_b); if (pb == null) { lat_b = 0.0; lon_b = 0.0; } else { // everything is ok try { lat_b = nf.parse(pb.path("coordinates_lat").textValue()).doubleValue(); lon_b = nf.parse(pb.path("coordinates_lon").textValue()).doubleValue(); } catch (ParseException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } return GeoPoint.getDistanceBetweenPoints(lat_a, lon_a, lat_b, lon_b, "K"); }
From source file:logic.Export.java
public boolean convertXls2() throws IOException, FileNotFoundException, IllegalArgumentException, ParseException { FileInputStream tamplateFile = new FileInputStream(templatePath); XSSFWorkbook workbook = new XSSFWorkbook(tamplateFile); CellStyle cellStyle = workbook.createCellStyle(); cellStyle.setDataFormat(workbook.getCreationHelper().createDataFormat().getFormat("#,##")); double hours = 0.0; NumberFormat format = NumberFormat.getInstance(Locale.FRANCE); Number number;/*w w w.ja v a 2 s . co m*/ XSSFSheet sheet; XSSFSheet sheet2; Cell cell = null; ConvertData cd = new ConvertData(); for (int i = 0; i < cd.getSheetnames().size(); i++) { sheet2 = workbook.cloneSheet(0, cd.sheetnames.get(i)); sheet = workbook.getSheetAt(i + 1); cell = sheet.getRow(0).getCell(1); cell.setCellValue(cd.sheetnames.get(i)); ArrayList<String[]> convert = cd.convert(cd.sheetnames.get(i)); for (int Row = 0; Row < convert.size(); Row++) { for (int Cell = 0; Cell < convert.get(Row).length; Cell++) { cell = sheet.getRow(9 + Row).getCell(Cell + 1); String name; switch (Cell) { case 3: name = convert.get(Row)[Cell]; int parseInt = Integer.parseInt(name); cell.setCellValue(parseInt); cell.setCellType(CellType.NUMERIC); break; case 4: number = format.parse(convert.get(Row)[Cell]); cell.setCellValue(number.doubleValue()); // cell.setCellStyle(cellStyle); cell.setCellType(CellType.NUMERIC); break; default: cell.setCellValue(convert.get(Row)[Cell]); break; } } } for (String[] sa : convert) { number = format.parse(sa[4]); hours = hours + number.doubleValue(); } cell = sheet.getRow(6).getCell(5); cell.setCellValue(hours); cell = sheet.getRow(2).getCell(8); XSSFCell cellHourlyRate = sheet.getRow(1).getCell(8); double numericCellValue = cellHourlyRate.getNumericCellValue(); cell.setCellValue(hours * numericCellValue); } workbook.removeSheetAt(0); tamplateFile.close(); File exportFile = newPath.getSelectedFile(); if (FilenameUtils.getExtension(exportFile.getName()).equalsIgnoreCase("xlsx")) { } else { exportFile = new File(exportFile.getParentFile(), FilenameUtils.getBaseName(exportFile.getName()) + ".xlsx"); } FileOutputStream outFile = new FileOutputStream(exportFile); workbook.write(outFile); outFile.close(); tamplateFile.close(); return true; }
From source file:com.glaf.core.jdbc.QueryHelper.java
/** * @param conn// ww w . j a v a 2s . c o m * ? * @param start * 0 * @param pageSize * ? * @param sql * ? * @param paramMap * ? * @return */ @SuppressWarnings("unchecked") public ResultModel getResultList(Connection conn, String sql, Map<String, Object> paramMap, int start, int pageSize) { if (!DBUtils.isLegalQuerySql(sql)) { throw new RuntimeException(" SQL statement illegal "); } ResultModel resultModel = new ResultModel(); boolean supportsPhysicalPage = false; PreparedStatement psmt = null; ResultSetMetaData rsmd = null; ResultSet rs = null; Dialect dialect = null; try { dialect = DBConfiguration.getDatabaseDialect(conn); if (dialect != null && dialect.supportsPhysicalPage()) { logger.debug("sql=" + sql); supportsPhysicalPage = dialect.supportsPhysicalPage(); sql = dialect.getLimitString(sql, start, pageSize); logger.debug(">>sql=" + sql); } List<Object> values = null; if (paramMap != null) { SqlExecutor sqlExecutor = DBUtils.replaceSQL(sql, paramMap); sql = sqlExecutor.getSql(); values = (List<Object>) sqlExecutor.getParameter(); } logger.debug("sql:\n" + sql); logger.debug("values:" + values); psmt = conn.prepareStatement(sql); if (values != null && !values.isEmpty()) { JdbcUtils.fillStatement(psmt, values); } List<ColumnDefinition> columns = new ArrayList<ColumnDefinition>(); rs = psmt.executeQuery(); rsmd = rs.getMetaData(); int count = rsmd.getColumnCount(); for (int i = 1; i <= count; i++) { int sqlType = rsmd.getColumnType(i); ColumnDefinition column = new ColumnDefinition(); column.setIndex(i); column.setColumnName(rsmd.getColumnName(i)); column.setColumnLabel(rsmd.getColumnLabel(i)); column.setJavaType(FieldType.getJavaType(sqlType)); column.setPrecision(rsmd.getPrecision(i)); column.setScale(rsmd.getScale(i)); if (column.getScale() == 0 && sqlType == Types.NUMERIC) { column.setJavaType("Long"); } column.setName(StringTools.lower(StringTools.camelStyle(column.getColumnLabel()))); columns.add(column); } resultModel.setHeaders(columns); if (!supportsPhysicalPage) { this.skipRows(rs, start); } int k = 0; while (rs.next() && k++ < pageSize) { int index = 0; RowModel rowModel = new RowModel(); Iterator<ColumnDefinition> iterator = columns.iterator(); while (iterator.hasNext()) { ColumnDefinition column = iterator.next(); ColumnDefinition c = new ColumnDefinition(); c.setColumnName(column.getColumnName()); c.setColumnLabel(column.getColumnLabel()); c.setName(column.getName()); c.setJavaType(column.getJavaType()); c.setPrecision(column.getPrecision()); c.setScale(column.getScale()); String javaType = column.getJavaType(); index = index + 1; if ("String".equals(javaType)) { String value = rs.getString(column.getIndex()); c.setValue(value); } else if ("Integer".equals(javaType)) { try { Integer value = rs.getInt(column.getIndex()); c.setValue(value); } catch (Exception e) { String str = rs.getString(column.getIndex()); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); c.setValue(num.intValue()); } } else if ("Long".equals(javaType)) { try { Long value = rs.getLong(column.getIndex()); c.setValue(value); } catch (Exception e) { String str = rs.getString(column.getIndex()); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); c.setValue(num.longValue()); } } else if ("Double".equals(javaType)) { try { Double value = rs.getDouble(column.getIndex()); c.setValue(value); } catch (Exception e) { String str = rs.getString(column.getIndex()); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); c.setValue(num.doubleValue()); } } else if ("Boolean".equals(javaType)) { Boolean value = rs.getBoolean(column.getIndex()); c.setValue(value); } else if ("Date".equals(javaType)) { Timestamp value = rs.getTimestamp(column.getIndex()); c.setValue(value); } else { c.setValue(rs.getObject(column.getIndex())); } rowModel.addColumn(c); } resultModel.addRow(rowModel); } } catch (Exception ex) { logger.error(ex); ex.printStackTrace(); throw new RuntimeException(ex); } finally { JdbcUtils.close(psmt); JdbcUtils.close(rs); } return resultModel; }
From source file:com.glaf.core.jdbc.QueryHelper.java
/** * @param conn// w ww . j av a 2 s . co m * ? * @param sqlExecutor * * @return */ @SuppressWarnings("unchecked") public List<Map<String, Object>> getResultList(Connection conn, SqlExecutor sqlExecutor) { if (!DBUtils.isLegalQuerySql(sqlExecutor.getSql())) { throw new RuntimeException(" SQL statement illegal "); } List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>(); PreparedStatement psmt = null; ResultSet rs = null; ResultSetMetaData rsmd = null; try { psmt = conn.prepareStatement(sqlExecutor.getSql()); if (sqlExecutor.getParameter() != null) { List<Object> values = (List<Object>) sqlExecutor.getParameter(); JdbcUtils.fillStatement(psmt, values); } rs = psmt.executeQuery(); if (conf.getBoolean("useMyBatisResultHandler", false)) { resultList = this.getResults(rs); } else { rsmd = rs.getMetaData(); int count = rsmd.getColumnCount(); List<ColumnDefinition> columns = new ArrayList<ColumnDefinition>(); for (int index = 1; index <= count; index++) { int sqlType = rsmd.getColumnType(index); ColumnDefinition column = new ColumnDefinition(); column.setIndex(index); column.setColumnName(rsmd.getColumnName(index)); column.setColumnLabel(rsmd.getColumnLabel(index)); column.setJavaType(FieldType.getJavaType(sqlType)); column.setPrecision(rsmd.getPrecision(index)); column.setScale(rsmd.getScale(index)); if (column.getScale() == 0 && sqlType == Types.NUMERIC) { column.setJavaType("Long"); } column.setName(StringTools.camelStyle(column.getColumnLabel().toLowerCase())); columns.add(column); } int startIndex = 1; while (rs.next() && startIndex <= 50000) { int index = 0; startIndex++; Map<String, Object> rowMap = new HashMap<String, Object>(); Iterator<ColumnDefinition> iterator = columns.iterator(); while (iterator.hasNext()) { ColumnDefinition column = iterator.next(); String columnLabel = column.getColumnLabel(); String columnName = column.getColumnName(); if (StringUtils.isEmpty(columnName)) { columnName = column.getColumnLabel(); } columnName = columnName.toLowerCase(); String javaType = column.getJavaType(); index = index + 1; if ("String".equals(javaType)) { String value = rs.getString(column.getIndex()); if (value != null) { value = value.trim(); rowMap.put(columnName, value); rowMap.put(columnLabel, value); } } else if ("Integer".equals(javaType)) { try { Integer value = rs.getInt(column.getIndex()); rowMap.put(columnName, value); rowMap.put(columnLabel, value); } catch (Exception e) { String str = rs.getString(column.getIndex()); logger.error("integer:" + str); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); rowMap.put(columnName, num.intValue()); rowMap.put(columnLabel, rowMap.get(columnName)); logger.debug("?:" + num.intValue()); } } else if ("Long".equals(javaType)) { try { Long value = rs.getLong(column.getIndex()); rowMap.put(columnName, value); rowMap.put(columnLabel, rowMap.get(columnName)); } catch (Exception e) { String str = rs.getString(column.getIndex()); logger.error("long:" + str); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); rowMap.put(columnName, num.longValue()); rowMap.put(columnLabel, num.longValue()); logger.debug("?:" + num.longValue()); } } else if ("Double".equals(javaType)) { try { Double d = rs.getDouble(column.getIndex()); rowMap.put(columnName, d); rowMap.put(columnLabel, d); } catch (Exception e) { String str = rs.getString(column.getIndex()); logger.error("double:" + str); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); rowMap.put(columnName, num.doubleValue()); rowMap.put(columnLabel, num.doubleValue()); logger.debug("?:" + num.doubleValue()); } } else if ("Boolean".equals(javaType)) { rowMap.put(columnName, rs.getBoolean(column.getIndex())); rowMap.put(columnLabel, rowMap.get(columnName)); } else if ("Date".equals(javaType)) { rowMap.put(columnName, rs.getTimestamp(column.getIndex())); rowMap.put(columnLabel, rowMap.get(columnName)); } else if ("Blob".equals(javaType)) { // ignore } else { Object value = rs.getObject(column.getIndex()); if (value != null) { if (value instanceof String) { value = (String) value.toString().trim(); } rowMap.put(columnName, value); rowMap.put(columnLabel, rowMap.get(columnName)); } } } rowMap.put("startIndex", startIndex); resultList.add(rowMap); } } logger.debug(">resultList size=" + resultList.size()); return resultList; } catch (Exception ex) { logger.error(ex); ex.printStackTrace(); throw new RuntimeException(ex); } finally { JdbcUtils.close(psmt); JdbcUtils.close(rs); } }
From source file:com.glaf.core.jdbc.QueryHelper.java
/** * @param conn/*from w ww. j a v a 2 s . c o m*/ * ? * @param sqlExecutor * ? * @param start * 0 * @param pageSize * ? * @return */ @SuppressWarnings("unchecked") public List<Map<String, Object>> getResultList(Connection conn, SqlExecutor sqlExecutor, int start, int pageSize) { if (!DBUtils.isLegalQuerySql(sqlExecutor.getSql())) { throw new RuntimeException(" SQL statement illegal "); } List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>(); String sql = sqlExecutor.getSql(); PreparedStatement psmt = null; ResultSet rs = null; ResultSetMetaData rsmd = null; boolean supportsPhysicalPage = false; try { Dialect dialect = DBConfiguration.getDatabaseDialect(conn); if (dialect != null && dialect.supportsPhysicalPage()) { supportsPhysicalPage = true; sql = dialect.getLimitString(sql, start, pageSize); logger.debug("sql=" + sqlExecutor.getSql()); logger.debug(">>sql=" + sql); } psmt = conn.prepareStatement(sql); if (sqlExecutor.getParameter() != null) { List<Object> values = (List<Object>) sqlExecutor.getParameter(); JdbcUtils.fillStatement(psmt, values); logger.debug(">>values=" + values); } rs = psmt.executeQuery(); if (conf.getBoolean("useMyBatisResultHandler", false)) { resultList = this.getResults(rs); } else { rsmd = rs.getMetaData(); int count = rsmd.getColumnCount(); List<ColumnDefinition> columns = new ArrayList<ColumnDefinition>(); for (int i = 1; i <= count; i++) { int sqlType = rsmd.getColumnType(i); ColumnDefinition column = new ColumnDefinition(); column.setIndex(i); column.setColumnName(rsmd.getColumnName(i)); column.setColumnLabel(rsmd.getColumnLabel(i)); column.setJavaType(FieldType.getJavaType(sqlType)); column.setPrecision(rsmd.getPrecision(i)); column.setScale(rsmd.getScale(i)); if (column.getScale() == 0 && sqlType == Types.NUMERIC) { column.setJavaType("Long"); } column.setName(StringTools.camelStyle(column.getColumnLabel().toLowerCase())); columns.add(column); } if (!supportsPhysicalPage) { logger.debug("---------------------skipRows:" + start); this.skipRows(rs, start, pageSize); } logger.debug("---------------------columns:" + columns.size()); logger.debug("---------------------start:" + start); logger.debug("---------------------pageSize:" + pageSize); // int index = 0; while (rs.next()) { // index++; // logger.debug("---------------------row index:" + index); Map<String, Object> rowMap = new HashMap<String, Object>(); Iterator<ColumnDefinition> iterator = columns.iterator(); while (iterator.hasNext()) { ColumnDefinition column = iterator.next(); String columnLabel = column.getColumnLabel(); String columnName = column.getColumnName(); if (StringUtils.isEmpty(columnName)) { columnName = column.getColumnLabel(); } columnName = columnName.toLowerCase(); String javaType = column.getJavaType(); if ("String".equals(javaType)) { String value = rs.getString(column.getIndex()); if (value != null) { value = value.trim(); rowMap.put(columnName, value); rowMap.put(columnLabel, rowMap.get(columnName)); } } else if ("Integer".equals(javaType)) { try { Integer value = rs.getInt(column.getIndex()); rowMap.put(columnName, value); rowMap.put(columnLabel, rowMap.get(columnName)); } catch (Exception e) { String str = rs.getString(column.getIndex()); logger.error("integer:" + str); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); rowMap.put(columnName, num.intValue()); rowMap.put(columnLabel, rowMap.get(columnName)); logger.debug("?:" + num.intValue()); } } else if ("Long".equals(javaType)) { try { Long value = rs.getLong(column.getIndex()); rowMap.put(columnName, value); rowMap.put(columnLabel, rowMap.get(columnName)); } catch (Exception e) { String str = rs.getString(column.getIndex()); logger.error("long:" + str); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); rowMap.put(columnName, num.longValue()); rowMap.put(columnLabel, rowMap.get(columnName)); logger.debug("?:" + num.longValue()); } } else if ("Double".equals(javaType)) { try { Double d = rs.getDouble(column.getIndex()); rowMap.put(columnName, d); rowMap.put(columnLabel, rowMap.get(columnName)); } catch (Exception e) { String str = rs.getString(column.getIndex()); logger.error("double:" + str); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); rowMap.put(columnName, num.doubleValue()); rowMap.put(columnLabel, rowMap.get(columnName)); logger.debug("?:" + num.doubleValue()); } } else if ("Boolean".equals(javaType)) { rowMap.put(columnName, rs.getBoolean(column.getIndex())); rowMap.put(columnLabel, rowMap.get(columnName)); } else if ("Date".equals(javaType)) { rowMap.put(columnName, rs.getTimestamp(column.getIndex())); rowMap.put(columnLabel, rowMap.get(columnName)); } else if ("Blob".equals(javaType)) { } else { Object value = rs.getObject(column.getIndex()); if (value != null) { if (value instanceof String) { value = (String) value.toString().trim(); } rowMap.put(columnName, value); rowMap.put(columnLabel, rowMap.get(columnName)); } } } resultList.add(rowMap); } } logger.debug(">resultList size = " + resultList.size()); return resultList; } catch (Exception ex) { logger.error(ex); ex.printStackTrace(); throw new RuntimeException(ex); } finally { JdbcUtils.close(psmt); JdbcUtils.close(rs); } }