当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.isNumeric方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:24,代码来源:DayOfWeekDescriptionBuilder.java

示例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);
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:17,代码来源:GfaFile.java

示例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;
}
 
开发者ID:edylle,项目名称:pathological-reports,代码行数:19,代码来源:OwnerController.java

示例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);
    }
}
 
开发者ID:linuer,项目名称:nan,代码行数:19,代码来源:FDateJsonDeserializer.java

示例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;
}
 
开发者ID:txgs888,项目名称:McrmbCore_Sponge,代码行数:22,代码来源:GiveCommand.java

示例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);
    }
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:24,代码来源:JSONGeometryMapper.java

示例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);
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:34,代码来源:XmlElementPathBeanComparator.java

示例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));
}
 
开发者ID:yaogdu,项目名称:datax,代码行数:20,代码来源:Configuration.java

示例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;
}
 
开发者ID:baidu,项目名称:openrasp,代码行数:31,代码来源:SSRFChecker.java

示例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();

	}
 
开发者ID:funtl,项目名称:framework,代码行数:38,代码来源:ValidateCodeServlet.java

示例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;
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:21,代码来源:XPathUtils.java

示例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));
    }
}
 
开发者ID:WheezyGold7931,项目名称:happybot,代码行数:29,代码来源:DeleteWarnCommand.java

示例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;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:17,代码来源:InfoController.java

示例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;
}
 
开发者ID:xujeff,项目名称:tianti,代码行数:15,代码来源:WebHelper.java

示例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();
}
 
开发者ID:tosinoni,项目名称:SECP,代码行数:11,代码来源:GroupController.java


注:本文中的org.apache.commons.lang3.StringUtils.isNumeric方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。