org.apache.commons.lang3.math.NumberUtils#isDigits ( )源码实例Demo

下面列出了org.apache.commons.lang3.math.NumberUtils#isDigits ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: elucidate-server   文件: SelectorUtils.java
public static XYWHFragmentSelector extractXywhFragmentSelector(String str) {

        if (StringUtils.isNotBlank(str)) {

            Matcher matcher = XYWH_MATCHER.matcher(str);
            if (matcher.find()) {

                String xStr = matcher.group(1);
                String yStr = matcher.group(2);
                String wStr = matcher.group(3);
                String hStr = matcher.group(4);

                if (NumberUtils.isDigits(xStr) && NumberUtils.isDigits(yStr) && NumberUtils.isDigits(wStr) && NumberUtils.isDigits(hStr)) {

                    XYWHFragmentSelector xywhFragmentSelector = new XYWHFragmentSelector();
                    xywhFragmentSelector.setX(Integer.parseInt(xStr));
                    xywhFragmentSelector.setY(Integer.parseInt(yStr));
                    xywhFragmentSelector.setW(Integer.parseInt(wStr));
                    xywhFragmentSelector.setH(Integer.parseInt(hStr));
                    return xywhFragmentSelector;
                }
            }

        }
        return null;
    }
 
源代码2 项目: wind-im   文件: SiteConfig.java
/**
 * <pre>
 * 1天
 * 7天
 * 14天
 * </pre>
 * 
 * @return
 */
public static int getGroupQRExpireDay() {
	int expireDay = 14;
	Map<Integer, String> map = getConfigMap();
	if (map != null) {
		String value = map.get(ConfigProto.ConfigKey.GROUP_QR_EXPIRE_TIME_VALUE);
		if (NumberUtils.isDigits(value)) {
			int day = Integer.valueOf(value);
			if (day == 1 || day == 7 || day == 14) {
				return day;
			}
		}
	}
	return expireDay;
}
 
源代码3 项目: jvm-sandbox-repeater   文件: TraceGenerator.java
public static boolean isValid(String traceId) {
    if (StringUtils.isBlank(traceId)) {
        return false;
    }
    if (traceId.length() != 32 && !traceId.endsWith(END_FLAG)) {
        return false;
    }
    return NumberUtils.isDigits(traceId.substring(25, 30));
}
 
源代码4 项目: chat-socket   文件: MainPresenter.java
private boolean verifyInputs() {
    String listenOnIp = view.getIp();
    String portAsString = view.getPort();
    if (!NumberUtils.isDigits(portAsString)) {
        postMessageBox("Port must be a number", MessageType.Error);
        return false;
    } else if (StringUtils.isEmpty(listenOnIp)) {
        postMessageBox("Ip must be not empty", MessageType.Error);
        return false;
    }
    return true;
}
 
源代码5 项目: prebid-server-java   文件: VideoResponseFactory.java
private List<ExtAdPod> adPodsWithTargetingFrom(List<Bid> bids) {
    final List<ExtAdPod> adPods = new ArrayList<>();
    for (Bid bid : bids) {
        final Map<String, String> targeting = targeting(bid);
        if (targeting.get("hb_uuid") == null) {
            continue;
        }
        final String impId = bid.getImpid();
        final String podIdString = impId.split("_")[0];
        if (!NumberUtils.isDigits(podIdString)) {
            continue;
        }
        final Integer podId = Integer.parseInt(podIdString);

        final ExtResponseVideoTargeting videoTargeting = ExtResponseVideoTargeting.of(
                targeting.get("hb_pb"),
                targeting.get("hb_pb_cat_dur"),
                targeting.get("hb_uuid"));

        ExtAdPod adPod = adPods.stream()
                .filter(extAdPod -> extAdPod.getPodid().equals(podId))
                .findFirst()
                .orElse(null);

        if (adPod == null) {
            adPod = ExtAdPod.of(podId, new ArrayList<>(), null);
            adPods.add(adPod);
        }
        adPod.getTargeting().add(videoTargeting);
    }
    return adPods;
}
 
