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:net.erdfelt.android.sdkfido.sdks.ApiLevel.java
@Override public int compareTo(ApiLevel o) { if ((o == null) || (StringUtils.isBlank(o.level)) || (!StringUtils.isNumeric(o.level))) { return -1; }/* w ww . j a v a2 s. c om*/ if ((StringUtils.isBlank(this.level) || (!StringUtils.isNumeric(this.level)))) { return 1; } int l1 = Integer.parseInt(this.level); int l2 = Integer.parseInt(o.level); return l2 - l1; }
From source file:fr.paris.lutece.plugins.mylutece.util.SecurityUtilsTest.java
public void testBuildResetConnectionLogUrl() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setRemoteAddr("127.0.0.1"); String strUrl = SecurityUtils.buildResetConnectionLogUrl(1, request); assertNotNull(strUrl);/* ww w . j a va 2s . co m*/ assertTrue(strUrl.contains("jsp/site/plugins/mylutece/DoResetConnectionLog.jsp")); Pattern pattern = Pattern.compile("[\\?&]([^=]+)=([^&]+)"); Matcher matcher = pattern.matcher(strUrl); int matchCount = 0; for (int i = 0; i < 4; i++) { assertTrue(matcher.find()); String strParamName = matcher.group(1); String strParamValue = matcher.group(2); if ("ip".equals(strParamName)) { assertEquals("127.0.0.1", strParamValue); matchCount++; } else if ("date_login".equals(strParamName)) { assertTrue(StringUtils.isNumeric(strParamValue)); matchCount++; } else if ("interval".equals(strParamName)) { assertEquals("1", strParamValue); matchCount++; } else if ("key".equals(strParamName)) { assertTrue(strParamValue.matches("[0-9a-f]{64}")); matchCount++; } } assertEquals(4, matchCount); }
From source file:com.dp2345.service.impl.CartServiceImpl.java
public Cart getCurrent() { RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes(); if (requestAttributes != null) { HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); Principal principal = (Principal) request.getSession().getAttribute(Member.PRINCIPAL_ATTRIBUTE_NAME); Member member = principal != null ? memberDao.find(principal.getId()) : null; if (member != null) { Cart cart = member.getCart(); if (cart != null) { if (!cart.hasExpired()) { if (!DateUtils.isSameDay(cart.getModifyDate(), new Date())) { cart.setModifyDate(new Date()); cartDao.merge(cart); }/*w w w .j a v a 2 s. co m*/ return cart; } else { cartDao.remove(cart); } } } else { String id = WebUtils.getCookie(request, Cart.ID_COOKIE_NAME); String key = WebUtils.getCookie(request, Cart.KEY_COOKIE_NAME); if (StringUtils.isNotEmpty(id) && StringUtils.isNumeric(id) && StringUtils.isNotEmpty(key)) { Cart cart = cartDao.find(Long.valueOf(id)); if (cart != null && cart.getMember() == null && StringUtils.equals(cart.getKey(), key)) { if (!cart.hasExpired()) { if (!DateUtils.isSameDay(cart.getModifyDate(), new Date())) { cart.setModifyDate(new Date()); cartDao.merge(cart); } return cart; } else { cartDao.remove(cart); } } } } } return null; }
From source file:com.urbancode.ud.client.UDRestClient.java
/** * Create an HTTP client configured with credentials and any proxy settings * from the environment.//from w w w.j a va 2s. c o m * * @param user The username to associate with the http client connection. * @param password The password of the username used to associate with the http client connection. * @param trustAllCerts Boolean to trust or deny all insecure certifications with the http client. * * @return DefaultHttpClient */ static public DefaultHttpClient createHttpClient(String user, String password, boolean trustAllCerts) { HttpClientBuilder builder = new HttpClientBuilder(); builder.setPreemptiveAuthentication(true); builder.setUsername(user); builder.setPassword(password); builder.setTrustAllCerts(trustAllCerts); if (!StringUtils.isEmpty(System.getenv("PROXY_HOST")) && StringUtils.isNumeric(System.getenv("PROXY_PORT"))) { log.debug("Configuring proxy settings."); builder.setProxyHost(System.getenv("PROXY_HOST")); builder.setProxyPort(Integer.valueOf(System.getenv("PROXY_PORT"))); } if (!StringUtils.isEmpty(System.getenv("PROXY_USERNAME")) && !StringUtils.isEmpty(System.getenv("PROXY_PASSWORD"))) { log.debug("Configuring proxy settings."); builder.setProxyUsername(System.getenv("PROXY_USERNAME")); builder.setProxyPassword(System.getenv("PROXY_PASSWORD")); } return builder.buildClient(); }
From source file:com.impetus.client.redis.RedisQueryInterpreter.java
void setMin(String field, Object fieldValue) { this.min = new HashMap<String, Double>(1); this.min.put(field, !StringUtils.isNumeric(fieldValue.toString()) ? Double.valueOf(PropertyAccessorHelper.getString(fieldValue).hashCode()) : Double.valueOf(fieldValue.toString())); }
From source file:com.alibaba.otter.node.etl.common.io.download.impl.aria2c.Aria2cDownload.java
protected void analyzeResult(Exec.Result result) { String[] results = StringUtils.split(result.getStdout(), SystemUtils.LINE_SEPARATOR); List<Aria2cStat> segmentStat = new ArrayList<Aria2cStat>(); int pos = 0;//from ww w .ja v a 2 s.c o m for (; pos < results.length; pos++) { if (true == results[pos].toLowerCase().startsWith("gid|stat")) { break; } } for (pos++; pos < results.length; pos++) { // ? // Download Results: // gid|stat|avg speed |path/URI // ===+====+===========+=========================================================== // 1| OK| 103.7KiB/s|./index.html // // Status Legend: // (OK):download completed. if (true == StringUtils.isNumeric(results[pos].substring(0, 1))) { // ????? String[] status = StringUtils.split(results[pos], " \t|"); if (status.length > 2) { if (StringUtils.equalsIgnoreCase(Aria2cStat.OK.name(), status[1])) { segmentStat.add(Aria2cStat.OK); } else if (StringUtils.equalsIgnoreCase(Aria2cStat.ERR.name(), status[1])) { segmentStat.add(Aria2cStat.ERR); } else if (StringUtils.equalsIgnoreCase(Aria2cStat.INPR.name(), status[1])) { segmentStat.add(Aria2cStat.INPR); } logger.warn(results[pos]); } else { logger.error("it seems aria2 changed it's status format: " + results[pos]); } } } int size = segmentStat.size(); int errCount = 0; int inprCount = 0; for (int i = 0; i < size; i++) { final Aria2cStat stat = segmentStat.get(i); if (Aria2cStat.ERR == stat) { errCount++; } else if (Aria2cStat.INPR == stat) { inprCount++; } } // ??? if (errCount == 0) { if (inprCount == 0) { // ? completed.set(true); } else { // ? paused.set(true); } } else { if (errCount == size) { // ? aborted.set(true); } else { // ?? paused.set(true); } } }
From source file:net.sourceforge.fenixedu.dataTransferObject.residenceManagement.ResidenceEventBean.java
public boolean getStatus() { if (StringUtils.isEmpty(userName) || !StringUtils.isNumeric(userName)) { statusMessage = "label.error.invalid.student.number"; return false; }/*from w w w. j a v a 2 s .c o m*/ Student student = Student.readStudentByNumber(Integer.valueOf(userName)); if (student == null || student.getPerson() == null) { statusMessage = "label.error.invalid.student.number"; return false; } setStudent(student); ResidenceYear year = ResidenceYear.getCurrentYear(); ResidenceManagementUnit unit = year.getUnit(); /* if (!roomValue.equals(unit.getCurrentSingleRoomValue()) && !roomValue.equals(unit.getCurrentDoubleRoomValue())) { statusMessage = "label.error.invalid.payment.amount"; return false; }*/ String socialSecurityNumber = student.getPerson().getSocialSecurityNumber(); if (socialSecurityNumber != null && !socialSecurityNumber.equalsIgnoreCase(fiscalNumber.trim())) { statusMessage = "label.error.invalid.fiscalNumber"; return false; } return true; }
From source file:hydrograph.ui.propertywindow.widgets.listeners.JoinInputCountFocusOutListener.java
@Override public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers, Widget... widgets) {/*from ww w . ja va 2 s . c o m*/ final Widget[] widgetList = widgets; if (helpers != null) { if (helpers.get(HelperType.MINIMUM_PORT_COUNT) != null) { minimunPortCount = Integer.valueOf((String) helpers.get(HelperType.MINIMUM_PORT_COUNT)); } currentComponent = (Component) helpers.get(HelperType.CURRENT_COMPONENT); } Listener listener = new Listener() { @Override public void handleEvent(Event event) { if (event.type == SWT.FocusOut) { Text textBox = (Text) widgetList[0]; String textBoxValue = ((Text) event.widget).getText(); if (StringUtils.isNotBlank(textBoxValue) && StringUtils.isNumeric(textBoxValue)) { if ((Integer.parseInt(textBoxValue) < minimunPortCount || Integer.parseInt(textBoxValue) > 25) && currentComponent.getProperties() .get(Constants.UNUSED_AND_INPUT_PORT_COUNT_PROPERTY) != null) { textBox.setText((String) currentComponent.getProperties() .get(Constants.UNUSED_AND_INPUT_PORT_COUNT_PROPERTY)); } } } } }; return listener; }
From source file:com.commerce4j.storefront.controllers.HomeController.java
/** * Welcome Action, welcomes new users to the store * * @param request//from w w w. j a va2 s.c om * @param response * @return */ public ModelAndView welcome(HttpServletRequest request, HttpServletResponse response) { // declare locales ModelAndView mav = home(request, response); // init locals String uid = request.getParameter("uid"); if (StringUtils.isNotEmpty(uid) && StringUtils.isNumeric(uid)) { Integer userId = new Integer(uid); UserDAO userDAO = (UserDAO) getBean("userDAO"); UserDTO userDTO = userDAO.findById(userId); mav.addObject("user", userDTO); } // return mav return mav; }
From source file:net.bible.service.readingplan.ReadingPlanDao.java
/** get a list of all days readings in a plan *//*from w w w. j a va 2s .co m*/ public List<OneDaysReadingsDto> getReadingList(String planName) { ReadingPlanInfoDto planInfo = getReadingPlanInfoDto(planName); Properties properties = getPlanProperties(planName); List<OneDaysReadingsDto> list = new ArrayList<OneDaysReadingsDto>(); for (Entry<Object, Object> entry : properties.entrySet()) { String key = (String) entry.getKey(); String value = (String) entry.getValue(); if (StringUtils.isNumeric(key)) { int day = Integer.parseInt(key); OneDaysReadingsDto daysReading = new OneDaysReadingsDto(day, value, planInfo); list.add(daysReading); } } Collections.sort(list); return list; }