當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。