源代码6 项目: elucidate-server   文件: SelectorUtils.java
public static TFragmentSelector extractTFragmentSelector(String str) {

        if (StringUtils.isNotBlank(str)) {

            Matcher matcher = T_MATCHER.matcher(str);
            if (matcher.find()) {

                String startStr = matcher.group(1);
                String endStr = matcher.group(3);

                if (StringUtils.isBlank(startStr) && StringUtils.isNotBlank(endStr)) {
                    startStr = Integer.toString(0);
                } else if (StringUtils.isNotBlank(startStr) && StringUtils.isBlank(endStr)) {
                    endStr = Integer.toString(Integer.MAX_VALUE);
                }

                if (NumberUtils.isDigits(startStr) && NumberUtils.isDigits(endStr)) {

                    TFragmentSelector tFragmentSelector = new TFragmentSelector();
                    tFragmentSelector.setStart(Integer.parseInt(startStr));
                    tFragmentSelector.setEnd(Integer.parseInt(endStr));
                    return tFragmentSelector;
                }
            }
        }
        return null;
    }
 
源代码7 项目: icure-backend   文件: FuzzyValues.java
/**
 * Indicates if the submitted text has the format of a SSIN. <br/>
 * It does <b>NOT</b> check if the SSIN is valid!
 */
public static boolean isSsin(String text) {
	if (!NumberUtils.isDigits(text) || text.length() != 11) {
		return false;
	}
	BigInteger checkDigits = new BigInteger(text.substring(9));
	BigInteger big97 = new BigInteger("97");
	BigInteger modBefore2000 = new BigInteger(text.substring(0, 9)).mod(big97);
	BigInteger modAfter2000 = new BigInteger("2" + text.substring(0, 9)).mod(big97);

	return big97.subtract(modBefore2000).equals(checkDigits) || big97.subtract(modAfter2000).equals(checkDigits);
}
 
源代码8 项目: para   文件: Constraint.java
/**
 * The 'digits' constraint - field must be a {@link Number} or {@link String} containing digits where the
 * number of digits in the integral part is limited by 'integer', and the
 * number of digits for the fractional part is limited
 * by 'fraction'.
 * @param integer the max number of digits for the integral part
 * @param fraction the max number of digits for the fractional part
 * @return constraint
 */
public static Constraint digits(final Number integer, final Number fraction) {
	return new Constraint("digits", digitsPayload(integer, fraction)) {
		public boolean isValid(Object actualValue) {
			if (actualValue != null) {
				if (!((actualValue instanceof Number) || (actualValue instanceof String))) {
					return false;
				} else {
					if (integer != null && fraction != null) {
						String val = actualValue.toString();
						String[] split = val.split("[,.]");
						if (!NumberUtils.isDigits(split[0])) {
							return false;
						}
						if (integer.intValue() < split[0].length()) {
							return false;
						}
						if (split.length > 1 && fraction.intValue() < split[1].length()) {
							return false;
						}
					}
				}
			}
			return true;
		}
	};
}
 
源代码9 项目: smockin   文件: RuleEngineUtils.java
static Integer extractJSONFieldListPosition(final String field) {

        int bracketStart = field.indexOf("[");
        final String positionStr = field.substring( (bracketStart + 1), (field.length() - 1) );

        if (!NumberUtils.isDigits(positionStr)) {
            return null;
        }

        return Integer.valueOf(positionStr);
    }
 
源代码10 项目: meghanada-server   文件: ClassNameUtils.java
public static boolean isAnonymousClass(final String name) {
  if (!name.contains(INNER_MARK)) {
    return false;
  }
  final int i = name.lastIndexOf(INNER_MARK);
  if (i < name.length()) {
    final String s = name.substring(i + 1);
    return NumberUtils.isDigits(s);
  }
  return false;
}
 
