参数检查
来源:互联网 发布:针织毛衣品牌推荐知乎 编辑:程序博客网 时间:2024/03/29 04:25
import java.math.BigDecimal;
public class CMNCMN0901U {
/**
* パラメータで渡された文字列の中にアルファベットの小文字が有れば、Trueを返す。
* @return アルファベットの小文字が有ったか否かを返す
* @param strInput 調べる対象の文字列
*/
public static boolean containLowerCase(String strInput) {
if (strInput == null) {
throw new CMNCMN0325X("strInput", null);
}
boolean blnReturn = false;
for (int i = 0; i < strInput.length(); i++) {
char ch = strInput.charAt(i);
if (ch >= 'a' && ch <= 'z') {
blnReturn = true;
break;
}else{
}
}
return blnReturn;
}
/**
* パラメータで渡された文字列の中にアルファベットの大文字が有れば、Trueを返す。
* @return アルファベットの大文字が有ったか否かを返す。
* @param strInput 調べる対象の文字列
*/
public static boolean containUpperCase(String strInput) {
if (strInput == null) {
throw new CMNCMN0325X("strInput", null);
}
boolean blnReturn = false;
for (int i = 0; i < strInput.length(); i++) {
char ch = strInput.charAt(i);
if (ch >= 'A' && ch <= 'Z') {
blnReturn = true;
break;
}
}
return blnReturn;
}
/**
* パラメータで渡された文字列の中に英字以外の文字列が有れば、Falseを返す。
* @return 英字以外の文字が有ったか否かを返す
* @param strInput 調べる対象の文字列
*/
public static boolean isAlpha(String strInput) {
if (strInput == null) {
throw new CMNCMN0325X("strInput", null);
}
boolean blnReturn = true;
for (int i = 0; i < strInput.length(); i++) {
char ch = strInput.charAt(i);
if ((ch >= 'A' && ch <= 'Z') ||
(ch >= 'a' && ch <= 'z')) {
}else{
blnReturn = false;
break;
}
}
return blnReturn;
}
/**
* パラメータで渡された文字列の中に英数字以外の文字列が有れば、Falseを返す。
* @return 英数字以外の文字が有ったか否かを返す
* @param strInput 調べる対象の文字列
*/
public static boolean isAlphaNum(String strInput) {
if (strInput == null) {
throw new CMNCMN0325X("strInput", null);
}
boolean blnReturn = true;
for (int i = 0; i < strInput.length(); i++) {
char ch = strInput.charAt(i);
if ((ch >= '0' && ch <= '9') ||
(ch >= 'A' && ch <= 'Z') ||
(ch >= 'a' && ch <= 'z')) {
}else{
blnReturn = false;
break;
}
}
return blnReturn;
}
/**
* パラメータで渡された文字列の中に英数字以外の文字列が有れば、Falseを返す。
* @return 英数字以外の文字が有ったか否かを返す
* @param strInput 調べる対象の文字列
*/
public static boolean isAlphaNumSpace(String strInput) {
if (strInput == null) {
throw new CMNCMN0325X("strInput", null);
}
boolean blnReturn = true;
for (int i = 0; i < strInput.length(); i++) {
char ch = strInput.charAt(i);
if ((ch >= '0' && ch <= '9') ||
(ch >= 'A' && ch <= 'Z') ||
(ch >= 'a' && ch <= 'z') ||
(ch == ' ')) {
}else{
blnReturn = false;
break;
}
}
return blnReturn;
}
/**
* パラメータで渡された文字列の中に空白以外の文字列がある場合はFalseを返す。
* @return 空白以外の文字が有ったか否かを返す。
* @param strInput 調べる対象の文字列
*/
public static boolean isBlank(String strInput) {
if (strInput == null) {
throw new CMNCMN0325X("strInput", null);
}
boolean blnReturn = true;
for (int i = 0; i < strInput.length(); i++) {
char ch = strInput.charAt(i);
if (Character.isWhitespace(ch)) {
}else{
blnReturn = false;
break;
}
}
return blnReturn;
}
/**
* パラメータで渡された文字列の中に数字以外の文字列が有れば、Falseを返す。
* @return 数字以外の文字が有ったか否かを返す
* @param strInput 調べる対象の文字列
*/
public static boolean isNum(String strInput) {
if (strInput == null) {
throw new CMNCMN0325X("strInput", null);
}
boolean blnReturn = true;
for (int i = 0; i < strInput.length(); i++) {
char ch = strInput.charAt(i);
if(ch >= '0' && ch <= '9'){
}else{
blnReturn = false;
break;
}
}
return blnReturn;
}
/**
* パラメータで渡された文字列が有効であるか否かを判定する。
* @return 有効なとき、true、無効なときfalse
* @param strInput 調べる対象の文字列
* @param iLength 整数部の桁数
* @param iScale 小数部の桁数
*/
public static boolean isNum(String strInput, int iLength, int iScale) {
if (strInput == null) {
throw new CMNCMN0325X("strInput", null);
}
try {
BigDecimal bdValue = new BigDecimal(strInput);
// 小数点以下の桁数のチェック
if (bdValue.scale() > iScale) {
return false;
}
// 整数部の桁数のチェック
if (bdValue.compareTo(new BigDecimal(Math.pow(10, iLength))) < 0) {
return true;
} else {
return false;
}
// 変換エラー時
} catch (NumberFormatException ex) {
return false;
}
}
}
- 参数检查
- 参数检查
- 检查传入参数
- 检查参数有效性
- Java参数检查
- Java 参数检查
- STM32入口参数检查
- 统一管理应用程序的参数检查
- 参数检查类的使用
- python 的 参数 静态检查
- NullPointerException 与 方法参数检查
- Elegant的函数参数检查
- Spring mvc自定义参数检查
- Python 参数检查模块: paramscheck
- 【Guava】参数检查工具包Preconditions
- 程序中参数的检查
- [收藏]C++ Tips(4)--参数的检查
- [收藏]C++ Tips(4)--参数的检查
- SCO UNIX快速入门
- java数据结构:链表与迭代器入门程序
- 共享锁与排他锁
- 日本某汽车公司开发项目
- blog开张
- 参数检查
- 落户CSDN勒。。
- 如何使用jacob将word转换为PDF
- Solaris网络课程认证 and 上海租房记
- 【自嘲】可怜的程序员
- org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)这个异常
- 巧用tmpfs加速你的linux服务器
- Jakarta POI 3.0
- Oracle的锁机制归纳总结