- 浏览: 78265 次
- 性别:
- 来自: 广州
文章分类
最新评论
public class PrecisionValidator extends BaseValidator { private PrecisionValidator() { } public static final int ORACLE_NUMBER_PRECISION_RANGE_MIN = 1; public static final int ORACLE_NUMBER_PRECISION_RANGE_MAX = 38; public static final int ORACLE_NUMBER_SCALE_RANGE_MIN = -84; public static final int ORACLE_NUMBER_SCALE_RANGE_MAX = 127; /** * Validation Rule: A number can be stored in an oracle NUMBER column by specified precision and scale * @param precision The total number of digits * @param scale The number of digits to the right of the decimal point * @param inputText Input string text * @return boolean Return true when input string is valid number can be stored in an oracle NUMBER column * by specified precision and scale, otherwise return false. */ public static boolean validateNumberPrecision(int precision, int scale, String inputText) { boolean isValid = false; if (Util.isEmpty(inputText)) { isValid = true; } if (!Util.isEmpty(inputText) && NumericValidator.isNumeric(inputText)) { if (precision > PrecisionValidator.ORACLE_NUMBER_PRECISION_RANGE_MAX) { precision = PrecisionValidator.ORACLE_NUMBER_PRECISION_RANGE_MAX; } if (precision < PrecisionValidator.ORACLE_NUMBER_PRECISION_RANGE_MIN) { precision = PrecisionValidator.ORACLE_NUMBER_PRECISION_RANGE_MIN; } if (scale > PrecisionValidator.ORACLE_NUMBER_SCALE_RANGE_MAX) { scale = PrecisionValidator.ORACLE_NUMBER_SCALE_RANGE_MAX; } if (scale < PrecisionValidator.ORACLE_NUMBER_SCALE_RANGE_MIN) { scale = PrecisionValidator.ORACLE_NUMBER_SCALE_RANGE_MIN; } int lastDecimalIndex = inputText.lastIndexOf('.'); int currentPrecision = 0; int currentScale = 0; boolean isValidPrecision = false; boolean isValidScale = false; if (lastDecimalIndex > 0) { currentPrecision = lastDecimalIndex; currentScale = inputText.length() - lastDecimalIndex - 1; } else { currentPrecision = inputText.length(); currentScale = 0; } if (currentPrecision <= precision) { isValidPrecision = true; } if (scale >= 0 && currentScale <= scale) { isValidScale = true; } if (scale < 0) { isValidScale = true; } if (isValidPrecision && isValidScale) { isValid = true; } } return isValid; } /** * Validation Rule: A number can be stored in an oracle NUMBER column by specified precision and scale * @param precision The total number of digits * @param scale The number of digits to the right of the decimal point * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param fieldErrorMessage Field error message * @return boolean Return true when input string is valid number can be stored in an oracle NUMBER column * by specified precision and scale, otherwise return false. */ public static boolean validateNumberPrecision(int precision, int scale, String inputText, String fieldErrorParam, String fieldErrorMessage) { boolean isValid = PrecisionValidator.validateNumberPrecision(precision, scale, inputText); if (!isValid) { addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } /** * Validation Rule: A number can be stored in an oracle NUMBER column by specified precision and scale * @param precision The total number of digits * @param scale The number of digits to the right of the decimal point * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param bundle Language property file id * @param key Message key * @param defaultMessage Default message * @param arguments The arguments of message * @return boolean Return true when input string is valid number can be stored in an oracle NUMBER column * by specified precision and scale, otherwise return false. */ public static boolean validateNumberPrecision(int precision, int scale, String inputText, String fieldErrorParam, String bundle, String key, String defaultMessage, String[] arguments) { boolean isValid = PrecisionValidator.validateNumberPrecision(precision, scale, inputText); if (!isValid) { String fieldErrorMessage = MessageUtil.getText(bundle, key, defaultMessage, arguments); addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } /** * Validation Rule: A number is integer and the value is between -2147483648 and 2147483647 * @param inputText Input string text * @return boolean Return true when input string is an integer and the value is between -2147483648 and 2147483647, * otherwise return false. */ public static boolean validateIntegerPrecision(String inputText) { boolean isValid = false; if (Util.isEmpty(inputText)) { isValid = true; } if (!Util.isEmpty(inputText) && IntegerValidator.isInteger(inputText)) { try { Integer.parseInt(inputText); isValid = true; } catch (Exception e) { isValid = false; } } return isValid; } /** * Validation Rule: A number is integer and the value is between -2147483648 and 2147483647 * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param fieldErrorMessage Field error message * @return boolean Return true when input string is an integer and the value is between -2147483648 and 2147483647, * otherwise return false. */ public static boolean validateIntegerPrecision(String inputText, String fieldErrorParam, String fieldErrorMessage) { boolean isValid = PrecisionValidator.validateIntegerPrecision(inputText); if (!isValid) { addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } /** * Validation Rule: A number is integer and the value is between -2147483648 and 2147483647 * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param bundle Language property file id * @param key Message key * @param defaultMessage Default message * @param arguments The arguments of message * @return boolean Return true when input string is an integer and the value is between -2147483648 and 2147483647, * otherwise return false. */ public static boolean validateIntegerPrecision(String inputText, String fieldErrorParam, String bundle, String key, String defaultMessage, String[] arguments) { boolean isValid = PrecisionValidator.validateIntegerPrecision(inputText); if (!isValid) { String fieldErrorMessage = MessageUtil.getText(bundle, key, defaultMessage, arguments); addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } /** * Validation Rule: A number is type long and the value is between -9223372036854775808L and 9223372036854775807L * @param inputText Input string text * @return boolean Return true when input string is type long number and the value is between -9223372036854775808L and 9223372036854775807L, * otherwise return false. */ public static boolean validateLongPrecision(String inputText) { boolean isValid = false; if (Util.isEmpty(inputText)) { isValid = true; } if (!Util.isEmpty(inputText) && IntegerValidator.isInteger(inputText)) { try { Long.parseLong(inputText); isValid = true; } catch (Exception e) { isValid = false; } } return isValid; } /** * Validation Rule: A number is type long and the value is between -9223372036854775808L and 9223372036854775807L * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param fieldErrorMessage Field error message * @return boolean Return true when input string is type long number and the value is between -9223372036854775808L and 9223372036854775807L, * otherwise return false. */ public static boolean validateLongPrecision(String inputText, String fieldErrorParam, String fieldErrorMessage) { boolean isValid = PrecisionValidator.validateLongPrecision(inputText); if (!isValid) { addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } /** * Validation Rule: A number is type long and the value is between -9223372036854775808L and 9223372036854775807L * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param bundle Language property file id * @param key Message key * @param defaultMessage Default message * @param arguments The arguments of message * @return boolean Return true when input string is type long number and the value is between -9223372036854775808L and 9223372036854775807L, * otherwise return false. */ public static boolean validateLongPrecision(String inputText, String fieldErrorParam, String bundle, String key, String defaultMessage, String[] arguments) { boolean isValid = PrecisionValidator.validateLongPrecision(inputText); if (!isValid) { String fieldErrorMessage = MessageUtil.getText(bundle, key, defaultMessage, arguments); addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } /** * Validation Rule: A number is type float and the value is between 1.401298464324817E-45f and 3.4028234663852886E38f * @param inputText Input string text * @return boolean Return true when input string is type float number and the value is between 1.401298464324817E-45f and 3.4028234663852886E38f, * otherwise return false. */ public static boolean validateFloatPrecision(String inputText) { boolean isValid = false; if (Util.isEmpty(inputText)) { isValid = true; } if (!Util.isEmpty(inputText) && NumericValidator.isNumeric(inputText)) { try { Float.parseFloat(inputText); isValid = true; } catch (Exception e) { isValid = false; } } return isValid; } /** * Validation Rule: A number is type float and the value is between 1.401298464324817E-45f and 3.4028234663852886E38f * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param fieldErrorMessage Field error message * @return boolean Return true when input string is type float number and the value is between 1.401298464324817E-45f and 3.4028234663852886E38f, * otherwise return false. */ public static boolean validateFloatPrecision(String inputText, String fieldErrorParam, String fieldErrorMessage) { boolean isValid = PrecisionValidator.validateFloatPrecision(inputText); if (!isValid) { addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } /** * Validation Rule: A number is type float and the value is between 1.401298464324817E-45f and 3.4028234663852886E38f * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param bundle Language property file id * @param key Message key * @param defaultMessage Default message * @param arguments The arguments of message * @return boolean Return true when input string is type float number and the value is between 1.401298464324817E-45f and 3.4028234663852886E38f, * otherwise return false. */ public static boolean validateFloatPrecision(String inputText, String fieldErrorParam, String bundle, String key, String defaultMessage, String[] arguments) { boolean isValid = PrecisionValidator.validateFloatPrecision(inputText); if (!isValid) { String fieldErrorMessage = MessageUtil.getText(bundle, key, defaultMessage, arguments); addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } /** * Validation Rule: A number is type double and the value is between 4.9E-324 and 1.7976931348623157E308 * @param inputText Input string text * @return boolean Return true when input string is type double number and the value is between 4.9E-324 and 1.7976931348623157E308, * otherwise return false. */ public static boolean validateDoublePrecision(String inputText) { boolean isValid = false; if (Util.isEmpty(inputText)) { isValid = true; } if (!Util.isEmpty(inputText) && NumericValidator.isNumeric(inputText)) { try { Double.parseDouble(inputText); isValid = true; } catch (Exception e) { isValid = false; } } return isValid; } /** * Validation Rule: A number is type double and the value is between 4.9E-324 and 1.7976931348623157E308 * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param fieldErrorMessage Field error message * @return boolean Return true when input string is type double number and the value is between 4.9E-324 and 1.7976931348623157E308, * otherwise return false. */ public static boolean validateDoublePrecision(String inputText, String fieldErrorParam, String fieldErrorMessage) { boolean isValid = PrecisionValidator.validateDoublePrecision(inputText); if (!isValid) { addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } /** * Validation Rule: A number is type double and the value is between 4.9E-324 and 1.7976931348623157E308 * @param inputText Input string text * @param fieldErrorParam Field error tag parameter * @param bundle Language property file id * @param key Message key * @param defaultMessage Default message * @param arguments The arguments of message * @return boolean Return true when input string is type double number and the value is between 4.9E-324 and 1.7976931348623157E308, * otherwise return false. */ public static boolean validateDoublePrecision(String inputText, String fieldErrorParam, String bundle, String key, String defaultMessage, String[] arguments) { boolean isValid = PrecisionValidator.validateDoublePrecision(inputText); if (!isValid) { String fieldErrorMessage = MessageUtil.getText(bundle, key, defaultMessage, arguments); addFieldErrorMessage(fieldErrorParam, fieldErrorMessage); } return isValid; } }
发表评论
-
XssValidator
2012-09-05 10:48 1031public class XssValidator exten ... -
StringLengthValidator
2012-09-05 13:50 817public class StringLengthValida ... -
RegexValidator
2012-09-05 13:50 2147import java.util.regex.Matcher; ... -
NumericValidator
2012-09-05 13:51 788public class NumericValidator e ... -
InvalidXMLCharacterValidator
2012-10-05 13:43 842import java.util.regex.Matcher; ... -
IntegerValidator
2012-10-05 13:43 984public class IntegerValidator e ... -
InputValidator
2012-10-05 13:43 3127public class InputValidator ext ... -
FloatValidator
2012-10-05 13:42 777public class FloatValidator ext ... -
EmailValidator
2012-10-05 13:43 1111public class EmailValidator ext ... -
DigitValidator
2012-09-04 13:37 851public class DigitValidator ext ... -
DateValidator
2012-09-04 13:36 954import java.text.DateFormat; i ... -
GracieValidator
2012-09-04 13:34 607public interface GracieValidato ... -
AlphanumericValidator
2012-09-04 13:35 657public class AlphanumericValida ... -
MessageUtil
2012-09-04 13:31 1224import java.text.MessageFormat; ... -
FieldValidationConstants
2012-08-31 09:55 722import java.util.Locale; pub ... -
BaseValidator
2012-08-31 09:53 828import org.springframework.web. ... -
Messages
2012-08-31 09:50 730import java.util.ArrayList; im ... -
AlphanumericValidator
2012-08-31 09:48 743public class AlphanumericValida ...
相关推荐
maxwell simplorer simulink 永磁同步电机矢量控制联合仿真,电机为分数槽绕组,使用pi控制SVPWM调制,修改文件路径后可使用,软件版本matlab 2017b, Maxwell electronics 2021b 共包含两个文件, Maxwell和Simplorer联合仿真文件,以及Maxwell Simplorer simulink 三者联合仿真文件。
基于springboot的网上图书商城--论文.zip
门板边挡板分离喂料机sw19全套技术资料100%好用.zip
信号与系统matlab仿真实验报告2024(学生提交).docx
洗砂机stp全套技术资料100%好用.zip
用句子记忆单词带背版本,适合时间比较充足想打好基础的同学
电子PCB板龙门铣自动化生产线sw17可编辑全套技术资料100%好用.zip
最新紧固件标准型号对照表.docx
【创新无忧】基于matlab遗传算法GA优化极限学习机KELM故障诊断【含Matlab源码 10735期】.zip
【创新无忧】基于matlab极光算法PLO优化极限学习机KELM故障诊断【含Matlab源码 10707期】.zip
java面向对象程序设计实验报告
展示PRD文档的关键要素编写具体示例。同时提供了一份模板,方便撰写PRD文档。
内容概要:本文详细介绍了一个基于广义变分同步优化(GVSAO)的时间序列预测模型项目。该项目涵盖了从项目背景到最终部署的整个流程,包括数据预处理、模型构建、训练、优化、GUI界面设计、实时预测及系统部署等方面。GVSAO作为一种新型优化方法,能更好地处理非线性关系和高维数据的特点,在预测股票价格、电力负荷、天气变化等方面显示出优越性能。文中提供的MATLAB代码和可视化工具使模型实现和评估更为便捷。 适合人群:对时间序列预测感兴趣的科研工作者、学生和工程师,特别是那些想要深入了解同步优化技术及其应用场景的人。 使用场景及目标:①适用于金融、能源、气象和制造业等多个领域的时间序列预测;②提升模型预测精度;③提供一个完整的项目实施模板供学习模仿。使用该模型可以更有效地挖掘时间序列数据背后隐含的趋势和规律,辅助商业决策和社会管理。 其他说明:本文档不仅包含理论概念和技术细节,还有丰富的实例演示,可以帮助读者全面掌握基于GVSAO的时间序列预测技巧。同时,附带完整的程序代码使得研究成果可以直接应用于实际工作中。
DSP芯片程序读取 DSP28德州仪器28系列DSP反汇编,定点器件和浮点器件均支持,能够根据out、hex或bin文件建立可以编译的CCS汇编语言工程,并且编译后可生成二进制完全相同的bin文件,方便进行研究软件设计思路,二次开发,器件迁移,混淆再链接,研究通信协议,解除ID限制,提取算法等,小批量的代码转C。
内容概要:本文介绍了一种基于对比学习的图异常检测算法,涵盖数据预处理、对比样本构建、模型设计(含选择适当的GNN架构及设计对比学习模块)、异常检测流程、结果评估方法和代码实例六个主要环节。文章特别强调在常规数据集(如Cora、PubMed)的应用上力求获得较高的AUC分数,超过80%,并且提供了详细的操作指导和Python源代码示例供开发者学习。 适用人群:主要面向有一定机器学习、深度学习理论基础,尤其关注图结构数据处理的研究人员、数据科学家和技术专家。对于有志于从事网络安全监控、金融风控等领域工作的专业人士尤为有用。 使用场景及目标:①针对具有大量节点关系的数据结构进行高效的异常识别;②利用先进的AI技术和工具箱快速搭建并迭代优化系统性能,达成高效准确的预测;③为后续研究提供参考和启示。 其他说明:文中不仅深入解析了每一阶段的技术细节,而且通过具体的Python实现片段帮助读者更好地理解和实践这一复杂的过程。对于期望深入挖掘对比学习在非传统数据格式下应用可能性的人而言是个宝贵的参考资料。
MIPI-DPU platform TCL
【JavaScrip】一个傻妞机器人插件库_pgj
comsol锂离子电池组充放电循环强制液冷散热仿真。 模型为SolidWorks导入,可以提供原模型。 电池模型:一维电化学(p2d)模型耦合三维热模型
饼干分包sw20可编辑全套技术资料100%好用.zip
自适应大领域搜索算法(ALNS)matlab解决tsp问题,与传统大规模领域搜索算法(LNS)相比收敛性强,运行时间短,很好的学习资料