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:de.snertlab.xdccBee.ui.dialog.EditNewIrcServerDialog.java
@Override protected String checkFields() { String msg = ""; //$NON-NLS-1$ if (StringUtils.isEmpty(txtHostname.getText())) { msg = msg + XdccBeeMessages.getString("EditNewIrcServerDialog_CHECK_ERROR_HOSTNAME_EMPTY") + "\n"; //$NON-NLS-1$//$NON-NLS-2$ }/*from w w w . j a v a 2s . c o m*/ if (StringUtils.isEmpty(txtPort.getText())) { msg = msg + XdccBeeMessages.getString("EditNewIrcServerDialog_CHECK_ERROR_PORT_EMPTY") + "\n"; //$NON-NLS-1$//$NON-NLS-2$ } else if (!StringUtils.isNumeric(txtPort.getText())) { msg = msg + XdccBeeMessages.getString("EditNewIrcServerDialog_CHECK_ERROR_PORT_INTEGER") + "\n"; //$NON-NLS-1$//$NON-NLS-2$ } return msg; }
From source file:io.druid.storage.hdfs.HdfsDataSegmentKiller.java
@Override public void kill(DataSegment segment) throws SegmentLoadingException { final Path segmentPath = getPath(segment); log.info("killing segment[%s] mapped to path[%s]", segment.getIdentifier(), segmentPath); try {/*from www.j a va 2 s.c om*/ String segmentLocation = segmentPath.getName(); final FileSystem fs = segmentPath.getFileSystem(config); if (!segmentLocation.endsWith(".zip")) { throw new SegmentLoadingException("Unknown file type[%s]", segmentPath); } else { if (!fs.exists(segmentPath)) { log.warn("Segment Path [%s] does not exist. It appears to have been deleted already.", segmentPath); return; } String[] zipParts = segmentLocation.split("_"); // for segments stored as hdfs://nn1/hdfs_base_directory/data_source_name/interval/version/shardNum_index.zip if (zipParts.length == 2 && zipParts[1].equals("index.zip") && StringUtils.isNumeric(zipParts[0])) { if (!fs.delete(segmentPath, false)) { throw new SegmentLoadingException("Unable to kill segment, failed to delete [%s]", segmentPath.toString()); } Path descriptorPath = new Path(segmentPath.getParent(), io.druid.java.util.common.StringUtils.format("%s_descriptor.json", zipParts[0])); //delete partitionNumber_descriptor.json if (!fs.delete(descriptorPath, false)) { throw new SegmentLoadingException("Unable to kill segment, failed to delete [%s]", descriptorPath.toString()); } //for segments stored as hdfs://nn1/hdfs_base_directory/data_source_name/interval/version/shardNum_index.zip // max depth to look is 2, i.e version directory and interval. mayBeDeleteParentsUpto(fs, segmentPath, 2); } else { //for segments stored as hdfs://nn1/hdfs_base_directory/data_source_name/interval/version/shardNum/ // index.zip if (!fs.delete(segmentPath, false)) { throw new SegmentLoadingException("Unable to kill segment, failed to delete [%s]", segmentPath.toString()); } Path descriptorPath = new Path(segmentPath.getParent(), "descriptor.json"); if (!fs.delete(descriptorPath, false)) { throw new SegmentLoadingException("Unable to kill segment, failed to delete [%s]", descriptorPath.toString()); } //for segments stored as hdfs://nn1/hdfs_base_directory/data_source_name/interval/version/shardNum/index.zip //max depth to look is 3, i.e partition number directory,version directory and interval. mayBeDeleteParentsUpto(fs, segmentPath, 3); } } } catch (IOException e) { throw new SegmentLoadingException(e, "Unable to kill segment"); } }
From source file:ee.pri.rl.blog.web.page.setting.SettingValidator.java
private void validateNumMainEntries(IValidatable<String> validatable) { String value = validatable.getValue(); if (!StringUtils.isNumeric(value)) { error(validatable, "Value must be number"); } else {// w w w .j a v a2 s. c om int intValue = Integer.valueOf(value); if (intValue < 0) { error(validatable, "Value must be greater than or equal to 0"); } } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.manager.ManageHolidaysDA.java
public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixServiceException { final String holidayIDString = request.getParameter("holidayID"); if (holidayIDString != null && StringUtils.isNumeric(holidayIDString)) { final Holiday holiday = FenixFramework.getDomainObject(holidayIDString); DeleteHoliday.run(holiday);/*from w w w .j a v a 2 s . c o m*/ } return prepare(mapping, form, request, response); }
From source file:fr.paris.lutece.plugins.mydashboard.web.portlet.MyDashboardPortletJspBean.java
/** * {@inheritDoc}/*w ww . ja v a 2 s.c o m*/ */ @Override public String doCreate(HttpServletRequest request) { MyDashboardPortlet portlet = new MyDashboardPortlet(); String strIdPage = request.getParameter(PARAMETER_PAGE_ID); int nIdPage = (StringUtils.isNotEmpty(strIdPage) && StringUtils.isNumeric(strIdPage)) ? Integer.parseInt(strIdPage) : 1; // get portlet common attributes String strErrorUrl = setPortletCommonData(request, portlet); if (strErrorUrl != null) { return strErrorUrl; } portlet.setPageId(nIdPage); //Portlet creation MyDashboardPortletHome.getInstance().create(portlet); //Displays the page with the new Portlet return getPageUrl(nIdPage); }
From source file:de.thischwa.pmcms.server.ContextUtil.java
public static APoormansObject<?> getpo(final String idString) { if (StringUtils.isBlank(idString) || !StringUtils.isNumeric(idString)) throw new IllegalArgumentException("'id' not found!"); int id = Integer.valueOf(idString); return siteHolder.get(id); }
From source file:com.impetus.client.cassandra.CassandraClientProperties.java
/** * Populate client properties.//from ww w . j a v a 2 s. co m * * @param client the client * @param properties the properties */ public void populateClientProperties(Client client, Map<String, Object> properties) { this.cassandraClientBase = (CassandraClientBase) client; if (properties != null) { for (String key : properties.keySet()) { Object value = properties.get(key); if (checkNull(key, value)) { if (key.equals(CONSISTENCY_LEVEL)) { setConsistencylevel(value); } else if (key.equals(CQL_VERSION) && value instanceof String) { this.cassandraClientBase.setCqlVersion((String) value); } else if (key.equals(TTL_PER_SESSION)) { setTTLPerSession(value); } else if (key.equals(TTL_PER_REQUEST)) { setTTLPerRequest(value); } else if (key.equals(TTL_VALUES) && value instanceof Map) { this.cassandraClientBase.setTtlValues((Map) value); } else if (key.equals(PersistenceProperties.KUNDERA_BATCH_SIZE) && !StringUtils.isBlank(value.toString()) && StringUtils.isNumeric(value.toString())) { this.cassandraClientBase.setBatchSize(value.toString()); } // Add more properties as needed } } } }
From source file:fr.paris.lutece.plugins.suggest.service.SuggestSubmitExtendableResourceService.java
/** * {@inheritDoc}//from ww w .j av a2 s .c o m */ @Override public IExtendableResource getResource(String strIdResource, String strResourceType) { if (StringUtils.isNotBlank(strIdResource) && StringUtils.isNumeric(strIdResource)) { int nIdSuggestSubmit = Integer.parseInt(strIdResource); return SuggestSubmitService.getService().findByPrimaryKey(nIdSuggestSubmit, false, PluginService.getPlugin(SuggestPlugin.PLUGIN_NAME)); } return null; }
From source file:io.github.xxyy.simplegiveall.SimpleGiveallMain.java
@SuppressWarnings("deprecation") //ItemStack IDs private static ItemStack handleGiveallSpecific(final CommandSender sender, final String[] args) { //giveall item[:damage] amount ItemStack finalStack;//from www. j a v a 2s .c om int amount = 1; short damage = 0; if (args.length >= 2) { if (!StringUtils.isNumeric(args[1])) { sender.sendMessage(MessageFormat.format(bundle.getString("AMOUNT_NAN"), args[1])); return null; } amount = Integer.parseInt(args[1]); } final String[] itemInfo = args[0].split(bundle.getString("MATERIAL_DAMAGE_SEPERATOR")); //default is ':' if (itemInfo.length > 1) { //If we have a damage given, use that if (StringUtils.isNumeric(itemInfo[1])) { //Check that the damage is actually numeric damage = Short.parseShort(itemInfo[1]); } else { sender.sendMessage(MessageFormat.format(bundle.getString("INVALID_DAMAGE"), itemInfo[1])); return null; } } if (StringUtils.isNumeric(itemInfo[0])) { //Check if we have been passed an item ID finalStack = new ItemStack(Integer.parseInt(itemInfo[0]), amount, damage); sender.sendMessage(MessageFormat.format(bundle.getString("ITEMIDS_DEPRECATED"), finalStack.getType())); //Send the user a message noting that item IDs will be removed in a future update } else { //Else, we probably have a material name final Material material = Material.matchMaterial(itemInfo[0].replace("-", "_")); //replace dashes with underscores because that's a common mistake if (material == null) { //If the user passed an invalid material name sender.sendMessage( MessageFormat.format(bundle.getString("UNKNOWN_MATERIAL"), itemInfo[0].toUpperCase())); printHelpTo(sender); return null; } finalStack = new ItemStack(material, amount, damage); } return finalStack; }
From source file:fr.paris.lutece.plugins.workflow.modules.appointment.service.TaskUpdateAdminAppointment.java
/** * {@inheritDoc}/*www . j a v a 2 s . c om*/ */ @Override public void processTask(int nIdResourceHistory, HttpServletRequest request, Locale locale) { ResourceHistory resourceHistory = _resourceHistoryService.findByPrimaryKey(nIdResourceHistory); String strIdAdminUser = request.getParameter(PARAMETER_ID_ADMIN_USER); if (StringUtils.isNotEmpty(strIdAdminUser) && StringUtils.isNumeric(strIdAdminUser)) { int nIdAdminUser = Integer.parseInt(strIdAdminUser); AdminUser adminUser = AdminUserHome.findByPrimaryKey(nIdAdminUser); if (adminUser != null) { Appointment appointment = AppointmentHome.findByPrimaryKey(resourceHistory.getIdResource()); if (appointment.getIdAdminUser() != nIdAdminUser) { appointment.setIdAdminUser(nIdAdminUser); AppointmentHome.update(appointment); UpdateAdminAppointmentHistory history = new UpdateAdminAppointmentHistory(); history.setIdHistory(resourceHistory.getId()); history.setIdAppointment(resourceHistory.getIdResource()); history.setIdAdminUser(nIdAdminUser); UpdateAdminAppointmentHistoryHome.create(history); } } } }