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.nridge.ds.solr.SolrParentChild.java
private String extractLimit(String aValue) { String fetchLimit = FIELD_FETCH_LIMIT_DEFAULT; if (StringUtils.isNotEmpty(aValue)) { int offset1 = aValue.lastIndexOf("("); int offset2 = aValue.lastIndexOf(")"); if ((offset1 != -1) && (offset2 != -1)) { String countString = aValue.substring(offset1 + 1, offset2); if (StringUtils.contains(countString, StrUtl.CHAR_COMMA)) { ArrayList<String> offsetLimitList = StrUtl.expandToList(countString, StrUtl.CHAR_COMMA); if (offsetLimitList.size() > 1) { String limitValue = offsetLimitList.get(1); if (StringUtils.isNumeric(limitValue)) fetchLimit = limitValue; }/*from w ww . j a v a2 s . c o m*/ } else { if (StringUtils.isNumeric(countString)) fetchLimit = countString; } } } return fetchLimit; }
From source file:com.aimluck.eip.webmail.WebMailSelectData.java
/** * /*from w w w . jav a2 s. c om*/ * @param action * @param rundata * @param context */ @Override public void init(ALAction action, RunData rundata, Context context) throws ALPageNotFoundException, ALDBErrorException { String sort = ALEipUtils.getTemp(rundata, context, LIST_SORT_STR); if (sort == null || sort.equals("")) { ALEipUtils.setTemp(rundata, context, LIST_SORT_STR, ALEipUtils.getPortlet(rundata, context).getPortletConfig().getInitParameter("p2a-sort")); } orgId = Database.getDomainName(); userId = ALEipUtils.getUserId(rundata); user = (JetspeedUser) ((JetspeedRunData) rundata).getUser(); // ??? mailReceiveThreadStatus = ALEipUtils.getTemp(rundata, context, "start_recieve"); ALEipUtils.removeTemp(rundata, context, "start_recieve"); String tabParam = rundata.getParameters().getString("tab"); currentTab = ALEipUtils.getTemp(rundata, context, "tab"); if (tabParam == null && currentTab == null) { ALEipUtils.setTemp(rundata, context, "tab", WebMailUtils.TAB_RECEIVE); currentTab = WebMailUtils.TAB_RECEIVE; } else if (tabParam != null) { ALEipUtils.setTemp(rundata, context, "tab", tabParam); currentTab = tabParam; } // ??????????? if (ALEipUtils.isMatch(rundata, context)) { // ID if (rundata.getParameters().containsKey(WebMailUtils.ACCOUNT_ID)) { ALEipUtils.setTemp(rundata, context, WebMailUtils.ACCOUNT_ID, rundata.getParameters().getString(WebMailUtils.ACCOUNT_ID)); } // ID if (rundata.getParameters().containsKey(WebMailUtils.FOLDER_ID)) { ALEipUtils.setTemp(rundata, context, WebMailUtils.FOLDER_ID, rundata.getParameters().getString(WebMailUtils.FOLDER_ID)); } } else { String _accountId = ALEipUtils.getTemp(rundata, context, WebMailUtils.ACCOUNT_ID); if (StringUtils.isEmpty(_accountId) || !StringUtils.isNumeric(_accountId)) { ALEipUtils.setTemp(rundata, context, WebMailUtils.ACCOUNT_ID, ALEipUtils .getPortlet(rundata, context).getPortletConfig().getInitParameter("p3a-accounts")); } } try { accountId = Integer.parseInt(ALEipUtils.getTemp(rundata, context, WebMailUtils.ACCOUNT_ID)); } catch (Exception ignore) { accountId = 0; } try { folderId = Integer.parseInt(ALEipUtils.getTemp(rundata, context, WebMailUtils.FOLDER_ID)); } catch (Exception e) { folderId = 0; } // accountId????????????? if (!validateAccountId()) { accountId = 0; } // ID??????????????ID?? if (accountId == 0) { try { Expression exp = ExpressionFactory.matchExp(EipMMailAccount.USER_ID_PROPERTY, userId); SelectQuery<EipMMailAccount> query = Database.query(EipMMailAccount.class, exp); query.select(EipMMailAccount.ACCOUNT_ID_PK_COLUMN); List<EipMMailAccount> accounts = query.fetchList(); if (accounts != null && accounts.size() > 0) { EipMMailAccount account = accounts.get(0); accountId = account.getAccountId(); ALEipUtils.setTemp(rundata, context, WebMailUtils.ACCOUNT_ID, Integer.toString(accountId)); } else { // ???????? return; } } catch (Exception e) { } } // ? EipMMailAccount account = ALMailUtils.getMailAccount(userId, accountId); if (account == null) { action.addErrorMessage(ALLocalizationUtils.getl10nFormat("WEBMAIL_NO_ACCOUNT")); return; } // ???? EipTMailFolder mailFolder = WebMailUtils.getEipTMailFolder(account, String.valueOf(folderId)); // ??????????????????ID?? if (mailFolder == null) { folderId = account.getDefaultFolderId(); // ? ALEipUtils.setTemp(rundata, context, WebMailUtils.FOLDER_ID, String.valueOf(folderId)); // ?? mailFolder = WebMailUtils.getEipTMailFolder(account, String.valueOf(folderId)); } selectedFolder = new WebMailFolderResultData(mailFolder); // ? mailFolderList = WebMailUtils.getMailFolderAll(account); // ?????????? if (accountId > 0) { int type_mail = (WebMailUtils.TAB_RECEIVE.equals(currentTab)) ? ALFolder.TYPE_RECEIVE : ALFolder.TYPE_SEND; ALMailHandler handler = ALMailFactoryService.getInstance().getMailHandler(); folder = handler.getALFolder(type_mail, orgId, userId, Integer.valueOf(accountId)); folder.setRowsNum(super.getRowsNum()); } loadUnreadMailSumMap(rundata, context); super.init(action, rundata, context); // ???????? if ("date".equals(ALEipUtils.getTemp(rundata, context, LIST_SORT_STR))) { String sort_type = ALEipUtils.getTemp(rundata, context, LIST_SORT_TYPE_STR); if (sort_type == null || sort_type.equals("")) { ALEipUtils.setTemp(rundata, context, LIST_SORT_TYPE_STR, ALEipConstants.LIST_SORT_TYPE_DESC); } } }
From source file:com.p5solutions.core.utils.Comparison.java
/** * Checks if is numeric.//from w w w . j av a 2s. com * * @param value * the value * @return true, if is numeric */ public static boolean isNumeric(String value) { return StringUtils.isNumeric(value); }
From source file:com.hangum.tadpole.rdb.core.dialog.export.sqlresult.composite.ExportSQLComposite.java
@Override public ExportSqlDAO getLastData() { ExportSqlDAO dao = new ExportSqlDAO(); dao.setComboEncoding(this.comboEncoding.getText()); dao.setTargetName(this.textTargetName.getText()); List<String> listWhereColumnName = new ArrayList<>(); for (int i = 0; i < btnWhereColumn.length; i++) { Button button = btnWhereColumn[i]; if (button.getSelection()) listWhereColumnName.add(button.getText()); }/*from w w w. j a va2 s. c o m*/ dao.setListWhere(listWhereColumnName); if (StringUtils.isEmpty(this.textCommit.getText())) { dao.setCommit(0); } else if (!StringUtils.isNumeric(this.textCommit.getText())) { dao.setCommit(0); } else { dao.setCommit(Integer.valueOf(this.textCommit.getText().trim())); } if (this.btnBatchInsert.getSelection()) { dao.setStatementType("batch"); } else if (this.btnInsert.getSelection()) { dao.setStatementType("insert"); } else if (this.btnUpdate.getSelection()) { dao.setStatementType("update"); } else if (this.btnMerge.getSelection()) { dao.setStatementType("merge"); } return dao; }
From source file:com.hpe.application.automation.bamboo.tasks.RunFromFileSystemTaskConfigurator.java
public void validate(@NotNull final ActionParametersMap params, @NotNull final ErrorCollection errorCollection) { super.validate(params, errorCollection); final String pathParameter = params.getString(TESTS_PATH); final String timeoutParameter = params.getString(TIMEOUT); I18nBean textProvider = getI18nBean(); if (StringUtils.isEmpty(pathParameter)) { errorCollection.addError(TESTS_PATH, textProvider.getText("RunFromFileSystemTaskConfigurator.error.testsPathIsEmpty")); }// w w w . ja va 2 s .c o m if (!StringUtils.isEmpty(timeoutParameter)) { if (!StringUtils.isNumeric(timeoutParameter) || Integer.parseInt(timeoutParameter) < 0 | Integer.parseInt(timeoutParameter) > 30) { errorCollection.addError(TIMEOUT, textProvider.getText("RunFromFileSystemTaskConfigurator.error.timeoutIsNotCorrect")); } } }
From source file:fr.paris.lutece.plugins.appointment.modules.resource.web.workflow.SetAppointmentResourceTaskComponent.java
/** * {@inheritDoc}/* ww w . j a va2 s. c o m*/ */ @Override public String getDisplayConfigForm(HttpServletRequest request, Locale locale, ITask task) { Map<String, Object> model = new HashMap<String, Object>(); TaskSetAppointmentResourceConfig config = _taskSetAppointmentResourceConfigService .findByPrimaryKey(task.getId()); List<AppointmentForm> listAppointmentform = AppointmentFormHome.getAppointmentFormsList(); ReferenceList refListAppointmentForm = new ReferenceList(); for (AppointmentForm form : listAppointmentform) { refListAppointmentForm.addItem(form.getIdForm(), form.getTitle()); } String strIdAppointmentForm; // We get the only possible id appointment form if there is only one appointment form if (refListAppointmentForm.size() == 1) { strIdAppointmentForm = refListAppointmentForm.get(0).getCode(); } else { strIdAppointmentForm = request.getParameter(PARAMETER_ID_APPOINTMENT_FORM); if ((config != null) && (StringUtils.isEmpty(strIdAppointmentForm) || !StringUtils.isNumeric(strIdAppointmentForm))) { AppointmentFormResourceType formResourceType = AppointmentFormResourceTypeHome .findByPrimaryKey(config.getIdFormResourceType()); strIdAppointmentForm = Integer.toString(formResourceType.getIdAppointmentForm()); } } if (config != null) { model.put(PARAMETER_ID_FORM_RESOURCE_TYPE, Integer.toString(config.getIdFormResourceType())); model.put(PARAMETER_IS_MANDATORY, config.getIsMandatory()); } else { model.put(PARAMETER_IS_MANDATORY, true); } ReferenceList refListFormTypes = new ReferenceList(); if (StringUtils.isNotEmpty(strIdAppointmentForm) && StringUtils.isNumeric(strIdAppointmentForm)) { model.put(PARAMETER_ID_APPOINTMENT_FORM, strIdAppointmentForm); List<AppointmentFormResourceType> listFormResourceType = AppointmentFormResourceTypeHome .findResourceTypesListFromIdForm(Integer.parseInt(strIdAppointmentForm)); for (AppointmentFormResourceType formType : listFormResourceType) { refListFormTypes.addItem(formType.getId(), formType.getDescription()); } } model.put(MARK_REF_LIST_FORM_RESOURCE_TYPES, refListFormTypes); model.put(MARK_REF_LIST_APPOINTMENT_FORM, refListAppointmentForm); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_CONFIG_SET_APPOINTMENT_RESOURCE, locale, model); return template.getHtml(); }
From source file:de.ma.it.common.excel.ExcelFileManager.java
/** * //from w w w . j ava 2 s. co m * @param row * @param cellIdx * @return * @throws IllegalArgumentException */ public Double readCellAsDouble(HSSFRow row, int cellIdx) throws IllegalArgumentException { HSSFCell cell = getCell(row, cellIdx); if (cell == null) { return null; } int cellType = cell.getCellType(); // First evaluate formula if present if (cellType == HSSFCell.CELL_TYPE_FORMULA) { cellType = evaluator.evaluateFormulaCell(cell); } Double result; switch (cellType) { case HSSFCell.CELL_TYPE_NUMERIC: double numericCellValue = cell.getNumericCellValue(); result = Double.valueOf(numericCellValue); break; case HSSFCell.CELL_TYPE_STRING: String stringCellValue = cell.getStringCellValue(); if (!StringUtils.isNumeric(stringCellValue)) { throw new IllegalArgumentException("Value " + stringCellValue + " is not numeric!"); } result = Double.valueOf(stringCellValue); break; default: result = Double.MIN_VALUE; break; } return result; }
From source file:edu.ku.brc.specify.ui.db.AskForNumbersDlg.java
/** * @return// w w w.j av a 2 s.c o m */ protected boolean processNumbers() { dataObjsIds.clear(); numbersList.clear(); numErrorList.clear(); numMissingList.clear(); errorPanel.setNumbers(null); missingPanel.setNumbers(null); DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(dataClass.getName()); DBFieldInfo fi = ti.getFieldByName(fieldName); boolean hasColMemID = ti.getFieldByColumnName("CollectionMemberID", true) != null; UIFieldFormatterIFace formatter = fi.getFormatter(); // Check for a dash in the format char rangeSeparator = formatter != null ? formatter.hasDash() ? '/' : '-' : ' '; boolean isOK = true; String fieldStr = textArea.getText().trim(); if (formatter != null && formatter.isNumeric() && ti.getTableId() == 1 && fieldName.equals("catalogNumber")) { fieldStr = CatalogNumberFormatter.preParseNumericCatalogNumbers(fieldStr, formatter); } if (StringUtils.isNotEmpty(fieldStr)) { DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); String[] toks = StringUtils.split(fieldStr, ','); for (String fldStr : toks) { String numToken = fldStr.trim(); if (formatter != null && formatter.isNumeric() && StringUtils.contains(numToken, rangeSeparator)) { String fldNum = null; String endFldNum = null; String[] tokens = StringUtils.split(numToken, rangeSeparator); if (tokens.length == 2) { try { if (formatter.isNumeric()) { if (!StringUtils.isNumeric(fldNum) || !StringUtils.isNumeric(endFldNum)) { numErrorList.add(fldStr.trim()); isOK = false; continue; } } fldNum = (String) formatter.formatFromUI(tokens[0].trim()); endFldNum = (String) formatter.formatFromUI(tokens[1].trim()); } catch (java.lang.NumberFormatException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AskForNumbersDlg.class, ex); numErrorList.add(numToken); isOK = false; } String sql = String.format("SELECT id FROM %s WHERE %s >= '%s' AND %s <= '%s' %s", ti.getClassName(), fieldName, fldNum, fieldName, endFldNum, (hasColMemID ? AND_COLLID : "")); sql = QueryAdjusterForDomain.getInstance().adjustSQL(sql); List<?> list = session.getDataList(sql); for (Object obj : list) { dataObjsIds.add((Integer) obj); } numbersList.add(numToken); } else { numErrorList.add(numToken); isOK = false; } continue; } String fldValForDB = numToken; try { if (formatter != null) { if (formatter.isNumeric()) { if (!StringUtils.isNumeric(numToken)) { numErrorList.add(numToken); isOK = false; continue; } } fldValForDB = (String) formatter.formatFromUI(numToken); } else { fldValForDB = numToken; } } catch (java.lang.NumberFormatException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AskForNumbersDlg.class, ex); numErrorList.add(numToken); isOK = false; } if (StringUtils.isNotEmpty(fldValForDB)) { String sql = String.format("SELECT id FROM %s WHERE %s = '%s' %s", ti.getClassName(), fieldName, fldValForDB, (hasColMemID ? AND_COLLID : "")); sql = QueryAdjusterForDomain.getInstance().adjustSQL(sql); //log.debug(sql); Integer recordId = (Integer) session.getData(sql); if (recordId != null) { dataObjsIds.add(recordId); numbersList.add(numToken); } else { numMissingList.add(numToken); isOK = false; } } } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(AskForNumbersDlg.class, ex); log.error(ex); ex.printStackTrace(); } finally { if (session != null) { session.close(); } } } buildNumberList(numbersList, textArea); pb.getPanel().removeAll(); CellConstraints cc = new CellConstraints(); pb.addSeparator(UIRegistry.getResourceString(labelKey), cc.xy(1, 1)); pb.add(UIHelper.createScrollPane(textArea), cc.xy(1, 3)); int y = 5; if (numErrorList.size() > 0) { errorPanel.setNumbers(numErrorList); pb.add(UIHelper.createScrollPane(errorPanel), cc.xy(1, y)); y += 2; } if (numMissingList.size() > 0) { missingPanel.setNumbers(numMissingList); pb.add(UIHelper.createScrollPane(missingPanel), cc.xy(1, y)); y += 2; } if (numErrorList.isEmpty() && numMissingList.isEmpty() && dataObjsIds.isEmpty()) { UIRegistry.showLocalizedError("BT_NO_NUMS_ERROR"); return false; } if (!isOK) { pack(); } return isOK; }
From source file:com.haulmont.cuba.desktop.gui.components.SwingXTableSettings.java
protected void applyColumnSettings(Element element, boolean sortable) { final Element columnsElem = element.element("columns"); // do not allow duplicates Collection<Table.Column> sequence = new LinkedHashSet<>(); for (Element colElem : Dom4j.elements(columnsElem, "column")) { String id = colElem.attributeValue("id"); Table.Column column = getColumn(id); if (column != null) { sequence.add(column);//from w ww. j a v a 2 s . c o m TableColumnExt tableColumn = table.getColumnExt(column); if (tableColumn != null) { String width = colElem.attributeValue("width"); if (StringUtils.isNotEmpty(width)) { tableColumn.setPreferredWidth(Integer.parseInt(width)); } String visible = colElem.attributeValue("visible"); if (StringUtils.isNotEmpty(visible)) { tableColumn.setVisible(Boolean.valueOf(visible)); } } } } table.setColumnSequence(sequence.toArray(new Object[sequence.size()])); if (sortable && table.getRowSorter() != null) { String sortColumn = columnsElem.attributeValue("sortColumn"); if (sortColumn != null) { SortOrder sortOrder = SortOrder.valueOf(columnsElem.attributeValue("sortOrder")); int sortColumnIndex = -1; if (!StringUtils.isNumeric(sortColumn)) { Table.Column column = getColumn(sortColumn); if (column != null) { sortColumnIndex = columns.indexOf(column); } } else { // backward compatibility sortColumnIndex = Integer.parseInt(sortColumn); } if (sortColumnIndex >= 0) { table.getRowSorter().setSortKeys( Collections.singletonList(new RowSorter.SortKey(sortColumnIndex, sortOrder))); } } else { table.getRowSorter().setSortKeys(null); } } table.revalidate(); table.repaint(); }
From source file:com.aimluck.eip.project.ProjectTaskFormData.java
/** * ?//from w w w .j av a 2 s .c om * * @param action * ALAction * @param rundata * RunData * @param context * Context */ @Override public void init(ALAction action, RunData rundata, Context context) throws ALPageNotFoundException, ALDBErrorException { super.init(action, rundata, context); rundata.getUser().setTemp(ALEipConstants.MYGROUP, null); try { parentTaskId = Integer.valueOf(rundata.getParameters().getString("parent_task_id")); } catch (NumberFormatException e) { parentTaskId = null; } String _projectId = ALEipUtils.getParameter(rundata, context, "projectid"); if (StringUtils.isNotEmpty(_projectId) && StringUtils.isNumeric(_projectId)) { projectId = Integer.valueOf((_projectId)); } else { projectId = 0; } project = ProjectUtils.getEipTProject(projectId); loginUser = ALEipUtils.getALEipUser(rundata); folderName = rundata.getParameters().getString("folderName"); uid = ALEipUtils.getUserId(rundata); projectMembers = ProjectUtils.getProjectMembers(projectId); allProject = ProjectUtils.getAllProject(); // try { taskId = Integer.valueOf(ALEipUtils.getTemp(rundata, context, ALEipConstants.ENTITY_ID)); } catch (NumberFormatException e) { taskId = null; } // ??? hasChildren = (ProjectUtils.getCountChildrenTask(taskId) > 0); }