The most complete Java form verification Encapsulation class __java

Source: Internet
Author: User
Package com.tongrong.utils;
Import java.util.Collection;
Import Java.util.Map;
Import Java.util.regex.Matcher;

Import Java.util.regex.Pattern;

Import Org.apache.commons.lang.StringUtils; /** * Java Form Verification Tool class * * @author Jiqinlin * */@SuppressWarnings ("Unchecked") public class Regexutil {public STA
tic void Main (string[] args) {//System.out.println ("Filter in English special characters:" +regexutil.stringfilter ("China ~~!#$%%."));
System.out.println ("is included in Chinese and English special characters:" +regexutil.iscontainsspecialchar ("12"));
SYSTEM.OUT.PRINTLN ("Filter HTML code:" +regexutil.htmltotext ("<javascript>12</javascript>ddddd")); SYSTEM.OUT.PRINTLN ("Judge Chinese Character:" +regexutil.ischinesechar ("China.")
        ")); SYSTEM.OUT.PRINTLN ("Matching Chinese characters:" +regexutil.ischinese) ("China.")
"));
SYSTEM.OUT.PRINTLN ("Judge English Character:" +regexutil.isenglish ("abc!"));
SYSTEM.OUT.PRINTLN ("Judging legal character:" +regexutil.isrightfulstring ("abc_-11aaa"));
System.out.println ("Zip code verification:" +regexutil.iszipcode ("162406")); SystEM.OUT.PRINTLN ("ID card number verification:" +regexutil.isidcardno ("35052419880210133e"));
System.out.println ("Mobile number verification:" +regexutil.ismobile ("18918611111"));
SYSTEM.OUT.PRINTLN ("Phone number verification:" +regexutil.isphone ("8889333"));
SYSTEM.OUT.PRINTLN ("Phone number verification:" +regexutil.isnumeric ("888.9333"));
System.out.println ("Match password:" +regexutil.ispwd ("d888d_ddddd"));
        System.out.println ("Match password:" +regexutil.isurl ("http://baidu.com"));
System.out.println ("Verify character:" +regexutil.stringcheck ("Chinese aabc001_-"));
        System.out.println (Isemail ("416501600@qq.com"));
    http://baidu.com www.baidu.com baidu.com//System.out.println (Numberutils.toint ("-0000000002")); Public final Static Boolean isNull (object[] objs) {if (objs==null| |
        objs.length==0) return true;
    return false; Public final static Boolean isNull (Integer integer) {if (integer==null| |
        integer==0) return true;
    return false; Public Final Static boolean isNull (Collection Collection) {if (collection==null| |
        Collection.size () ==0) return true;
    return false; Public final Static Boolean isNull (map map) {if (map==null| |
        Map.size () ==0) return true;
    return false; Public final Static Boolean isNull (String str) {return str = NULL | | "". Equals (Str.trim ()) | |
    Null ". Equals (Str.tolowercase ()); Public final Static Boolean isNull (Long longs) {if longs==null| |
        longs==0) return true;
    return false;
    Public final Static Boolean isnotnull (Long longs) {return!isnull (longs);
    Public final Static Boolean isnotnull (String str) {return!isnull (str);
    Public final Static Boolean isnotnull (Collection Collection) {return!isnull (Collection);
    Public final Static Boolean isnotnull (map map) {return!isnull (map); } public final Static Boolean Isnotnull(Integer integer)
    {return!isnull (integer);
    Public final Static Boolean isnotnull (object[] objs) {return!isnull (OBJS); /** * Matching URL address * * @param str * @return * @author Jiqinlin/Public Final St atic boolean isurl (String str) {return match (str, ^http://) ([\\w-]+\\.)
    +[\\w-]+ (/[\\w-./?%&=]*)? $ ");
     /** * Matches the password, starts with a letter, length between 6-12, and can only contain characters, numbers, and underscores.
        * * @param str * @return * @author Jiqinlin/Public Final static Boolean ispwd (String str) {
    return match (str, "^[a-za-z]\\w{6,12}$");
     /** * Verify characters, can only contain characters such as Chinese, English, numerals, underscores, and so on. * * @param str * @return * @author Jiqinlin/Public Final static Boolean Stringcheck (String str
    ) {return match (str, "^[a-za-z0-9\u4e00-\u9fa5-_]+$"); /** * Matching Email address * * @param str * @return * @author Jiqinlin/public final StaTic Boolean isemail (String str) {return match (str, "^\\w+" ([-+.] \\w+) *@\\w+ ([-.] \\w+) *\\.\\w+ ([-.]
    \\w+) *$ "); /** * Matching non-negative integer (positive integer +0) * * @param str * @return * @author Jiqinlin/public fi
    Nal Static boolean isinteger (String str) {return match (str, "^[+]?\\d+$"); /** * To determine numeric types, including integers and floating-point numbers * * @param str * @return * @author Jiqinlin/Public
        Final static Boolean isnumeric (String str) {if (isfloat (str) | | | isinteger (str)) return true;
    return false; /** * can only enter numbers * * @param str * @return * @author Jiqinlin * * Public final STA
    Tic Boolean isdigits (String str) {return match (str, "^[0-9]*$"); /** * Matching positive floating-point number * * @param str * @return * @author Jiqinlin/public final STA
    Tic Boolean isfloat (String str) {return match (str, "^[-\\+]?\\d+ (\\.\\d+)? $");
   } 
    /** * TEL (cell phone/Phone) verification * * @param text * @return * @author Jiqinlin/public F Inal Static Boolean Istel (String text) {if ismobile (text) | |
        Isphone (text) return true;
    return false; /** * Phone Number verification * * @param text * @return * @author Jiqinlin/public final Static Boolean Isphone (String text) {return match (text, ^ (\\d{3,4}-?)?
    \\d{7,9}$ ");  /** * MOBILE Number Verification * * @param text * @return * @author Jiqinlin/public final
        Static Boolean IsMobile (String text) {if (Text.length ()!=11) return false; Return match (text, "^ ((13[0-9]{1}) | ( 15[0-9]{1}) | (18[0-9]{1}))
    +\\D{8}) $ "); /** * ID Card number Verification * * @param text * @return * @author Jiqinlin/public final Static Boolean Isidcardno (String text) {return match (text, ^ (\\d{6}) ()?
   \\D{4}) (\\d{2}) (\\d{2}) (\\d{3}) (\\w) $ "); /** * ZIP Code verification * * @param text * @return * @author Jiqinlin/public final
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.