List of usage examples for org.apache.commons.lang3.math NumberUtils toInt
public static int toInt(final String str, final int defaultValue)
Convert a String
to an int
, returning a default value if the conversion fails.
If the string is null
, the default value is returned.
NumberUtils.toInt(null, 1) = 1 NumberUtils.toInt("", 1) = 1 NumberUtils.toInt("1", 0) = 1
From source file:org.jasig.cas.client.configuration.BaseConfigurationStrategy.java
public final int getInt(final ConfigurationKey<Integer> configurationKey) { return getValue(configurationKey, new Parser<Integer>() { public Integer parse(final String value) { return NumberUtils.toInt(value, configurationKey.getDefaultValue()); }//www. j a v a 2 s.c o m }); }
From source file:org.jodconverter.boot.autoconfigure.JodConverterLocalAutoConfiguration.java
private OfficeManager createOfficeManager() { final LocalOfficeManager.Builder builder = LocalOfficeManager.builder(); if (!StringUtils.isBlank(properties.getPortNumbers())) { builder.portNumbers(//from ww w.j a v a2s. co m ArrayUtils.toPrimitive(Stream.of(StringUtils.split(properties.getPortNumbers(), ", ")) .map(str -> NumberUtils.toInt(str, 2002)).toArray(Integer[]::new))); } builder.officeHome(properties.getOfficeHome()); builder.workingDir(properties.getWorkingDir()); builder.templateProfileDir(properties.getTemplateProfileDir()); builder.killExistingProcess(properties.isKillExistingProcess()); builder.processTimeout(properties.getProcessTimeout()); builder.processRetryInterval(properties.getProcessRetryInterval()); builder.taskExecutionTimeout(properties.getTaskExecutionTimeout()); builder.maxTasksPerProcess(properties.getMaxTasksPerProcess()); builder.taskQueueTimeout(properties.getTaskQueueTimeout()); // Starts the manager return builder.build(); }
From source file:org.jodconverter.spring.JodConverterBean.java
@Override public void afterPropertiesSet() throws OfficeException { // NOSONAR final LocalOfficeManager.Builder builder = LocalOfficeManager.builder(); if (!StringUtils.isBlank(portNumbers)) { builder.portNumbers(ArrayUtils.toPrimitive(Stream.of(StringUtils.split(portNumbers, ", ")) .map(str -> NumberUtils.toInt(str, 2002)).toArray(Integer[]::new))); }// www. j a v a 2 s . com builder.officeHome(officeHome); builder.workingDir(workingDir); builder.templateProfileDir(templateProfileDir); builder.killExistingProcess(killExistingProcess); builder.processTimeout(processTimeout); builder.processRetryInterval(processRetryInterval); builder.taskExecutionTimeout(taskExecutionTimeout); builder.maxTasksPerProcess(maxTasksPerProcess); builder.taskQueueTimeout(taskQueueTimeout); // Starts the manager officeManager = builder.build(); documentConverter = LocalConverter.make(officeManager); officeManager.start(); }
From source file:org.lodder.subtools.sublibrary.data.tvrage.model.TVRageEpisodeNumber.java
public TVRageEpisodeNumber(String season, String episode) { this.season = NumberUtils.toInt(season, 0); this.episode = NumberUtils.toInt(episode, 0); // Calculate the absolute if we are not passed one this.absolute = calculateAbsolute(this.season, this.episode); }
From source file:org.lodder.subtools.sublibrary.data.tvrage.model.TVRageEpisodeNumber.java
public TVRageEpisodeNumber(String season, String episode, String absolute) { this.season = NumberUtils.toInt(season, 0); this.episode = NumberUtils.toInt(episode, 0); this.absolute = NumberUtils.toInt(absolute, 0); }
From source file:org.mariotaku.twidere.model.ParcelableCardEntity.java
public int getAsInteger(@Nullable String key, int def) { final ParcelableBindingValue value = getValue(key); if (value == null) return def; return NumberUtils.toInt(value.value, def); }
From source file:org.mariotaku.twidere.service.RefreshService.java
private long getRefreshInterval() { if (mPreferences == null) return 0; final int prefValue = NumberUtils .toInt(mPreferences.getString(KEY_REFRESH_INTERVAL, DEFAULT_REFRESH_INTERVAL), -1); return Math.max(prefValue, 3) * 60 * 1000; }
From source file:org.mariotaku.twidere.util.TwidereValidator.java
public TwidereValidator(final Context context) { final SharedPreferencesWrapper prefs = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mValidator = new Validator(); if (prefs != null) { final String textLimit = prefs.getString(KEY_STATUS_TEXT_LIMIT, null); mMaxTweetLength = NumberUtils.toInt(textLimit, Validator.MAX_TWEET_LENGTH); } else {// w w w .jav a2 s.c om mMaxTweetLength = Validator.MAX_TWEET_LENGTH; } }
From source file:org.mobile.mpos.controller.UserController.java
public void listUser() { String page = getPara("page"); if (StringUtils.isBlank(page)) { renderJson(fail("PAGE_EMPTY", "?")); return;/*from w w w . j a v a 2 s . c o m*/ } String count = getPara("size"); if (StringUtils.isBlank(count)) { renderJson(fail("SIZE_EMPTY", "??")); return; } MobileUserService mobileUserService = Duang.duang(MobileUserService.class); long all = mobileUserService.countUser(); int offset = (NumberUtils.toInt(page, 1) - 1) * NumberUtils.toInt(count, 5); int size = NumberUtils.toInt(count, 5); long pageSize = 0; if (all % size == 0) { pageSize = all / size; } else { pageSize = all / size + 1; } Map<String, Object> result = new HashMap<String, Object>(); result.put("pageSize", pageSize); result.put("page", NumberUtils.toInt(page, 1)); List<Map<String, String>> data = mobileUserService.pageAllUsers(offset, size); result.put("size", NumberUtils.toInt(count, 5)); result.put("factSize", data.size()); result.put("pageData", data); renderJson(success(result)); }
From source file:org.neo4j.kernel.api.impl.index.IndexReaderStub.java
private int maxValue() { return Arrays.stream(elements).mapToInt(value -> NumberUtils.toInt(value, 0)).max().getAsInt(); }