List of usage examples for org.apache.commons.lang3.math NumberUtils isDigits
public static boolean isDigits(final String str)
Checks whether the String
contains only digit characters.
Null
and empty String will return false
.
From source file:de.micromata.genome.logging.spi.BaseLoggingLocalSettingsConfigModel.java
@Override public void validate(ValContext ctx) { if (StringUtils.isBlank(maxLogAttrLength) == true) { maxLogAttrLength = "10241024"; }//w w w .ja v a 2 s . com if (NumberUtils.isDigits(maxLogAttrLength) == false) { ctx.directError("maxLogAttrLength", "maxLogAttrLength requires int"); } }
From source file:jodtemplate.pptx.Slide.java
public String getNextId() { int id = 1;//from www.j ava 2 s . c om for (final Relationship rel : otherRelationships) { final String numStr = StringUtils.removeStart(rel.getId(), Relationship.ID_PREFIX); if (NumberUtils.isDigits(numStr)) { final int num = Integer.parseInt(numStr); if (num >= id) { id = num + 1; } } } return Relationship.ID_PREFIX + id; }
From source file:com.galenframework.speclang2.specs.SpecComponentProcessor.java
private Object processArgumentValue(String value) { try {/* w ww. ja v a 2 s.com*/ if (value == null) { return ""; } if (NumberUtils.isDigits(value)) { return Long.parseLong(value); } else if (NumberUtils.isNumber(value)) { return Double.parseDouble(value); } else if (value.equals("true")) { return true; } else if (value.equals("false")) { return false; } else { return value; } } catch (Exception ex) { return value; } }
From source file:com.rcs.shoe.shop.fx.controller.ui.Controller.java
protected ChangeListener getDigitChangeListener(final TextField textField) { ChangeListener<String> result = new ChangeListener<String>() { @Override/*from w ww . j a v a2 s . c o m*/ public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (StringUtils.isBlank(newValue)) { textField.textProperty().setValue(""); } else if (NumberUtils.isDigits(newValue)) { textField.textProperty().setValue(newValue); } else { textField.textProperty().setValue(oldValue); } } }; return result; }
From source file:net.gtaun.shoebill.object.Player.java
/** * Gets a Player by its name or its Id/*www . j a v a 2 s . c om*/ * @param nameOrId The Name or Id * @return The found Player */ static Player getByNameOrId(String nameOrId) { nameOrId = nameOrId.trim(); Player player = get(nameOrId); if (player == null && NumberUtils.isDigits(nameOrId)) player = get(NumberUtils.toInt(nameOrId)); return player; }
From source file:de.bmarwell.j9kwsolver.util.ResponseUtils.java
/** * @param response the response sent by the server. * @return the number of credits assigned by the server for solving. *//*from w ww . ja v a 2s.c o m*/ private static int parseCredits(final String response) { int credits = 0; if (StringUtils.isEmpty(response)) { return credits; } String[] splitresponse = StringUtils.splitPreserveAllTokens(response, '|'); if (splitresponse.length != 2) { LOG.error("Response doesn't contain two items: {}.", ToStringBuilder.reflectionToString(splitresponse)); return credits; } // TODO: Enum for numbered field. String stringCredits = splitresponse[1]; if (NumberUtils.isDigits(stringCredits)) { credits = NumberUtils.toInt(stringCredits, 0); LOG.debug("Found reward: {} credits.", credits); } return credits; }
From source file:com.rcs.shoe.shop.fx.controller.ui.SaleEnterController.java
public void searchProduct() { String prodCode = productCode.getText(); String prodNumberTx = produstNumberText.getText(); if (NumberUtils.isDigits(prodNumberTx)) { searchProduct(Integer.parseInt(prodNumberTx), prodCode, false); } else {/*from ww w .j a v a 2 s . c om*/ searchProduct(null, prodCode, false); } }
From source file:de.micromata.mgc.application.webserver.config.JettyConfigModel.java
@Override public void validate(final ValContext valContext) { final ValContext ctx = valContext.createSubContext(this, ""); if (NumberUtils.isDigits(idleTimeout) == false) { ctx.directError("idleTimeout", "Please provide numeric idleTimeout number"); }/* w w w . ja v a2s . co m*/ if (StringUtils.isBlank(port) == true) { ctx.directError("serverPort", "Please provide a server port"); } else { if (NumberUtils.isDigits(port) == false) { ctx.directError("serverPort", "Please provide numeric port number"); } } if (isInt(sessionTimeout) == false) { ctx.directError("serverPort", "Please provide a numeric value for the session timeout"); } if (isSslEnabled() == false) { return; } if (StringUtils.isBlank(sslPort) == true) { ctx.directError("sslPort", "Please provide a server port"); } else { if (NumberUtils.isDigits(port) == false) { ctx.directError("sslPort", "Please provid numeric port number"); } } if (StringUtils.isBlank(sslKeystorePath) == true) { ctx.directError("sslKeystorePath", "Please provide a keystore file"); } else { final File keystorefile = new File(sslKeystorePath); if (keystorefile.exists() == false) { ctx.directError("sslKeystorePath", "Cannot find keystore: " + keystorefile.getAbsolutePath()); } } if (StringUtils.isBlank(trustStorePath) == true) { ctx.directError("trustStorePath", "Please provide a trust store file"); } else { final File keystorefile = new File(trustStorePath); if (keystorefile.exists() == false) { ctx.directError("trustStorePath", "Cannot find trust store: " + keystorefile.getAbsolutePath()); } } }
From source file:com.rcs.shoe.shop.fx.controller.ui.ProductsController.java
public void changeProductState() { String text = selProductNum.textProperty().getValue(); if (NumberUtils.isDigits(text)) { Integer prouctNumber = Integer.parseInt(selProductNum.textProperty().getValue()); uIConfig.loadEditProduct(prouctNumber, false); } else {/*w ww . j a v a 2 s .co m*/ showSelectProductpopup(); } }
From source file:gov.ca.cwds.cals.service.ComplaintsService.java
private boolean isCwsCmsFacility(String facilityId) { return !NumberUtils.isDigits(facilityId); }