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


Java NumberUtils.isDigits方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.math.NumberUtils.isDigits方法的典型用法代码示例。如果您正苦于以下问题:Java NumberUtils.isDigits方法的具体用法?Java NumberUtils.isDigits怎么用?Java NumberUtils.isDigits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.math.NumberUtils的用法示例。


在下文中一共展示了NumberUtils.isDigits方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCurrentPageNum

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * Gets the request page number from the specified path.
 *
 * @param path
 *            the specified path, see {@link #PAGINATION_PATH_PATTERN} for
 *            the details
 * @return page number, returns {@code 1} if the specified request URI can
 *         not convert to an number
 * @see #PAGINATION_PATH_PATTERN
 */
public static int getCurrentPageNum(final String path) {
	logger.trace("Getting current page number[path={}]", path);

	if (StringUtils.isBlank(path) || path.equals("/")) {
		return 1;
	}

	final String currentPageNumber = path.split("/")[0];

	if (!NumberUtils.isDigits(currentPageNumber)) {
		return 1;
	}

	return Integer.valueOf(currentPageNumber);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:26,代码来源:Requests.java

示例2: getPageSize

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * Gets the request page size from the specified path.
 *
 * @param path
 *            the specified path, see {@link #PAGINATION_PATH_PATTERN} for
 *            the details
 * @return page number, returns {@value #DEFAULT_PAGE_SIZE} if the specified
 *         request URI can not convert to an number
 * @see #PAGINATION_PATH_PATTERN
 */
public static int getPageSize(final String path) {
	logger.trace("Page number[string={}]", path);

	if (StringUtils.isBlank(path)) {
		return DEFAULT_PAGE_SIZE;
	}

	final String[] parts = path.split("/");

	if (1 >= parts.length) {
		return DEFAULT_PAGE_SIZE;
	}

	final String pageSize = parts[1];

	if (!NumberUtils.isDigits(pageSize)) {
		return DEFAULT_PAGE_SIZE;
	}

	return Integer.valueOf(pageSize);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:32,代码来源:Requests.java

示例3: getWindowSize

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * Gets the request window size from the specified path.
 *
 * @param path
 *            the specified path, see {@link #PAGINATION_PATH_PATTERN} for
 *            the details
 * @return page number, returns {@value #DEFAULT_WINDOW_SIZE} if the
 *         specified request URI can not convert to an number
 * @see #PAGINATION_PATH_PATTERN
 */
public static int getWindowSize(final String path) {
	logger.trace("Page number[string={}]", path);

	if (StringUtils.isBlank(path)) {
		return DEFAULT_WINDOW_SIZE;
	}

	final String[] parts = path.split("/");

	if (2 >= parts.length) {
		return DEFAULT_WINDOW_SIZE;
	}

	final String windowSize = parts[2];

	if (!NumberUtils.isDigits(windowSize)) {
		return DEFAULT_WINDOW_SIZE;
	}

	return Integer.valueOf(windowSize);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:32,代码来源:Requests.java

示例4: valideerWaardeEnDataTypeKomenOvereen

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
private void valideerWaardeEnDataTypeKomenOvereen(final AttribuutElement attribuutElement, final String waarde, final Set<Melding> meldingen) {
    final ElementBasisType datatype = attribuutElement.getDatatype();
    boolean logMelding = false;
    if (datatype == ElementBasisType.DATUMTIJD) {
        try {
            datumService.parseDateTime(waarde);
        } catch (StapMeldingException e) {
            LOGGER.debug("datum tijd in zoekcriteria niet geldig", e);
            logMelding = true;
        }
    } else if (datatype == ElementBasisType.BOOLEAN) {
        if (!"n".equalsIgnoreCase(waarde) && !"j".equalsIgnoreCase(waarde)) {
            logMelding = true;
        }
    } else if (attribuutElement.isGetal() && !NumberUtils.isDigits(waarde)) {
        logMelding = true;
    }

    if (logMelding) {
        LOGGER.debug(String.format(FOUT_MELDING, Regel.R2308.toString(), attribuutElement.getElementNaam()));
        meldingen.add(new Melding(Regel.R2308));
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:24,代码来源:ValideerZoekCriteriaServiceImpl.java

示例5: invalidUserDefinedPermalinkFormat

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * Checks whether the specified user-defined permalink is invalid on format.
 * 
 * @param permalink
 *            the specified user-defined permalink
 * @return {@code true} if invalid, returns {@code false} otherwise
 */
private static boolean invalidUserDefinedPermalinkFormat(final String permalink) {
	if (StringUtils.isBlank(permalink)) {
		return true;
	}

	if (isReservedLink(permalink)) {
		return true;
	}
	if (NumberUtils.isDigits(permalink.substring(1))) {
		// See issue 120
		// (http://code.google.com/p/b3log-solo/issues/detail?id=120#c4) for
		// more details
		return true;
	}

	int slashCnt = 0;

	for (int i = 0; i < permalink.length(); i++) {
		if ('/' == permalink.charAt(i)) {
			slashCnt++;
		}

		if (slashCnt > 1) {
			return true;
		}
	}

	return !UrlValidator.getInstance().isValid(Latkes.getServer() + permalink);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:37,代码来源:PermalinkQueryService.java

示例6: getValueFieldNameFromRange

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * @param from from value
 * @param to to value
 * @return either "properties.vn" if one of the range limits is a number, or "properties.v" otherwise.
 */
static String getValueFieldNameFromRange(String from, String to) {
	if (("*".equals(from) && "*".equals(to)) || NumberUtils.isDigits(from) || NumberUtils.isDigits(to)) {
		return PROPS_PREFIX + "vn";
	}
	return PROPS_PREFIX + "v";
}
 
开发者ID:Erudika,项目名称:para-search-elasticsearch,代码行数:12,代码来源:ElasticSearchUtils.java

示例7: GitVersion

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
public GitVersion(String versionStr) {
	for (String each: LoaderUtils.splitAndTrim(versionStr, ".")) {
		if (NumberUtils.isDigits(each))
			parts.add(Integer.valueOf(each));
		else if (each.equals("msysgit"))
			msysgit = true;
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:9,代码来源:GitVersion.java

示例8: parseFileId

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * Retrieves BiologicalDataItemID for a file from an input String.
 * If input String might be interpreted as a number, this number will be returned as a result.
 * If input String isn't a number, method interprets it as a file name and tries to find a file
 * with such a name in the NGB server and retrieves its ID from a loaded data.
 * @param strId input String for file identification
 * @return BiologicalDataItemID of a file
 * @throws ApplicationException if method fails to find a file
 */
protected Long parseFileId(String strId) {
    if (NumberUtils.isDigits(strId)) {
        return Long.parseLong(strId);
    } else {
        List<BiologicalDataItem> items = loadItemsByName(strId);
        if (items == null || items.isEmpty()) {
            throw new ApplicationException(getMessage(ERROR_FILE_NOT_FOUND, strId));
        }
        if (items.size() > 1) {
            LOGGER.error(getMessage(SEVERAL_RESULTS_FOR_QUERY, strId));
        }
        return items.get(0).getBioDataItemId();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:24,代码来源:AbstractHTTPCommandHandler.java

示例9: loadFileByNameOrBioID

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * Loads BiologicalDataItem file from NGB server by an input String.
 * If input String might be interpreted as a number, item will be loaded by BiologicalDataItemID.
 * If input String isn't a number, method interprets it as a file name and tries to find a file
 * with such a name in the NGB server.
 * @param strId input String for file identification
 * @return BiologicalDataItem representing file
 * @throws ApplicationException if method fails to find a file
 */
protected BiologicalDataItem loadFileByNameOrBioID(String strId) {
    if (NumberUtils.isDigits(strId)) {
        return loadFileByBioID(strId);
    } else {
        List<BiologicalDataItem> items = loadItemsByName(strId);
        if (items == null || items.isEmpty()) {
            throw new ApplicationException(getMessage(ERROR_FILE_NOT_FOUND, strId));
        }
        if (items.size() > 1) {
            LOGGER.error(getMessage(SEVERAL_RESULTS_FOR_QUERY, strId));
        }
        return items.get(0);
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:24,代码来源:AbstractHTTPCommandHandler.java

示例10: loadReferenceId

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * Retrieves reference ID from an input String.
 * If input String might be interpreted as a number, this number is assumed to be a BiologicalDataItemID
 * for a reference and thus a reference is loaded from the server by this BiologicalDataItemID.
 * If input String isn't a number, method interprets it as a file name, tries to find a reference
 * with such a name in the NGB server and retrieves its ID from a loaded data.
 * @param strId input String for reference identification
 * @return ID of a reference
 */
//TODO: remove this method and all connected logic when ID and BiologicalDataItemID are merged on the server
protected Long loadReferenceId(String strId) {
    if (NumberUtils.isDigits(strId)) {
        BiologicalDataItem reference = loadFileByBioID(strId);
        return reference.getId();
    } else {
        List<BiologicalDataItem> items = loadItemsByName(strId);
        checkLoadedItems(strId, items);
        return items.get(0).getId();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:21,代码来源:AbstractHTTPCommandHandler.java

示例11: parseProjectId

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * Retrieves ID for a dataset(project) from an input String.
 * If input String might be interpreted as a number, this number will be returned as a result.
 * If input String isn't a number, method interprets it as a dataset name and tries to find a file
 * with such a name in the NGB server and retrieves its ID from a loaded data.
 * @param strId input String for dataset identification
 * @return ID of a dataset
 */
protected Long parseProjectId(String strId) {
    if (NumberUtils.isDigits(strId)) {
        return Long.parseLong(strId);
    } else {
        Project project = loadProjectByName(strId);
        return project.getId();
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:17,代码来源:AbstractHTTPCommandHandler.java

示例12: parseAndVerifyArguments

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
@Override
public void parseAndVerifyArguments(List<String> arguments, ApplicationOptions options) {
    if (CollectionUtils.isEmpty(arguments)) {
        throw new IllegalArgumentException(MessageConstants
                .getMessage(MINIMUM_COMMAND_ARGUMENTS, getCommand(), 1, arguments.size()));
    }

    dataset = arguments.get(0);
    ids = arguments.subList(1, arguments.size());

    printJson = options.isPrintJson();
    printTable = options.isPrintTable();

    String location = options.getLocation();
    if (StringUtils.isNoneBlank(location)) {
        String[] parts = location.split(":");
        chrName = parts[0];

        if (parts.length > 1 && parts[1].contains("-")) {
            String[] subParts = parts[1].split("-");
            if (NumberUtils.isDigits(subParts[0])) {
                startIndex = Integer.parseInt(subParts[0]);
            }
            if (NumberUtils.isDigits(subParts[1])) {
                endIndex = Integer.parseInt(subParts[1]);
            }
        }
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:30,代码来源:UrlGeneratorHandler.java

示例13: execute

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * 执行FTP回调操作的方法
 *
 * @param <T>      the type parameter
 * @param callback 回调的函数
 * @return the t
 * @throws IOException the io exception
 */
public <T> T execute(FTPClientCallback<T> callback) throws IOException {
    FTPClient ftp = new FTPClient();
    try {
        //登录FTP服务器
        try {
            //设置超时时间
            ftp.setDataTimeout(7200);
            //设置默认编码
            ftp.setControlEncoding(DEAFULT_REMOTE_CHARSET);
            //设置默认端口
            ftp.setDefaultPort(DEAFULT_REMOTE_PORT);
            //设置是否显示隐藏文件
            ftp.setListHiddenFiles(false);
            //连接ftp服务器
            if (StringUtils.isNotEmpty(port) && NumberUtils.isDigits(port)) {
                ftp.connect(host, Integer.valueOf(port));
            } else {
                ftp.connect(host);
            }
        } catch (ConnectException e) {
            logger.error("连接FTP服务器失败:" + ftp.getReplyString() + ftp.getReplyCode());
            throw new IOException("Problem connecting the FTP-server fail", e);
        }
        //得到连接的返回编码
        int reply = ftp.getReplyCode();

        if (!FTPReply.isPositiveCompletion(reply)) {
            ftp.disconnect();
        }
        //登录失败权限验证失败
        if (!ftp.login(getUsername(), getPassword())) {
            ftp.quit();
            ftp.disconnect();
            logger.error("连接FTP服务器用户或者密码失败::" + ftp.getReplyString());
            throw new IOException("Cant Authentificate to FTP-Server");
        }
        if (logger.isDebugEnabled()) {
            logger.info("成功登录FTP服务器:" + host + " 端口:" + port);
        }
        ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
        //回调FTP的操作
        return callback.doTransfer(ftp);
    } finally {
        //FTP退出
        ftp.logout();
        //断开FTP连接
        if (ftp.isConnected()) {
            ftp.disconnect();
        }
    }
}
 
开发者ID:numsg,项目名称:spring-boot-seed,代码行数:60,代码来源:FTPClientImpl.java

示例14: exactVersionNo

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
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);
    }
 
开发者ID:mgtechsoftware,项目名称:smockin,代码行数:14,代码来源:GeneralUtils.java

示例15: getValueFieldName

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * @param v search term
 * @return the name of the value property inside a nested object, e.g. "properties.v"
 */
static String getValueFieldName(String v) {
	return PROPS_PREFIX + (NumberUtils.isDigits(v) ? "vn" : "v");
}
 
开发者ID:Erudika,项目名称:para-search-elasticsearch,代码行数:8,代码来源:ElasticSearchUtils.java


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