源代码11 项目: systemsgenetics   文件: VcfAnnotation.java
public static VcfAnnotation fromVcfInfo(VcfMetaInfo info)
{
	Annotation.Type type = VcfAnnotation.toAnnotationType(info.getType());

	Integer number = null;
	boolean unbounded = false;
	boolean perAltAllele = false;
	boolean perGenotype = false;

	// Number can be A -> field has one value per alternate allele
	// Or G -> the field has one value for each possible genotype
	// Or . -> is unknown, or is unbounded
	// Or an Integer
	if (info.getNumber() != null)
	{
		if (info.getNumber().equalsIgnoreCase("A"))
		{
			perAltAllele = true;
		}
		else if (info.getNumber().equalsIgnoreCase("G"))
		{
			perGenotype = true;
		}
		else if (info.getNumber().equals("."))
		{
			unbounded = true;
		}
		else if (NumberUtils.isDigits(info.getNumber()))
		{
			number = Integer.parseInt(info.getNumber());
		}
	}

	return new VcfAnnotation(info.getId(), info.getDescription(), type, number, unbounded, perAltAllele,
			perGenotype);
}
 
源代码12 项目: drftpd   文件: IMDBParser.java
private boolean getInfo() {
    try {
        String url = _url + "/reference";

        String data = HttpUtils.retrieveHttpAsString(url);

        if (!data.contains("<meta property='og:type' content=\"video.movie\" />")) {
            logger.warn("Request for IMDB info for a Tv Show, this is not handled by this plugin. URL:{}", url);
            return false;
        }

        _title = parseData(data, "<meta property='og:title' content=\"", "(");
        _language = parseData(data, "<td class=\"ipl-zebra-list__label\">Language</td>", "</td>").replaceAll("\\s{2,}", "|");
        _country = parseData(data, "<td class=\"ipl-zebra-list__label\">Country</td>", "</td>").replaceAll("\\s{2,}", "|");
        _genres = parseData(data, "<td class=\"ipl-zebra-list__label\">Genres</td>", "</td>").replaceAll("\\s{2,}", "|");
        _director = parseData(data, "<div class=\"titlereference-overview-section\">\\n\\s+Directors?:", "</div>", false, true).replaceAll("\\s+?,\\s+?", "|");
        String rating = parseData(data, "<span class=\"ipl-rating-star__rating\">", "</span>");
        if (!rating.equals("N|A") && (rating.length() == 1 || rating.length() == 3) && NumberUtils.isDigits(rating.replaceAll("\\D", ""))) {
            _rating = Integer.valueOf(rating.replaceAll("\\D", ""));
            if (rating.length() == 1) {
                // Rating an even(single digit) number, multiply by 10
                _rating = _rating * 10;
            }
            String votes = parseData(data, "<span class=\"ipl-rating-star__total-votes\">", "</span>");
            if (!votes.equals("N|A") && NumberUtils.isDigits(votes.replaceAll("\\D", "")))
                _votes = Integer.valueOf(votes.replaceAll("\\D", ""));
        }
        _plot = parseData(data, "<section class=\"titlereference-section-overview\">", "</div>", true, true);
        Pattern p = Pattern.compile("<a href=\"/title/tt\\d+/releaseinfo\">\\d{2} [a-zA-Z]{3} (\\d{4})");
        Matcher m = p.matcher(data);
        if (m.find() && NumberUtils.isDigits(m.group(1))) {
            _year = Integer.valueOf(m.group(1));
        }
        String runtime = parseData(data, "<td class=\"ipl-zebra-list__label\">Runtime</td>", "</td>");
        if (!runtime.equals("N|A") && NumberUtils.isDigits(runtime.replaceAll("\\D", ""))) {
            _runtime = Integer.valueOf(runtime.replaceAll("\\D", ""));
        }
    } catch (Exception e) {
        logger.error("", e);
        return false;
    }
    return true;
}
 
源代码13 项目: blockchain-java   文件: CLI.java
/**
 * 命令行解析入口
 */
