本文整理汇总了Java中org.apache.commons.lang3.math.NumberUtils.isNumber方法的典型用法代码示例。如果您正苦于以下问题:Java NumberUtils.isNumber方法的具体用法?Java NumberUtils.isNumber怎么用?Java NumberUtils.isNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.math.NumberUtils
的用法示例。
在下文中一共展示了NumberUtils.isNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: docsToUsers
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
* Converts the given {@link DocumentsSearchResult} to a {@link ISearchResult} containing
* the found {@link User}s. It extracts all user ids from the {@link Document}s
* and queries the database for them.
* @param docsResult the {@link DocumentsSearchResult} to convert.
* @return {@link ISearchResult} containing the {@link User}s.
*/
private ISearchResult<User> docsToUsers(final DocumentsSearchResult docsResult) {
final List<Long> userIds = new ArrayList<>();
for (final Document doc : docsResult.getResults()) {
final String userId = doc.get(IIndexElement.FIELD_ID);
if(NumberUtils.isNumber(userId)) {
userIds.add(Long.valueOf(userId));
}
else {
LOGGER.error("Not numeric user id from index {}.", userId);
}
}
// no results -> return empty ISearchResult
if(userIds.isEmpty()) {
return new SimpleSearchResult<User>(new ArrayList<User>(), docsResult.getTotalHits());
}
return new SimpleSearchResult<>(DSL.using(jooqConfig).
select().
from(TABLE).
where(TABLE.ID.in(userIds)).
orderBy(DSL.field("FIELD(id, " + StringUtils.join(userIds, ", ") + ")", Long.class)).
fetchInto(User.class), docsResult.getTotalHits());
}
示例2: docsToProviders
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
* Builds {@link Provider}s for the given {@link Document}s.
* @param docsResult the {@link Document}s to convert.
* @return a new {@link ISearchResult} containing the {@link Provider}s and the
* totalHits from the given {@link DocumentsSearchResult}.
*/
private ISearchResult<Provider> docsToProviders(final DocumentsSearchResult docsResult) {
final List<Provider> providers = new ArrayList<>();
for (final Document doc : docsResult.getResults()) {
final String providerId = doc.get(IIndexElement.FIELD_ID);
if(NumberUtils.isNumber(providerId)) {
providers.add(getProvider(Integer.parseInt(providerId)));
}
else {
LOGGER.error("Not numeric user id from index {}.", providerId);
}
}
return new SimpleSearchResult<>(providers, docsResult.getTotalHits());
}
示例3: parseIntArray
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
* Parses a string, representing an array of integers (e.g. [1,2,3]) into an {@link Integer} array
* @param arrayString an integer array string
* @return an {@link Integer} array
*/
public static Integer[] parseIntArray(String arrayString) {
String[] items = arrayString.replaceAll("\\[", "").replaceAll("\\]", "").split(",");
Integer[] results = new Integer[items.length];
for (int i = 0; i < items.length; i++) {
String numberString = items[i].trim();
if (NumberUtils.isNumber(numberString)) {
results[i] = Integer.parseInt(numberString);
} else {
return null;
}
}
return results;
}
示例4: validate
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
@Override
public ArrayList<String> validate() {
ArrayList<String> ret = new ArrayList<>();
if (name == null || name.equalsIgnoreCase("null") || name.trim().length() == 0)
ret.add("Operation Name Cannot be empty");
if (type == null || type.equalsIgnoreCase("null") || type.trim().length() == 0)
ret.add("Operation Type Cannot be empty");
if (getType().equalsIgnoreCase(Enums.ModuleOperationTypes.REQUEST_SENT.name())) {
if (timeout == null || timeout.equalsIgnoreCase("null") || timeout.trim().length() == 0 || !NumberUtils.isNumber(timeout))
ret.add("Timeout Cannot be empty");
}
if (getType().equalsIgnoreCase(Enums.ModuleOperationTypes.DATA_READ.name()) || getType().equalsIgnoreCase(Enums.ModuleOperationTypes.DATA_WRITE.name())) {
if (dType == null || dType.equalsIgnoreCase("null") || dType.trim().length() == 0)
ret.add("Data Type Cannot be empty");
}
return ret;
}
示例5: validate
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
@Override
public ArrayList<String> validate() {
ArrayList<String> ret = new ArrayList<>();
if (name == null || name.equalsIgnoreCase("null") || name.trim().length() == 0)
ret.add("Node Name Cannot be empty");
if (endianess == null || endianess.equalsIgnoreCase("null") || endianess.trim().length() == 0)
ret.add("Endianess Cannot be empty");
if (osName == null || osName.equalsIgnoreCase("null") || osName.trim().length() == 0)
ret.add("OS Name Cannot be empty");
if (osVer == null || osVer.equalsIgnoreCase("null") || osVer.trim().length() == 0)
ret.add("OS Version Cannot be empty");
if (availMem == null || availMem.equalsIgnoreCase("null") || availMem.trim().length() == 0 || (!NumberUtils.isNumber(availMem)))
ret.add("Available Memory Cannot be empty or a Non-numeric value");
if (mst == null || mst.equalsIgnoreCase("null") || mst.trim().length() == 0 || (!NumberUtils.isNumber(mst)))
ret.add("Module Switch Time Cannot be empty or a Non-numeric value");
return ret;
}
示例6: getBigFileThreshold
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
public static final Long getBigFileThreshold() {
if (bigFileThreshold == null) {
String bigThresholdValue = configure.get("filecloud.bigfile-threshold");
if (StringUtils.isNotBlank(bigThresholdValue) && NumberUtils.isNumber(bigThresholdValue.trim())) {
bigFileThreshold = NumberUtils.toLong(bigThresholdValue.trim());
} else {
bigFileThreshold = DEFAULT_BIG_FILE_THRESHOLD;
}
}
return bigFileThreshold;
}
示例7: parseAndSetScore
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
private void parseAndSetScore(String[] tokens, int tokenCount, NggbSimpleBedFeature feature) {
if (tokenCount > SCORE_OFFSET && NumberUtils.isNumber(tokens[SCORE_OFFSET])) {
try {
float score = Float.parseFloat(tokens[SCORE_OFFSET]);
feature.setScore(score);
} catch (NumberFormatException numberFormatException) {
feature.setScore(Float.NaN);
}
}
}
示例8: parseAndSetColour
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
private void parseAndSetColour(String[] tokens, int tokenCount, NggbSimpleBedFeature feature) {
if (tokenCount > COLOUR_OFFSET) {
String colorString = tokens[COLOUR_OFFSET];
feature.setColor(ParsingUtils.parseColor(colorString));
// ThickStart and ThickEnd
if (NumberUtils.isNumber(tokens[THICK_START_OFFSET])
&& NumberUtils.isNumber(tokens[THICK_END_OFFSET])) {
feature.setThickStart(Integer.parseInt(tokens[THICK_START_OFFSET]));
feature.setThickEnd(Integer.parseInt(tokens[THICK_END_OFFSET]));
}
}
}
示例9: editInput
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
@RequestMapping("/edit.html")
public String editInput(String id, ModelMap model) {
PayChannel item = null;
if(StringUtils.isNotBlank(id) && NumberUtils.isNumber(id)) {
item = payChannelService.selectPayChannel(Integer.parseInt(id));
}
if(item == null) item = new PayChannel();
model.put("item", item);
return "pay_channel/edit";
}
示例10: viewInput
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
@RequestMapping("/view.html")
public String viewInput(String id, ModelMap model) {
PayChannel item = null;
if(StringUtils.isNotBlank(id) && NumberUtils.isNumber(id)) {
item = payChannelService.selectPayChannel(Integer.parseInt(id));
}
if(item == null) item = new PayChannel();
model.put("item", item);
return "pay_channel/view";
}
示例11: getMaxRetryUploadFastDFSTimes
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
public static final Integer getMaxRetryUploadFastDFSTimes() {
if (maxRetryUploadFastDFSTimes == null) {
String maxRetryUploadFastDFSTimesValue = configure.get("filecloud.fdfs-max-retry-times");
if (StringUtils.isNotBlank(maxRetryUploadFastDFSTimesValue) && NumberUtils.isNumber(maxRetryUploadFastDFSTimesValue.trim())) {
maxRetryUploadFastDFSTimes = NumberUtils.toInt(maxRetryUploadFastDFSTimesValue.trim());
} else {
maxRetryUploadFastDFSTimes = DEFAULT_MAX_RETRY_UPLOAD_TIMES;
}
}
return maxRetryUploadFastDFSTimes;
}
示例12: validate
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
@Override
public ArrayList<String> validate() {
ArrayList<String> ret = new ArrayList<>();
if (name == null || name.equalsIgnoreCase("null") || name.trim().length() == 0)
ret.add("Dynamic Trigger Instance Name Cannot be empty");
if (priority == null || priority.equalsIgnoreCase("null") || priority.trim().length() == 0 || (!NumberUtils.isNumber(priority)))
ret.add("Dynamic Trigger Instance Priority Cannot be empty or a non numeric value");
return ret;
}
示例13: addNumberInfo
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
private void addNumberInfo(Map<String, Object> permittedInfo, Map<String, Object> info, int count,
VCFHeaderLineType type, InfoItem key) {
Object value;
if (count > 1) {
value = parseNumberArray(type, info.get(key.getName()));
if (value == null) {
LOGGER.error(MessageHelper.getMessage(
MessagesConstants.ERROR_FEATURE_INDEX_WRITING_WRONG_PARAMETER_TYPE,
key.getName(), key.getType(), info.get(key.getName()).toString()));
return;
}
permittedInfo.put("_" + key.getName() + "_v", info.get(key.getName()).toString());
} else {
String numberString = info.get(key.getName()).toString();
if (NumberUtils.isNumber(numberString)) {
value = parseNumber(type, info.get(key.getName()));
} else {
LOGGER.error(MessageHelper.getMessage(
MessagesConstants.ERROR_FEATURE_INDEX_WRITING_WRONG_PARAMETER_TYPE, key.getName(), key.getType(),
numberString));
return;
}
}
permittedInfo.put(key.getName(), value);
}
示例14: validate
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
@Override
public ArrayList<String> validate() {
ArrayList<String> ret = new ArrayList<>();
if (compName == null || compName.equalsIgnoreCase("null") || compName.trim().length() == 0)
ret.add("Computing Platform Name Cannot be empty");
if (moduleName == null || moduleName.equalsIgnoreCase("null") || moduleName.trim().length() == 0)
ret.add("Module Instance Name Cannot be empty");
if (priority == null || priority.equalsIgnoreCase("null") || priority.trim().length() == 0 || (!NumberUtils.isNumber(priority)))
ret.add("Priority Cannot be empty or a Non-numeric value");
return ret;
}
示例15: validate
import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
@Override
public ArrayList<String> validate() {
ArrayList<String> ret = new ArrayList<>();
if (compPlatform == null || compPlatform.equalsIgnoreCase("null") || compPlatform.trim().length() == 0)
ret.add("Computing Platform Name Cannot be empty");
if (mcastAddr == null || mcastAddr.equalsIgnoreCase("null") || mcastAddr.trim().length() == 0)
ret.add("Multicast Address Cannot be empty");
if (notifMaxNumber == null || notifMaxNumber.equalsIgnoreCase("null") || notifMaxNumber.trim().length() == 0 || (!NumberUtils.isNumber(notifMaxNumber)))
ret.add("Notification Max Number Cannot be empty or a Non-numeric value");
if (port == null || port.equalsIgnoreCase("null") || port.trim().length() == 0 || (!NumberUtils.isNumber(port)))
ret.add("Port Number Cannot be empty or a Non-numeric value");
if (platNum == null || platNum.equalsIgnoreCase("null") || platNum.trim().length() == 0 || (!NumberUtils.isNumber(platNum)))
ret.add("Platform Number Cannot be empty or a Non-numeric value");
return ret;
}