List of usage examples for org.apache.commons.lang3 StringUtils isNumeric
public static boolean isNumeric(final CharSequence cs)
Checks if the CharSequence contains only Unicode digits.
From source file:net.ceos.project.poi.annotated.core.CellFormulaConverter.java
/** * Calculate the range address based at template range address passed as * parameter and also the propagation type. * <p>// w w w . j a v a 2 s . c o m * Assuming we having 15 registry, start at 5 * <ul> * <li>(input) => D => (output) => D5:D20 * <li>(input) => D:F => (output) => D5:F20 * <li>(input) => 7 => (output) => E7:S7 * <li>(input) => 7:8 => (output) => E7:S8 * <li> * </ul> * * @param configCriteria * the {@link XConfigCriteria} * @param templateRangeAddress * the template range address * @return the range address calculated */ protected static String calculateRangeAddressFromTemplate(final XConfigCriteria configCriteria, String templateRangeAddress) throws ConfigurationException { String start = ""; String end = ""; /* remove all possible separators */ String rangeAddressWithoutSeparator = removeRangeSeparator(templateRangeAddress); /* validate propagation with template */ validatePropagationWithRangeAddress(configCriteria, rangeAddressWithoutSeparator); /* check if specific range group */ if (PredicateFactory.isReadyRangeAddress.test(rangeAddressWithoutSeparator)) { /* if true, return the range address */ return templateRangeAddress; } /* split by separator all possible separators */ String[] splitted = splitRangeSeparator(templateRangeAddress); if (splitted.length == 2) { /* range group */ start = transformToStartRange(configCriteria, splitted[0]); end = transformToEndRange(configCriteria, splitted[1]); } else if (splitted.length == 1) { /* dynamic list */ if (StringUtils.isNumeric(splitted[0])) { start = transformToRange(configCriteria, splitted[0], configCriteria.getStartCellInmutable()); end = transformToRange(configCriteria, splitted[0], configCriteria.getLastCellIndex()); } else if (StringUtils.isAlpha(splitted[0])) { start = transformToRange(configCriteria, splitted[0], configCriteria.getStartRowInmutable()); end = transformToRange(configCriteria, splitted[0], configCriteria.getSheet().getLastRowNum() + 1); } } return start + ":" + end; }
From source file:com.plabadie.mockmail.server.MockMailServer.java
private void initWithCommandLine(String[] args) { Option help = new Option("help", "print this message"); Option port = OptionBuilder.withArgName("portnumber").hasArg() .withDescription("Port number where mockmail serves smtp requests. Default : 2525.").create("port"); Option outdir = OptionBuilder.withArgName("path").hasArg().withDescription( "Folder where the email files will be stored. Can be relative to the working dir. Default : 'mail'") .create("outdir"); Options options = new Options(); options.addOption(help);/*from ww w. j ava 2s . c o m*/ options.addOption(port); options.addOption(outdir); // create the parser CommandLineParser parser = new GnuParser(); CommandLine line = null; try { // parse the command line arguments line = parser.parse(options, args); } catch (ParseException exp) { // oops, something went wrong System.err.println(exp.getMessage()); System.exit(1); } if (line.hasOption("help")) { // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar mockmail.jar", options); System.exit(0); } if (line.hasOption("port")) { String portStringValue = line.getOptionValue("port"); if (StringUtils.isNotBlank(portStringValue) && StringUtils.isNumeric(portStringValue)) { this.setPort(Integer.parseInt(portStringValue)); } } if (line.hasOption("outdir")) { String outDirStringValue = line.getOptionValue("outdir"); if (StringUtils.isNotBlank(outDirStringValue)) { this.setOutDirPath(outDirStringValue); } } }
From source file:com.bellman.bible.service.readingplan.ReadingPlanDao.java
/** * get last day number - there may be missed days so cannot simply do props.size() *///from w ww.j a v a 2s. co m public int getNumberOfPlanDays(String planCode) { int maxDayNo = 0; for (Object oDayNo : getPlanProperties(planCode).keySet()) { String dayNoStr = (String) oDayNo; if (StringUtils.isNumeric(dayNoStr)) { int dayNo = Integer.parseInt(dayNoStr); maxDayNo = Math.max(maxDayNo, dayNo); } else { if (!VERSIFICATION.equalsIgnoreCase(dayNoStr)) { Log.e(TAG, "Invalid day number:" + dayNoStr); } } } return maxDayNo; }
From source file:de.qaware.chronix.lucene.client.stream.date.DateQueryParser.java
/** * Converts the given date term into a numeric representation * * @param dateTerm the date term, e.g, start:NOW+30DAYS * @return the long representation of the date term * @throws ParseException if the date term could not be evaluated *///from www . j a va2 s .c om private long getNumberRepresentation(String dateTerm) throws ParseException { long numberRepresentation; if (StringUtils.isNumeric(dateTerm)) { numberRepresentation = Long.valueOf(dateTerm); } else if (solrDateMathPattern.matcher(dateTerm).matches()) { numberRepresentation = parseDateTerm(dateTerm); } else if (instantDatePattern.matcher(dateTerm).matches()) { numberRepresentation = Instant.parse(dateTerm).toEpochMilli(); } else { throw new ParseException("Could not parse date representation '" + dateTerm + "'", 0); } return numberRepresentation; }
From source file:com.jkoolcloud.tnt4j.streams.custom.kafka.interceptors.reporters.trace.TraceCommandDeserializer.java
/** * Parses trace command <tt>message</tt> and builds command instance handling topic messages tracing activity. * * @param message//ww w.j av a2 s .c om * command message to interpret * @return topic trace command built from message, or {@code null} if build fails * @throws Exception * if command message can't be parsed */ public static TopicTraceCommand interpret(String message) throws Exception { String args[] = message.split(" "); TopicTraceCommand command = null; for (int i = 0; i < args.length; i++) { String arg = args[i]; if (StringUtils.isEmpty(arg)) { continue; } if (arg.equalsIgnoreCase(TRACE)) { command = new TopicTraceCommand(); } if (arg.equalsIgnoreCase(OFF)) { command.active = false; } if (StringUtils.isNumeric(arg) && args[i + 1].equalsIgnoreCase(MESSAGES)) { command.count = Integer.parseInt(arg); } if (arg.equalsIgnoreCase(UNTIL)) { TimestampFormatter formatter = new TimestampFormatter(DATE_PATTERN, null, null); String dateTime = args[++i] + ' ' + args[++i]; UsecTimestamp timestamp = formatter.parse(dateTime); command.endAt = timestamp.getTimeMillis(); } if (arg.equalsIgnoreCase(BETWEEN)) { TimestampFormatter formatter = new TimestampFormatter(DATE_PATTERN, null, null); String dateTime = args[++i] + ' ' + args[++i]; UsecTimestamp begin = formatter.parse(dateTime); dateTime = args[++i] + ' ' + args[++i]; UsecTimestamp end = formatter.parse(dateTime); command.startFrom = begin.getTimeMillis(); command.endAt = end.getTimeMillis(); } if (arg.equalsIgnoreCase(TOPIC)) { command.topic = args[++i]; } } return command; }
From source file:ke.co.tawi.babblesms.server.servlet.admin.sms.Addcredit.java
/** * * @param request//from w w w .ja v a 2s . com * @param response * @throws ServletException, IOException */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { session = request.getSession(true); setClassParameters(request); // No source provided if (StringUtils.isBlank(sourceuuid)) { session.setAttribute(SessionConstants.ADMIN_ADD_CREDIT_ERROR_KEY, ERROR_INVALID_SOURCE); //amount is not provided } else if (StringUtils.isBlank(amount)) { session.setAttribute(SessionConstants.ADMIN_ADD_CREDIT_ERROR_KEY, ERROR_NO_AMOUNT); // Amount provided is not numeric value. } else if (!StringUtils.isNumeric(amount)) { session.setAttribute(SessionConstants.ADMIN_ADD_CREDIT_ERROR_KEY, ERROR_INVALID_AMOUNT); // No account provided } else if (StringUtils.isBlank(accountuuid)) { session.setAttribute(SessionConstants.ADMIN_ADD_CREDIT_ERROR_KEY, ERROR_NO_ACCOUNTNAME); } else { // If we get this far then all parameter checks are ok. session.setAttribute(SessionConstants.ADMIN_ADD_CREDIT_SUCCESS_KEY, "s"); // Reduce our session data session.setAttribute(SessionConstants.ADMIN_ADD_CREDIT_PARAMETERS, null); session.setAttribute(SessionConstants.ADMIN_ADD_CREDIT_ERROR_KEY, null); getSource(); //success message here session.setAttribute(SessionConstants.ADMIN_UPDATE_SUCCESS, "Credit added successfully."); } //err message and redirect url response.sendRedirect("admin/credit.jsp"); // session.setAttribute(SessionConstants.ADMIN_UPDATE_ERROR, "Credit update failed."); }
From source file:com.inkubator.hrm.service.impl.NotificationApproverSmsMessagesListener.java
@Override @Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, timeout = 50, rollbackFor = Exception.class) public void onMessage(Message message) { String approverNumber = StringUtils.EMPTY; String notifMessage = StringUtils.EMPTY; try {/* w w w . j a v a 2s . co m*/ TextMessage textMessage = (TextMessage) message; String json = textMessage.getText(); approverNumber = jsonConverter.getValueByKey(json, "senderNumber"); HrmUser approver = hrmUserDao.getEntityByPhoneNumber("+" + approverNumber); String content = jsonConverter.getValueByKey(json, "smsContent"); String[] arrContent = StringUtils.split(content, "#"); notifMessage = StringUtils.EMPTY; ApprovalActivity approvalActivity = StringUtils.isNumeric(arrContent[0]) ? approvalActivityDao.getEntiyByPK(Long.parseLong(arrContent[0])) : null; /** validation */ if (approver == null) { notifMessage = "Maaf, No Telepon tidak terdaftar "; } else if (arrContent.length != 3) { notifMessage = "Maaf, format tidak sesuai dengan standard : ApprovalActivityID#YES/NO/REVISI#COMMENT "; } else if (!(StringUtils.equalsIgnoreCase(arrContent[1], "YES") || StringUtils.equalsIgnoreCase(arrContent[1], "NO") || StringUtils.equalsIgnoreCase(arrContent[1], "REVISI"))) { notifMessage = "Maaf, format tidak sesuai dengan standard : ApprovalActivityID#YES/NO/REVISI#COMMENT "; } else if (!StringUtils.isNumeric(arrContent[0])) { notifMessage = "Maaf, Approval Activity ID tidak terdaftar"; } else if (approvalActivity == null) { notifMessage = "Maaf, approval activity ID tidak terdaftar"; } else if (!StringUtils.equals(approvalActivity.getApprovedBy(), approver.getUserId())) { notifMessage = "Maaf, No Telpon ini tidak berhak untuk melakukan approval"; } else if (approvalActivity.getApprovalStatus() != HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL) { notifMessage = "Maaf, permintaan tidak dapat di proses karena status Approval sudah berubah"; } /** proses approval, jika memenuhi validasi */ if (StringUtils.isEmpty(notifMessage)) { if (StringUtils.equalsIgnoreCase(arrContent[1], "YES")) { /** do Approved */ switch (approvalActivity.getApprovalDefinition().getName()) { case HRMConstant.BUSINESS_TRAVEL: businessTravelService.approved(approvalActivity.getId(), null, arrContent[2]); break; case HRMConstant.LOAN: loanNewApplicationService.approved(approvalActivity.getId(), null, arrContent[2]); break; case HRMConstant.REIMBURSEMENT: rmbsApplicationService.approved(approvalActivity.getId(), null, arrContent[2]); break; case HRMConstant.REIMBURSEMENT_DISBURSEMENT: rmbsDisbursementService.approved(approvalActivity.getId(), null, arrContent[2]); break; case HRMConstant.SHIFT_SCHEDULE: tempJadwalKaryawanService.approved(approvalActivity.getId(), null, arrContent[2]); break; case HRMConstant.LEAVE: leaveImplementationService.approved(approvalActivity.getId(), null, arrContent[2]); break; case HRMConstant.LEAVE_CANCELLATION: leaveImplementationService.approved(approvalActivity.getId(), null, arrContent[2]); break; case HRMConstant.ANNOUNCEMENT: announcementService.approved(approvalActivity.getId(), null, arrContent[2]); break; case HRMConstant.EMP_CORRECTION_ATTENDANCE: wtEmpCorrectionAttendanceService.approved(approvalActivity.getId(), null, arrContent[2]); break; case HRMConstant.VACANCY_ADVERTISEMENT: recruitVacancyAdvertisementService.approved(approvalActivity.getId(), null, arrContent[2]); break; case HRMConstant.EMPLOYEE_CAREER_TRANSITION: empCareerHistoryService.approved(approvalActivity.getId(), null, arrContent[2]); break; default: break; } notifMessage = "Terima kasih, permintaan untuk disetujui telah di proses"; } else if (StringUtils.equalsIgnoreCase(arrContent[1], "NO")) { /** do Rejected */ switch (approvalActivity.getApprovalDefinition().getName()) { case HRMConstant.BUSINESS_TRAVEL: businessTravelService.rejected(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.LOAN: loanNewApplicationService.rejected(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.REIMBURSEMENT: rmbsApplicationService.rejected(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.REIMBURSEMENT_DISBURSEMENT: rmbsDisbursementService.rejected(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.SHIFT_SCHEDULE: tempJadwalKaryawanService.rejected(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.LEAVE: leaveImplementationService.rejected(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.LEAVE_CANCELLATION: leaveImplementationService.rejected(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.ANNOUNCEMENT: announcementService.rejected(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.EMP_CORRECTION_ATTENDANCE: wtEmpCorrectionAttendanceService.rejected(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.VACANCY_ADVERTISEMENT: recruitVacancyAdvertisementService.rejected(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.EMPLOYEE_CAREER_TRANSITION: empCareerHistoryService.rejected(approvalActivity.getId(), arrContent[2]); break; default: break; } notifMessage = "Terima kasih, permintaan untuk ditolak telah di proses"; } else if (StringUtils.equalsIgnoreCase(arrContent[1], "REVISI")) { /** do Asking Revised */ switch (approvalActivity.getApprovalDefinition().getName()) { case HRMConstant.LOAN: loanNewApplicationService.askingRevised(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.REIMBURSEMENT: rmbsApplicationService.askingRevised(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.REIMBURSEMENT_DISBURSEMENT: rmbsDisbursementService.askingRevised(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.ANNOUNCEMENT: announcementService.askingRevised(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.EMP_CORRECTION_ATTENDANCE: wtEmpCorrectionAttendanceService.askingRevised(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.VACANCY_ADVERTISEMENT: recruitVacancyAdvertisementService.askingRevised(approvalActivity.getId(), arrContent[2]); break; case HRMConstant.EMPLOYEE_CAREER_TRANSITION: empCareerHistoryService.askingRevised(approvalActivity.getId(), arrContent[2]); break; default: /** Tidak semua module implement asking revised, jika belum/tidak implement maka kirim sms balik ke sender untuk notifikasi */ notifMessage = "Maaf, permintaan untuk \"REVISI\" tidak dapat diproses. Hanya bisa melakukan proses \"YES\" atau \"NO\""; break; } if (StringUtils.isEmpty(notifMessage)) { notifMessage = "Terima kasih, permintaan untuk direvisi telah di proses"; } } } } catch (Exception ex) { notifMessage = "Maaf, permintaan tidak dapat di proses, ada kegagalan di sistem. Mohon ulangi proses via aplikasi web atau hubungi Administrator"; LOGGER.error("Error", ex); } /** kirim sms balik ke sender untuk notifikasi messagenya */ final SMSSend mSSend = new SMSSend(); LOGGER.error("Info SMS " + notifMessage); mSSend.setFrom(HRMConstant.SYSTEM_ADMIN); mSSend.setDestination("+" + approverNumber); mSSend.setContent(notifMessage); //Send notificatin SMS this.jmsTemplateSMS.send(new MessageCreator() { @Override public Message createMessage(Session session) throws JMSException { return session.createTextMessage(jsonConverter.getJson(mSSend)); } }); }
From source file:mesclasses.controller.PageController.java
public void markAsInteger(TextField field) { field.textProperty().addListener((observable, oldValue, newValue) -> { if (StringUtils.isBlank(newValue)) { return; }/*w w w .j a v a 2 s. co m*/ if (!StringUtils.isNumeric(newValue.substring(newValue.length() - 1))) { field.setText(newValue.substring(0, newValue.length() - 1)); } }); }
From source file:com.moviejukebox.plugin.poster.MovieMeterPosterPlugin.java
@Override public IImage getPosterUrl(String id) { if (!StringUtils.isNumeric(id)) { return Image.UNKNOWN; }//w w w. j ava 2 s.c o m String posterURL = Movie.UNKNOWN; FilmInfo filmInfo; try { filmInfo = api.getFilm(NumberUtils.toInt(id)); if (filmInfo.getPosters() == null || filmInfo.getPosters().getLarge() == null) { LOG.debug("No MovieMeter Poster URL for movie: {}", id); } else { posterURL = filmInfo.getPosters().getLarge(); } } catch (MovieMeterException ex) { LOG.error("Failed retreiving MovieMeter Poster URL for movie: {}", id); LOG.error(SystemTools.getStackTrace(ex)); } if (StringTools.isValidString(posterURL)) { return new Image(posterURL); } return Image.UNKNOWN; }
From source file:com.emergya.persistenceGeo.web.RestTreeFolderController.java
/** * Returns the node types//from w w w. j a v a2 s. c o m * * @param parentType * The condition node type the returned nodes has to meet * * @return JSON file with success */ @RequestMapping(value = "/persistenceGeo/tree/getNodeTypes/{parentType}", produces = { MediaType.APPLICATION_JSON_VALUE }) public @ResponseBody List<FolderTypeDto> getNodeTypes(@PathVariable String parentType) { Map<String, Object> result = new HashMap<String, Object>(); List<FolderTypeDto> iptFolderTypes = new LinkedList<FolderTypeDto>(); try { Long parentId = null; if (parentType != null && StringUtils.isNumeric(parentType)) { parentId = Long.decode(parentType); } iptFolderTypes = foldersAdminService.getFolderTypes(parentId); } catch (Exception e) { LOG.error(e); result.put(SUCCESS, false); } return iptFolderTypes; }