public void parse() {
    this.validateArgs(args);
    try {
        CommandLineParser parser = new DefaultParser();
        CommandLine cmd = parser.parse(options, args);
        switch (args[0]) {
            case "createblockchain":
                String createblockchainAddress = cmd.getOptionValue("address");
                if (StringUtils.isBlank(createblockchainAddress)) {
                    help();
                }
                this.createBlockchain(createblockchainAddress);
                break;
            case "getbalance":
                String getBalanceAddress = cmd.getOptionValue("address");
                if (StringUtils.isBlank(getBalanceAddress)) {
                    help();
                }
                this.getBalance(getBalanceAddress);
                break;
            case "send":
                String sendFrom = cmd.getOptionValue("from");
                String sendTo = cmd.getOptionValue("to");
                String sendAmount = cmd.getOptionValue("amount");
                if (StringUtils.isBlank(sendFrom) ||
                        StringUtils.isBlank(sendTo) ||
                        !NumberUtils.isDigits(sendAmount)) {
                    help();
                }
                this.send(sendFrom, sendTo, Integer.valueOf(sendAmount));
                break;
            case "createwallet":
                this.createWallet();
                break;
            case "printaddresses":
                this.printAddresses();
                break;
            case "printchain":
                this.printChain();
                break;
            case "h":
                this.help();
                break;
            default:
                this.help();
        }
    } catch (Exception e) {
        log.error("Fail to parse cli command ! ", e);
    } finally {
        RocksDBUtils.getInstance().closeDB();
    }
}
 
源代码14 项目: chat-socket   文件: ConnectionPresenter.java
private boolean verifyInputs() {
    String serverIp = view.getServerIp();
    String serverPortAsString = view.getServerPort();
    return !StringUtils.isEmpty(serverIp) && NumberUtils.isDigits(serverPortAsString);
}
 
源代码15 项目: bookish   文件: DataTable.java
public void parseCSV(String csv) {
	try {
		Reader in = new StringReader(csv);
		CSVFormat format = CSVFormat.EXCEL.withHeader();
		CSVParser parser = format.parse(in);
		this.firstColIsIndex = false;
		for (CSVRecord record : parser) {
			if ( !firstColIsIndex && Character.isAlphabetic(record.get(0).charAt(0)) ) {
				// latch if we see alpha not number
				firstColIsIndex = true;
			}
			List<String> row = new ArrayList<>();
			for (int i = 0; i<record.size(); i++) {
				String v = record.get(i);
				boolean isInt = false;
				try {
					Integer.parseInt(v);
					isInt = true;
				}
				catch (NumberFormatException nfe) {
					isInt = false;
				}
				if ( !isInt && !NumberUtils.isDigits(v) && NumberUtils.isCreatable(v) ) {
					v = String.format("%.4f",Precision.round(Double.valueOf(v), 4));
				}
				else {
					v = abbrevString(v, 25);
				}
				row.add(v);
			}
			rows.add(row);
		}
		Set<String> colNames = parser.getHeaderMap().keySet();
		if ( !firstColIsIndex ) {
			colNames.remove(""); // remove index column name
		}
		this.colNames.addAll(colNames);
	}
	catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
源代码16 项目: Kettle   文件: HelpCommand.java
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) return true;

    String command;
    int pageNumber;
    int pageHeight;
    int pageWidth;

    if (args.length == 0) {
        command = "";
        pageNumber = 1;
    } else if (NumberUtils.isDigits(args[args.length - 1])) {
        command = StringUtils.join(ArrayUtils.subarray(args, 0, args.length - 1), " ");
        try {
            pageNumber = NumberUtils.createInteger(args[args.length - 1]);
        } catch (NumberFormatException exception) {
            pageNumber = 1;
        }
        if (pageNumber <= 0) {
            pageNumber = 1;
        }
    } else {
        command = StringUtils.join(args, " ");
        pageNumber = 1;
    }

    if (sender instanceof ConsoleCommandSender) {
        pageHeight = ChatPaginator.UNBOUNDED_PAGE_HEIGHT;
        pageWidth = ChatPaginator.UNBOUNDED_PAGE_WIDTH;
    } else {
        pageHeight = ChatPaginator.CLOSED_CHAT_PAGE_HEIGHT - 1;
        pageWidth = ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH;
    }

    HelpMap helpMap = Bukkit.getServer().getHelpMap();
    HelpTopic topic = helpMap.getHelpTopic(command);

    if (topic == null) {
        topic = helpMap.getHelpTopic("/" + command);
    }

    if (topic == null) {
        topic = findPossibleMatches(command);
    }

    if (topic == null || !topic.canSee(sender)) {
        sender.sendMessage(ChatColor.RED + "No help for " + command);
        return true;
    }

    ChatPaginator.ChatPage page = ChatPaginator.paginate(topic.getFullText(sender), pageNumber, pageWidth, pageHeight);

    StringBuilder header = new StringBuilder();
    header.append(ChatColor.YELLOW);
    header.append("--------- ");
    header.append(ChatColor.WHITE);
    header.append("Help: ");
    header.append(topic.getName());
    header.append(" ");
    if (page.getTotalPages() > 1) {
        header.append("(");
        header.append(page.getPageNumber());
        header.append("/");
        header.append(page.getTotalPages());
        header.append(") ");
    }
    header.append(ChatColor.YELLOW);
    for (int i = header.length(); i < ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH; i++) {
        header.append("-");
    }
    sender.sendMessage(header.toString());

    sender.sendMessage(page.getLines());

    return true;
}
 
