本文整理汇总了Java中org.apache.commons.lang3.StringUtils.isNumeric方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.isNumeric方法的具体用法?Java StringUtils.isNumeric怎么用?Java StringUtils.isNumeric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.isNumeric方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSingleItemDescription
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
protected String getSingleItemDescription(String expression) {
String exp = expression;
if (expression.contains("#")) {
exp = expression.substring(0, expression.indexOf("#"));
} else if (expression.contains("L")) {
exp = exp.replace("L", "");
}
if (StringUtils.isNumeric(exp)) {
int dayOfWeekNum = Integer.parseInt(exp);
boolean isZeroBasedDayOfWeek = (options == null || options.isZeroBasedDayOfWeek());
boolean isInvalidDayOfWeekForSetting = (options != null && !options.isZeroBasedDayOfWeek() && dayOfWeekNum <= 1);
if (isInvalidDayOfWeekForSetting || (isZeroBasedDayOfWeek && dayOfWeekNum == 0)) {
return DateAndTimeUtils.getDayOfWeekName(7);
} else if (options != null && !options.isZeroBasedDayOfWeek()) {
dayOfWeekNum -= 1;
}
return DateAndTimeUtils.getDayOfWeekName(dayOfWeekNum);
} else {
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("EEE").withLocale(Locale.ENGLISH);
return dateTimeFormatter.parseDateTime(WordUtils.capitalizeFully(exp)).dayOfWeek().getAsText(I18nMessages.getCurrentLocale());
}
}
示例2: containsGenomeMapping
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Iterates over all genomes, and checks for each one in the genome mapping if they are present if they are numeric.
* If none are numeric, it simply checks if the passed genome is present in the list.
*
* @param genomes genomes
* @param genome genome
* @return true iff it is found
*/
public boolean containsGenomeMapping(final List<String> genomes, final String genome) {
for (final String criteria : genomes) {
if (StringUtils.isNumeric(criteria) && genome.equals(genomeMapping.get(criteria))) {
return true;
}
}
return genomes.contains(genome);
}
示例3: findUsers
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@RequestMapping("list-owners")
public ModelAndView findUsers(@ModelAttribute("owner") FindOwnerDTO owner,
@RequestParam(name = "initialPage", value = "", required = false) String initialPage) {
ModelAndView mv = new ModelAndView("users/list-owners");
mv.addObject("navActive", NavIds.getInstance().getOwners());
int page = 0;
int size = 5;
if (StringUtils.isNumeric(initialPage)) {
page = Integer.valueOf(initialPage);
}
mv.addObject("owners", ownerService.findBy(owner, page, size));
return mv;
}
示例4: deserialize
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public Date deserialize(JsonParser gen, DeserializationContext ctxt) throws IOException, JsonProcessingException {
String date = gen.getText();
if (StringUtils.isEmpty(date)) {
return null;
}
if (StringUtils.isNumeric(date)) {
return new Date(Long.valueOf(date));
}
try {
DateTime dt = fmt.parseDateTime(date);
return dt.toDate();
} catch (Exception e) {
throw new IOException(e);
}
}
示例5: execute
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSource source, String[] args) {
if ((args.length != 2 && args.length != 3) || !StringUtils.isNumeric(args[1])) {
source.sendMessage(TextUtil.of("§c/" + McrmbPluginInfo.config.command + " give <玩家> <增加数量> [理由]"));
return true;
}
if (source instanceof Player && !McrmbPluginInfo.config.opModifyWhiteList.contains(source.getName())) {
source.sendMessage(TextUtil.of("§c你无法执行该操作,你可以在后台输入/" + McrmbPluginInfo.config.command + " adminwhite add <你的ID> 来添加你到操作点券白名单"));
return true;
}
Task.builder().name("manual-give")
.execute(() -> {
ManualResult result = McrmbCoreAPI.manual(args[0], ManualType.ADD, Integer.parseInt(args[1]), args.length == 3 ? args[2] : source.getName() + "加款");
if (result == null) {
source.sendMessage(TextUtil.of("§c加款失败"));
return;
}
source.sendMessage(TextUtil.of("§2加款成功,返回信息: §a" + result.getMsg()));
}).submit(McrmbCoreMain.instance());
return true;
}
示例6: readSpatialReference
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public ISpatialReference readSpatialReference(String spatialReference) {
try {
if (StringUtils.isNumeric(spatialReference)) {
SpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceFactory();
try {
int wkid = Integer.parseInt(spatialReference);
return spatialReferenceFactory.create(wkid);
} catch (NumberFormatException ignored) {
}
}
IJSONConverterGeometry converterGeometry = new JSONConverterGeometry();
IJSONReader jsonReader = createJSONReader(spatialReference);
ISpatialReference sr = converterGeometry
.readSpatialReference(jsonReader);
Cleaner.release(jsonReader);
Cleaner.release(converterGeometry);
return sr;
} catch (IOException e) {
throw new JSONException(String.format(
"Cannot map JSON string '%1$s' to %2$s", spatialReference,
"ISpatialReference"), e);
}
}
示例7: compare
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public int compare(T o1, T o2) {
Comparable obj1 = null;
Comparable obj2 = null;
try {
obj1 = (Comparable) PropertyUtils.getProperty(o1, this.propertyPath);
obj2 = (Comparable) PropertyUtils.getProperty(o2, this.propertyPath);
} catch (NestedNullException ignored) {
// Ignored, als het property NULL is, dan vergelijken met NULL
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new IllegalArgumentException("Could not retrieve property " + this.propertyPath, e);
}
Comparator<Comparable<Object>> objectComparator = null;
if ((obj1 != null && obj2 != null) && obj1 instanceof String) {
obj1 = ((String) obj1).toLowerCase().trim();
obj2 = ((String) obj2).toLowerCase().trim();
if (!StringUtils.isEmpty((String) obj1) && !StringUtils.isEmpty((String) obj2)) {
if (StringUtils.isNumeric((String) obj1) && StringUtils.isNumeric((String) obj2)) {
objectComparator = Comparator.comparingDouble(o -> new Double(String.valueOf(o)));
}
}
}
if (objectComparator == null) {
objectComparator = Comparator.naturalOrder();
}
//noinspection unchecked
return Comparator.nullsLast(objectComparator).compare(obj1, obj2);
}
示例8: findObjectInList
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked" })
private Object findObjectInList(final Object target, final String each) {
boolean isList = (target instanceof List);
if (!isList) {
throw new IllegalArgumentException(String.format(
"您提供的配置文件有误. 路径[%s]需要配置Json格式的Map对象,但该节点发现实际类型是[%s]. 请检查您的配置并作出修改.",
each, target.getClass().toString()));
}
String index = each.replace("[", "").replace("]", "");
if (!StringUtils.isNumeric(index)) {
throw new IllegalArgumentException(
String.format(
"系统编程错误,列表下标必须为数字类型,但该节点发现实际类型是[%s] ,该异常代表系统编程错误, 请联系DataX开发团队 !",
index));
}
return ((List<Object>) target).get(Integer.valueOf(index));
}
示例9: checkParam
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public List<EventInfo> checkParam(CheckParameter checkParameter) {
List<EventInfo> result = new LinkedList<EventInfo>();
String hostName = (String) checkParameter.getParam("hostname");
JsonObject config = Config.getConfig().getAlgorithmConfig();
if (!isModuleIgnore(config, CONFIG_KEY_SSRF_INTRANET)
&& (hostName.endsWith(".xip.io") || hostName.endsWith(".burpcollaborator.net") || hostName.endsWith(".xip.name"))) {
result.add(AttackInfo.createLocalAttackInfo(checkParameter,
getActionElement(config, CONFIG_KEY_SSRF_INTRANET), "访问已知的内网探测域名"));
} else if (!isModuleIgnore(config, CONFIG_KEY_SSRF_AWS)
&& hostName.equals("169.254.169.254")) {
result.add(AttackInfo.createLocalAttackInfo(checkParameter,
getActionElement(config, CONFIG_KEY_SSRF_AWS), "尝试读取 AWS metadata"));
} else if (!isModuleIgnore(config, CONFIG_KEY_SSRF_COMMON)
&& StringUtils.isNumeric(hostName)) {
result.add(AttackInfo.createLocalAttackInfo(checkParameter,
getActionElement(config, CONFIG_KEY_SSRF_COMMON), "尝试使用纯数字IP"));
} else if (!isModuleIgnore(config, CONFIG_KEY_SSRF_OBFUSCATE)
&& hostName.startsWith("0x") && !hostName.contains(".")) {
result.add(AttackInfo.createLocalAttackInfo(checkParameter,
getActionElement(config, CONFIG_KEY_SSRF_OBFUSCATE), "尝试使用16进制IP"));
}
List<EventInfo> jsResults = new JsChecker().checkParam(checkParameter);
if (jsResults != null && jsResults.size() > 0) {
result.addAll(jsResults);
}
return result;
}
示例10: createImage
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void createImage(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("image/jpeg");
/*
* 得到参数高,宽,都为数字时,则使用设置高宽,否则使用默认值
*/
String width = request.getParameter("width");
String height = request.getParameter("height");
if (StringUtils.isNumeric(width) && StringUtils.isNumeric(height)) {
w = NumberUtils.toInt(width);
h = NumberUtils.toInt(height);
}
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
/*
* 生成背景
*/
createBackground(g);
/*
* 生成字符
*/
String s = createCharacter(g);
request.getSession().setAttribute(VALIDATE_CODE, s);
g.dispose();
OutputStream out = response.getOutputStream();
ImageIO.write(image, "JPEG", out);
out.close();
}
示例11: getChildElementIndex
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Returns the index of the child element xpath
* i.e. /suspension_rec[3] returns 3. /suspension_rec defaults to 1
*
* @param xpath
* @return 1, the index, or null if the provided xpath is empty
*/
public static Integer getChildElementIndex(String xpath) {
if (StringUtils.isEmpty(xpath)) {
return null;
}
if (xpath.endsWith(R_BRACKET)) {
String value = xpath.substring(xpath.lastIndexOf(L_BRACKET) + 1, xpath.lastIndexOf(R_BRACKET));
if (StringUtils.isNumeric(value)) {
return Integer.valueOf(value);
}
}
return 1;
}
示例12: execute
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent e) {
if (C.hasRole(e.getMember(), Roles.HELPER)) {
if (!e.getArgs().isEmpty() && StringUtils.isNumeric(e.getArgs())) {
int id = Integer.parseInt(e.getArgs());
if (warningManager.isValidWarning(id)) {
User tUser = Main.getJda().getUserById(warningManager.getWarnTargetId(id));
Channels.LOG.getChannel().sendMessage(new EmbedBuilder()
.setAuthor(e.getMember().getUser().getName() + "#" + e.getMember().getUser().getDiscriminator(), null, e.getMember().getUser().getAvatarUrl())
.setColor(Color.YELLOW)
.setThumbnail(tUser.getAvatarUrl())
.setDescription(":information_source: **Warning Deleted**\n" + "⚠ " + C.bold("Warned " + tUser.getName() + "#" + tUser.getDiscriminator()) + "\n:page_facing_up: " + C.bold("Reason: ") + warningManager.getWarnReason(id) + "\n:id: **Warn ID** " + String.valueOf(id))
.build()).queue();
if (warningManager.deleteWarning(id)) {
e.reply("Deleted warning!");
} else {
e.reply("Warning could not be deleted!");
}
} else {
e.replyError("Invalid Warning!");
}
} else {
e.replyError("**Correct Usage:** ^" + name + " <warning ID>");
}
} else {
e.reply(C.permMsg(Roles.HELPER));
}
}
示例13: getPermissionFromOctalField
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Permission value from input field.
*
* @return Null if invalid string has been entered entered,
*/
private Permission getPermissionFromOctalField() {
if(StringUtils.isNotBlank(octalField.stringValue())) {
if(StringUtils.length(octalField.stringValue()) >= 3) {
if(StringUtils.isNumeric(octalField.stringValue())) {
return new Permission(Integer.valueOf(octalField.stringValue()).intValue());
}
}
}
log.warn(String.format("Invalid octal field input %s", octalField.stringValue()));
return null;
}
示例14: getPageSize
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
*
* @param request
* @return
*/
public static Integer getPageSize(HttpServletRequest request) {
String pageSize = request.getParameter("pageSize");
if (StringUtils.isNotBlank(pageSize) && StringUtils.isNumeric(pageSize)) {
return Integer.parseInt(pageSize);
}
return null;
}
示例15: getGroupGivenId
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public Response getGroupGivenId(String id) {
if (StringUtils.isEmpty(id) || !StringUtils.isNumeric(id)) {
return Response.status(Response.Status.NO_CONTENT).build();
}
long groupID = Long.parseLong(id);
Group group = getGroup(groupID);
return Response.status(Response.Status.OK).entity(getGroupResponse(group)).build();
}