private int toUnicode(@NotNull String str) { if (NumberUtils.isNumber(str)) { return Integer.parseInt(str); // If we have a number, it represents the Unicode code point of a letter } else { return (int)str.charAt(0); // If it's not a number we should only have strings consisting of one char } }
/** * Useful for figuring out if an Object is a number. */ public static boolean isNumeric(Object value) { if (value == null) return false; if (value instanceof Number) return true; if (value instanceof String) { String stringValue = (String) value; if (isNullOrEmpty(stringValue)) return true; return isNumber(stringValue); } return false; }
@Override protected boolean isInputValid(ConversationContext context, String input) { return NumberUtils.isNumber(input) && isNumberValid(context, NumberUtils.createNumber(input)); }
@Override protected String getFailedValidationText(ConversationContext context, String invalidInput) { if (NumberUtils.isNumber(invalidInput)) { return getFailedValidationText(context, NumberUtils.createNumber(invalidInput)); } else { return getInputNotNumericText(context, invalidInput); } }
return errorMessage; if(!NumberUtils.isNumber(amount)) { errorMessage = "request params[amount] error."; return errorMessage;
/** * Parses a block state from a string. * * @param sender the target who should receive an error message if {@code state} is * invalid * @param type the block type * @param state a string specifying a block state * @return the block state for {@code type} and {@code state}, or null if none match */ public static BlockStateData readState(CommandSender sender, Material type, String state) { if (NumberUtils.isNumber(state)) { return new BlockStateData(Byte.parseByte(state)); } try { return StateSerialization.parse(type, state); } catch (InvalidBlockStateException e) { sender.sendMessage(ChatColor.RED + e.getMessage()); return null; } }
throw new Pql2CompilationException("Having predicate only compares function calls"); if (!NumberUtils.isNumber(((ComparisonPredicateAstNode) visitingNode).getValue())) { throw new Pql2CompilationException("Having clause only supports comparing function result with numbers"); throw new Pql2CompilationException("Having predicate only compares function calls"); if (!NumberUtils.isNumber(((BetweenPredicateAstNode) visitingNode).getLeftValue())) { throw new Pql2CompilationException("Having clause only supports comparing function result with numbers"); if (!NumberUtils.isNumber(((BetweenPredicateAstNode) visitingNode).getRightValue())) { throw new Pql2CompilationException("Having clause only supports comparing function result with numbers"); if (!NumberUtils.isNumber(value)) { throw new Pql2CompilationException("Having clause only supports comparing function result with numbers");
@Override public boolean validateOptions(Map<String,String> options) { String o = options.get(NUM_SCANS_STRING_NAME); if (o != null && !NumberUtils.isNumber(o)) throw new IllegalArgumentException( "bad integer " + NUM_SCANS_STRING_NAME + ":" + options.get(NUM_SCANS_STRING_NAME)); return true; }
/** * Parses a string like "1.0.2" into the version number. * * @param num parameter string */ public VersionNumber(String num) { StringTokenizer tokens = new StringTokenizer(num, ".-_"); this.digits = new int[tokens.countTokens()]; if (this.digits.length < 2) { throw new IllegalArgumentException("Failed to parse " + num + " as version number"); } int i = 0; while (tokens.hasMoreTokens()) { String token = tokens.nextToken().toLowerCase(); if (token.equals("*")) { this.digits[i++] = 1000; } else if (StringUtils.startsWithIgnoreCase(token, "snapshot")) { this.digits[i - 1]--; //noinspection UnusedAssignment this.digits[i++] = 1000; break; } else { if (NumberUtils.isNumber(token)) { this.digits[i++] = Integer.parseInt(token); } } } }
if(value != null && NumberUtils.isNumber(value) && numberTypes.get(valueClazz) != null)
if (codeEnd == -1) { String text = str.substring(begin); if (text.length() > 0 && NumberUtils.isNumber(text)) { return HttpError.code(Integer.parseInt(text));
@Override public void run(FlowTrigger trigger, Map data) { HashSet<String> sets = new HashSet<>(); contents.forEach((f, c) -> { for (ErrorCodeElaboration err: c) { if (err.getCode() == null || err.getCode().isEmpty() || err.getCategory() == null || err.getCategory().isEmpty()) { continue; } if (!NumberUtils.isNumber(err.getCode())) { trigger.fail(operr("elaboration code must be number!")); return; } String code = err.getCategory() + "." + err.getCode(); if (!isClassPathFolder && StringSimilarity.errorCodeContained(code)) { results.add(new ElaborationCheckResult(f, err.getRegex(), ElaborationFailedReason.ErrorCodeAlreadyExisted.toString())); } if (sets.contains(code)) { results.add(new ElaborationCheckResult(f, err.getRegex(), ElaborationFailedReason.DuplicatedErrorCode.toString())); } else { sets.add(code); } } }); trigger.next(); } }).done(new FlowDoneHandler(completion) {
private List<ElaborationVO> getMissedElatorations(Long repeats, String from) { Long times = repeats != null ? repeats : 1L; if (from == null) { return Q.New(ElaborationVO.class).eq(ElaborationVO_.matched, false).gte(ElaborationVO_.repeats, times).list(); } else { if (TimeUtils.isValidTimestampFormat(from)) { long start = TimeUtils.parseFormatStringToTimeStamp(from); return Q.New(ElaborationVO.class).eq(ElaborationVO_.matched, false).gte(ElaborationVO_.repeats, times). gte(ElaborationVO_.lastOpDate, new Timestamp(start)).list(); } else if (NumberUtils.isNumber(from)) { try { return Q.New(ElaborationVO.class).eq(ElaborationVO_.matched, false).gte(ElaborationVO_.repeats, times). gte(ElaborationVO_.lastOpDate, new Timestamp(Long.valueOf(from))).list(); } catch (NumberFormatException e) { throw new OperationFailureException(argerr("%s is not a Long value Number", from)); } } else { throw new OperationFailureException(argerr("arg 'startTime' should format like 'yyyy-MM-dd HH:mm:ss' or '1545380003000'")); } } }
public MaxValidator(String maxValue) { if (!NumberUtils.isNumber(maxValue)) { throw new IllegalArgumentException(maxValue + " is not a Java number."); } this.maxValue = maxValue; }
/** * Check if the value can be right aligned. Does not trim the values before checking if numeric since it assumes * the spaces mean that the value is already padded. * * @param value to check * @return true if the value is a right alignable */ protected static boolean isRightAlign(final String value) { return value == null || RIGHT_ALIGN_STRINGS.contains(value) || NumberUtils.isNumber(value.trim()); }
/** * Checks if the value of this object is a boolean or numeric value. * * @return <code>true</code> if the value is a boolean or number, otherwise <code>false</code> */ public boolean isBooleanOrNumeric() { return isBooleanValue(value) || NumberUtils.isNumber(value); }
private Student getStudent(final ActionForm actionForm) { final String studentNumberString = ((DynaActionForm) actionForm).getString("studentNumber"); if (!StringUtils.isEmpty(studentNumberString) && NumberUtils.isNumber(studentNumberString)) { return Student.readStudentByNumber(Integer.valueOf(studentNumberString)); } return null; }
public static Date parseDate(String value) { if (value == null || value.isEmpty()) { return null; } if (NumberUtils.isNumber(value)) { return new FMDate(value); } return DateUtil.parseDate(value); }
@Override public Object apply(String input) { if (input.contains(LIST_DELIMITER)) { return splitBySeparatorAndTrimItems(input); } if (NumberUtils.isNumber(input)) { return NumberUtils.createNumber(input); } return input; }
private boolean useNewUi(final String token, final StaplerRequest req) { return isNewUi() && (StringUtils.startsWith(token, "dotCI") || //job pages (NumberUtils.isNumber(token) && (StringUtils.isEmpty(req.getRestOfPath()) || StringUtils.contains(req.getRestOfPath(), "dotCI")))); // buildpages }