源代码17 项目: webanno   文件: WebannoTsv1Reader.java
/**
 * Iterate through all lines and get available annotations<br>
 * First column is sentence number and a blank new line marks end of a sentence<br>
 * The Second column is the token <br>
 * The third column is the lemma annotation <br>
 * The fourth column is the POS annotation <br>
 * The fifth column is used for Named Entity annotations (Multiple annotations separeted by |
 * character) <br>
 * The sixth column is the origin token number of dependency parsing <br>
 * The seventh column is the function/type of the dependency parsing <br>
 * eighth and ninth columns are undefined currently
 */
private void setAnnotations(InputStream aIs, String aEncoding, StringBuilder text,
        Map<Integer, String> tokens, Map<Integer, String> pos, Map<Integer, String> lemma,
        Map<Integer, String> namedEntity, Map<Integer, String> dependencyFunction,
        Map<Integer, Integer> dependencyDependent, List<Integer> firstTokenInSentence)
    throws IOException
{
    int tokenNumber = 0;
    boolean first = true;
    int base = 0;

    LineIterator lineIterator = IOUtils.lineIterator(aIs, aEncoding);
    boolean textFound = false;
    StringBuilder tmpText = new StringBuilder();
    while (lineIterator.hasNext()) {
        String line = lineIterator.next().trim();
        if (line.startsWith("#text=")) {
            text.append(line.substring(6)).append("\n");
            textFound = true;
            continue;
        }
        if (line.startsWith("#")) {
            continue; // it is a comment line
        }
        int count = StringUtils.countMatches(line, "\t");
        if (line.isEmpty()) {
            continue;
        }
        if (count != 9) { // not a proper TSV file
            getUimaContext().getLogger().log(Level.INFO, "This is not a valid TSV File");
            throw new IOException(fileName + " This is not a valid TSV File");
        }
        StringTokenizer lineTk = new StringTokenizer(line, "\t");

        if (first) {
            tokenNumber = Integer.parseInt(line.substring(0, line.indexOf("\t")));
            firstTokenInSentence.add(tokenNumber);
            first = false;
        }
        else {
            int lineNumber = Integer.parseInt(line.substring(0, line.indexOf("\t")));
            if (lineNumber == 1) {
                base = tokenNumber;
                firstTokenInSentence.add(base);
            }
            tokenNumber = base + Integer.parseInt(line.substring(0, line.indexOf("\t")));
        }

        while (lineTk.hasMoreElements()) {
            lineTk.nextToken();
            String token = lineTk.nextToken();

            // for backward compatibility
            tmpText.append(token).append(" ");

            tokens.put(tokenNumber, token);
            lemma.put(tokenNumber, lineTk.nextToken());
            pos.put(tokenNumber, lineTk.nextToken());
            String ne = lineTk.nextToken();
            lineTk.nextToken();// make it compatible with prev WebAnno TSV reader
            namedEntity.put(tokenNumber, (ne.equals("_") || ne.equals("-")) ? "O" : ne);
            String dependentValue = lineTk.nextToken();
            if (NumberUtils.isDigits(dependentValue)) {
                int dependent = Integer.parseInt(dependentValue);
                dependencyDependent.put(tokenNumber, dependent == 0 ? 0 : base + dependent);
                dependencyFunction.put(tokenNumber, lineTk.nextToken());
            }
            else {
                lineTk.nextToken();
            }
            lineTk.nextToken();
            lineTk.nextToken();
        }
    }
    if (!textFound) {
        text.append(tmpText);
    }
}
 
