List of usage examples for org.apache.commons.lang StringUtils isNumeric
public static boolean isNumeric(String str)
Checks if the String contains only unicode digits.
From source file:com.greenline.guahao.web.module.home.controllers.mobile.report.MobileReportController.java
/** * /* w ww . j av a 2 s .c o m*/ * * @param map * @return String */ @MethodRemark(value = "remark=,pageSize=,pageNo=?") @RequestMapping(value = "/mobile/b/get/report") public String searchMyReport(ModelMap map) { String mobile = request.getParameter("mobile"); String certNo = request.getParameter("certNo"); if (StringUtils.isBlank(mobile) || StringUtils.isBlank(certNo)) { Long cuserId = UserCookieUtil.getUserId(request);// ?cookieuserId UserDO userDO = userManager.findUserByUserId(cuserId); map.put("userDO", userDO); return "mobile/report/search_report"; } if (!StringUtils.isNumeric(StringUtils.trim(mobile))) { map.put("hasError", true); map.put("message", "?????"); UserDO userDO = new UserDO(); userDO.setMobile(mobile); userDO.setCertNo(certNo); map.put("userDO", userDO); return "mobile/report/search_report"; } if (!RegexUtil.isIdCard(StringUtils.trim(certNo))) { map.put("hasError", true); map.put("message", "???????"); UserDO userDO = new UserDO(); userDO.setMobile(mobile); userDO.setCertNo(certNo); map.put("userDO", userDO); return "mobile/report/search_report"; } // Calendar calendar = Calendar.getInstance(); // ? calendar.add(Calendar.DATE, 1); Date end = calendar.getTime(); // 1? calendar.add(Calendar.DAY_OF_MONTH, -30); Date start = calendar.getTime(); // ??id String hospitalId = "99574b7d-e93e-4c1a-a61a-536f0b04466f"; List<InspectionReportsDO> list = reportManager.listReport(hospitalId, StringUtils.trim(mobile), StringUtils.trim(certNo), start, end); map.put("reportList", list); map.put("certNO", certNo); map.put("mobile", mobile); return "mobile/report/report_list"; }
From source file:controller.HostelController.java
@RequestMapping(value = "/hostelLogin.do") public ModelAndView login(String id, String password, HttpServletRequest request, HttpServletResponse response) throws Exception { String result = ""; if (!(StringUtils.isNumeric(id)) || id == "") { result = "????"; return new ModelAndView("hostelLogin", "result", result); }//from w w w . j a va2s . c om Hostel hostel1 = hostelService.getHostel(Integer.parseInt(id)); if (hostel1 != null && hostel1.getPassword().equals(password) && hostel1.getApplication() == 1) { HttpSession session = request.getSession(); session.setAttribute("cardId", Integer.parseInt(id)); response.sendRedirect("/HostelWorld/hostelHome"); return null; } else if (hostel1 != null && hostel1.getApplication() == 0) { result = ",?"; return new ModelAndView("hostelLogin", "result", result); } else { result = "????"; return new ModelAndView("hostelLogin", "result", result); } }
From source file:cn.vlabs.duckling.vwb.ui.action.emailnotify.EmailSubscribeAdminAction.java
/** * show create jsp// ww w .j a v a 2 s .c om * * @param p_mapping * @param p_form * @param p_request * @param p_response * @return * @throws IOException */ public ActionForward execute(ActionMapping p_mapping, ActionForm p_form, HttpServletRequest p_request, HttpServletResponse p_response) throws IOException { Resource res = this.getSavedViewPort(p_request); VWBContext context = VWBContext.createContext(p_request, VWBCommand.ADMIN, res); if (context.hasAccess(p_response)) { ResourceBundle mr = context.getBundle("templates/default"); final DynaActionForm form = (DynaActionForm) p_form; String pageName = (String) form.get("pageName"); if (pageName == null) pageName = ""; else { p_request.setAttribute("pageName", pageName); } String creator = (String) form.get("creator"); if (creator == null) creator = ""; else { p_request.setAttribute("creator", creator); } String emails = (String) form.get("emails"); if (emails == null) emails = ""; else { p_request.setAttribute("emails", emails); } String shour = (String) form.get("hour"); int hour = -1; if (StringUtils.isBlank(shour)) shour = ""; else { if (StringUtils.isNumeric(shour)) { hour = Integer.parseInt(shour); p_request.setAttribute("hour", shour); } } EmailSubscriberService ess = VWBContext.getContainer().getEmailSubscriberService(); String errorinfo = ""; String delESubId = (String) form.get("deleteESubId"); if (!StringUtils.isBlank(delESubId)) { if (StringUtils.isNumeric(delESubId)) { ess.removeSubscribe(context.getSite().getId(), Integer.parseInt(delESubId)); } else { errorinfo += " " + mr.getString("emailnotifier.deldberror"); p_request.setAttribute("errorInfo", errorinfo); } } Collection<EmailSubscriber> eSubs = ess.findSubscribe(context.getSite().getId(), emails, pageName, hour); p_request.setAttribute("eMailSubscribers", eSubs); return doLayout(context); } else return null; }
From source file:com.ah.be.ls.stat.StatManager.java
public boolean isActived() { String prop = System.getProperty("data.mining.report.interval"); int interval = StringUtils.isNumeric(prop) ? Integer.parseInt(prop) : DEFAULT_REPORT_INTERVAL; return idelHours >= interval; }
From source file:fr.paris.lutece.plugins.unittree.modules.profiles.web.unit.ProfilesUnitUserAttributeComponent.java
/** * {@inheritDoc}/*from w w w. j a v a 2s . c o m*/ */ @Override public void fillModel(HttpServletRequest request, Map<String, Object> model) { List<IAttribute> listAttributes = AttributeService.getInstance() .getPluginAttributesWithFields(ProfilesPlugin.PLUGIN_NAME, request.getLocale()); String strIdUser = request.getParameter(PARAMETER_ID_USER); if (StringUtils.isNotBlank(strIdUser) && StringUtils.isNumeric(strIdUser) && (listAttributes != null) && !listAttributes.isEmpty()) { int nIdUser = Integer.parseInt(strIdUser); Map<String, Object> map = AdminUserFieldService.getAdminUserFields(listAttributes, nIdUser, request.getLocale()); model.put(MARK_MAP_LIST_ATTRIBUTE_DEFAULT_VALUES, map); } model.put(MARK_ATTRIBUTES_LIST, listAttributes); model.put(MARK_LOCALE, request.getLocale()); }
From source file:com.impetus.client.redis.RedisQueryInterpreter.java
void setMax(String field, Object fieldValue) { this.max = new HashMap<String, Double>(1); this.max.put(field, !StringUtils.isNumeric(fieldValue.toString()) ? Double.valueOf(PropertyAccessorHelper.getString(fieldValue).hashCode()) : Double.valueOf(fieldValue.toString())); }
From source file:edu.ku.brc.ui.ColorWrapper.java
/** * Parses a comma separated String and creates a color and sets it internally * @param rgbStr the string to be parsed ("100, 128, 45") */// w w w . j a v a 2 s .c om public Color setRGB(final String rgbStr) { if (rgbStr == null) { throw new IllegalArgumentException("ColorWrapper - The Color string is null!"); } String[] rgbVals = StringUtils.split(rgbStr, " ,"); if (rgbVals.length == 3) { // We could check for numeric here if (StringUtils.isNumeric(rgbVals[0]) && StringUtils.isNumeric(rgbVals[1]) && StringUtils.isNumeric(rgbVals[2])) { int r = Integer.parseInt(rgbVals[0]); int g = Integer.parseInt(rgbVals[1]); int b = Integer.parseInt(rgbVals[2]); setRGB(r, g, b); } else { setRGB(255, 255, 255); //throw new IllegalArgumentException("ColorWrapper - one of the values is not numeric r["+rgbVals[0]+"] g["+rgbVals[1]+"] b["+rgbVals[2]+"]"); log.error("ColorWrapper - one of the values is not numeric [" + rgbStr + "] r[" + rgbVals[0] + "] g[" + rgbVals[1] + "] b[" + rgbVals[2] + "]"); } } else if (StringUtils.isNotEmpty(rgbStr)) { throw new IllegalArgumentException("ColorWrapper - The Color string doesn't parse [" + rgbStr + "]"); } return color; }
From source file:com.bigdata.etl.util.DwUtil.java
public static void bulkInsert(String tableName, List<Map<String, String>> lst) { ResultSet rs = null;/* w ww . ja v a2 s . c o m*/ java.sql.Statement stmt = null; try (java.sql.Connection conn = DataSource.getConnection()) { stmt = conn.createStatement(); rs = stmt.executeQuery("select top 0 * from " + tableName); try (SQLServerBulkCopy bulk = new SQLServerBulkCopy(url + "user=" + user + ";password=" + password)) { SQLServerBulkCopyOptions sqlsbc = new SQLServerBulkCopyOptions(); sqlsbc.setBulkCopyTimeout(60 * 60 * 1000); bulk.setBulkCopyOptions(sqlsbc); bulk.setDestinationTableName(tableName); ResultSetMetaData rsmd = rs.getMetaData(); if (lst == null) { return; } // System.out.println(LocalTime.now() + " "+Thread.currentThread().getId()+" "+lst.size()); try (CachedRowSetImpl x = new CachedRowSetImpl()) { x.populate(rs); for (int k = 0; k < lst.size(); k++) { Map<String, String> map = lst.get(k); x.last(); x.moveToInsertRow(); for (int i = 1; i <= rsmd.getColumnCount(); i++) { String name = rsmd.getColumnName(i).toUpperCase(); int type = rsmd.getColumnType(i);//package java.sql.Type? try { switch (type) { case Types.VARCHAR: case Types.NVARCHAR: int len = rsmd.getColumnDisplaySize(i); String v = map.get(name); if (map.containsKey(name)) { x.updateString(i, v.length() > len ? v.substring(0, len) : v); } else { x.updateNull(i); } break; case Types.BIGINT: if (map.containsKey(name) && map.get(name).matches("\\d{1,}")) { x.updateLong(i, Long.valueOf(map.get(name))); } else { // x.updateLong(i, 0); x.updateNull(i); } break; case Types.FLOAT: if (map.containsKey(name) && map.get(name).matches("([+-]?)\\d*\\.\\d+$")) { x.updateFloat(i, Float.valueOf(map.get(name))); } else { x.updateNull(i); } break; case Types.DOUBLE: if (map.containsKey(name) && map.get(name).trim().length() > 0 && StringUtils.isNumeric(map.get(name))) { x.updateDouble(i, Double.valueOf(map.get(name))); } else { x.updateNull(i); } break; case Types.INTEGER: if (map.containsKey(name) && map.get(name).matches("\\d{1,}")) { x.updateInt(i, Integer.valueOf(map.get(name))); } else { x.updateNull(i); } break; default: throw new RuntimeException("? " + type); } /* if(map.containsKey("SYS_TELECOM")) System.err.println(map.get("SYS_TELECOM")); */ } catch (RuntimeException | SQLException e) { Logger.getLogger(DwUtil.class.getName()).log(Level.SEVERE, "? name=" + name + " v=" + map.get(name), e); } } x.insertRow(); x.moveToCurrentRow(); //x.acceptChanges(); } long start = System.currentTimeMillis(); bulk.writeToServer(x); long end = System.currentTimeMillis(); System.out.println(LocalTime.now() + " " + Thread.currentThread().getId() + " " + (end - start) + "ms" + " " + x.size()); } } } catch (SQLException e) { Logger.getLogger(DwUtil.class.getName()).log(Level.SEVERE, null, e); } finally { try { if (rs != null) { rs.close(); } if (stmt != null) { stmt.close(); } } catch (SQLException ex) { Logger.getLogger(DwUtil.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:br.com.nordestefomento.jrimum.vallia.digitoverificador.BoletoCodigoDeBarrasDV.java
/** * @see br.com.nordestefomento.jrimum.vallia.digitoverificador.AbstractDigitoVerificador#calcule(String) * @since 0.2/* ww w .jav a2 s. c o m*/ */ @Override public int calcule(String numero) throws IllegalArgumentException { int dv = 0; int resto = 0; if (StringUtils.isNotBlank(numero) && StringUtils.isNumeric(numero) && (numero.length() == TAMANHO_SEM_DV)) { // Realizando o clculo do dgito verificador utilizando mdulo 11. // Obtendo o resto da diviso por 11. resto = modulo11.calcule(numero); // Seguindo as especificaes da FEBRABAN, caso o resto seja // (0), (1) ou (10), ser atribudo (1) ao digito verificador. if ((resto == 0) || (resto == 1) || (resto == 10)) dv = 1; // Caso contrrio, dv = 11 - resto. else dv = modulo11.valor() - resto; } else { throw new IllegalArgumentException("O cdigo de barras " + "[ " + numero + " ] deve conter apenas nmeros e " + TAMANHO_SEM_DV + " caracteres."); } return dv; }
From source file:com.impetus.kundera.property.accessor.SQLDateAccessor.java
@Override public Date fromString(Class targetClass, String s) { if (s == null) { return null; }/* w w w . ja va 2s.co m*/ if (StringUtils.isNumeric(s)) { return new Date(Long.parseLong(s)); } Date d = Date.valueOf(s); return d; }