源代码18 项目: icure-backend   文件: FuzzyValues.java
private static boolean isPartiallyFormedYYYYMMDD(String text) {
	return NumberUtils.isDigits(text) && text.matches("(\\d{4})(0?[1-9]|1[012])?(0?[1-9]|[12][0-9]|3[01])?");
}
 
源代码19 项目: apogen   文件: UtilsStaticAnalyzer.java
/**
 * BETA VERSION: trims the url of the web page, to get an meaningful name for
 * the PO test the correct use of last index of and extension removal
 * 
 * @param statesList
 * @throws MalformedURLException
 */
public static String getClassNameFromUrl(State state, List<State> statesList) throws MalformedURLException {

	// new add: check it does not lead to inconsistencies
	if (state.getStateId().equals("index")) {
		return toSentenceCase("index");
	}

	String s = state.getUrl();

	String toTrim = "";
	URL u = new URL(s);

	toTrim = u.toString();

	// retrieves the page name
	toTrim = toTrim.substring(toTrim.lastIndexOf('/') + 1, toTrim.length());
	// removes the php extension if any
	toTrim = toTrim.replace(".php", "");
	// removes the html extension if any
	toTrim = toTrim.replace(".html", "");
	// removes the & and ?
	if (toTrim.contains("?"))
		toTrim = toTrim.substring(0, toTrim.indexOf('?'));
	// camel case the string
	toTrim = toSentenceCase(toTrim);
	// check the uniqueness, solve the ambiguity otherwise
	toTrim = solveAmbiguity(toTrim, statesList);

	if (toTrim == "") {
		toTrim = u.getFile();

		// retrieves the page name
		toTrim = toTrim.substring(toTrim.lastIndexOf('/') + 1, toTrim.length());
		// removes the php extension if any
		toTrim = toTrim.replace(".php", "");
		// removes the html extension if any
		toTrim = toTrim.replace(".html", "");
		// removes the & and ?
		if (toTrim.contains("?"))
			toTrim = toTrim.substring(0, toTrim.indexOf('?'));
		// camel case the string
		toTrim = toSentenceCase(toTrim);
		// check the uniqueness, solve the ambiguity otherwise
		toTrim = solveAmbiguity(toTrim, statesList);

	}

	if (toTrim == "") {
		return toSentenceCase(state.getStateId());
	}

	if (NumberUtils.isNumber(toTrim) || NumberUtils.isDigits(toTrim)) {
		return toSentenceCase("PageObject_" + toTrim);
	}

	return toTrim;

}
 
源代码20 项目: smockin   文件: GeneralUtils.java
public static int exactVersionNo(String versionNo) {

        if (versionNo == null)
            throw new IllegalArgumentException("versionNo is not defined");

        versionNo = org.apache.commons.lang3.StringUtils.removeIgnoreCase(versionNo, "-SNAPSHOT");
        versionNo = org.apache.commons.lang3.StringUtils.remove(versionNo, ".");

        if (!NumberUtils.isDigits(versionNo))
            throw new IllegalArgumentException("extracted versionNo is not a valid number: " + versionNo);

        return Integer.valueOf(versionNo);
    }