夢(mèng)幻之旅

          DEBUG - 天道酬勤

             :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            671 隨筆 :: 6 文章 :: 256 評(píng)論 :: 0 Trackbacks
          <2009年2月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          1234567

          公告

          本博客中未注原創(chuàng)的文章均為轉(zhuǎn)載,對(duì)轉(zhuǎn)載內(nèi)容可能做了些修改和增加圖片注釋,如果侵犯了您的版權(quán),或沒(méi)有注明原作者,請(qǐng)諒解

          常用鏈接

          留言簿(21)

          隨筆分類(644)

          隨筆檔案(669)

          文章檔案(6)

          最新隨筆

          積分與排名

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          package com.roadway.sms.util;

          /**
           * 
          @author Huyvanpull
           *
           
          */
          public class Mobile
          {
              
          /**
               * 中國(guó)移動(dòng)擁有號(hào)碼段為:139,138,137,136,135,134,159,158,157(3G),151,150,188(3G),187(3G);13個(gè)號(hào)段
               * 中國(guó)聯(lián)通擁有號(hào)碼段為:130,131,132,156(3G),186(3G),185(3G);6個(gè)號(hào)段
               * 中國(guó)電信擁有號(hào)碼段為:133,153,189(3G),180(3G);4個(gè)號(hào)碼段
               
          */
              
          private static String regMobileStr    = "^1(([3][456789])|([5][01789])|([8][78]))[0-9]{8}$";
              
          private static String regMobile3GStr  = "^((157)|(18[78]))[0-9]{8}$";
              
          private static String regUnicomStr    = "^1(([3][012])|([5][6])|([8][56]))[0-9]{8}$";
              
          private static String regUnicom3GStr  = "^((156)|(18[56]))[0-9]{8}$";
              
          private static String regTelecomStr   = "^1(([3][3])|([5][3])|([8][09]))[0-9]{8}$";
              
          private static String regTelocom3GStr = "^(18[09])[0-9]{8}$";
              
              
          private String mobile       = "";
              
          private int facilitatorType = 0;
              
          private boolean isLawful    = false;
              
          private boolean is3G        = false;
              
              
          public Mobile(String mobile)
              {
                  
          this.setMobile(mobile);
              }
              
              
          public void setMobile(String mobile)
              {
                  
          if (mobile == null)
                  {
                      
          return;
                  }
                  
          /** 第一步判斷中國(guó)移動(dòng) */
                  
          if (mobile.matches(Mobile.regMobileStr))
                  {
                      
          this.mobile = mobile;
                      
          this.setFacilitatorType(0);
                      
          this.setLawful(true);
                      
          if (mobile.matches(Mobile.regMobile3GStr))
                      {
                          
          this.setIs3G(true);
                      }
                  }
                  
          /** 第二步判斷中國(guó)聯(lián)通 */
                  
          else if (mobile.matches(Mobile.regUnicomStr))
                  {
                      
          this.mobile = mobile;
                      
          this.setFacilitatorType(1);
                      
          this.setLawful(true);
                      
          if (mobile.matches(Mobile.regUnicom3GStr))
                      {
                          
          this.setIs3G(true);
                      }
                  }
                  
          /** 第三步判斷中國(guó)電腦 */
                  
          else if (mobile.matches(Mobile.regTelecomStr))
                  {
                      
          this.mobile = mobile;
                      
          this.setFacilitatorType(2);
                      
          this.setLawful(true);
                      
          if (mobile.matches(Mobile.regTelocom3GStr))
                      {
                          
          this.setIs3G(true);
                      }
                  }
              }
              
              
          public String getMobile()
              {
                  
          return mobile;
              }
              
              
          public int getFacilitatorType()
              {
                  
          return facilitatorType;
              }
              
              
          public boolean isLawful()
              {
                  
          return isLawful;
              }
              
              
          public boolean isIs3G()
              {
                  
          return is3G;
              }
              
          private void setFacilitatorType(int facilitatorType)
              {
                  
          this.facilitatorType = facilitatorType;
              }

              
          private void setLawful(boolean isLawful)
              {
                  
          this.isLawful = isLawful;
              }

              
          private void setIs3G(boolean is3G)
              {
                  
          this.is3G = is3G;
              }
              
          public String toString()
              {
                  StringBuffer str 
          = new StringBuffer();
                  str.append(
          "mobile:").append(this.getMobile()).append(",");
                  str.append(
          "facilitatorType:").append(this.getFacilitatorType()).append(",");
                  str.append(
          "isLawful:").append(this.isLawful()).append(",");
                  str.append(
          "is3G:").append(this.isIs3G()).append(";");
                  
          return str.toString();
              }
              
          public static void main(String[] args)
              {
                  Mobile mobile 
          = new Mobile("18001678250");
                  System.out.println(mobile.toString());
              }
          }
          posted on 2009-02-23 17:27 HUIKK 閱讀(270) 評(píng)論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 巩义市| 海安县| 清苑县| 洪洞县| 云南省| 会昌县| 沙河市| 曲阜市| 简阳市| 桃园市| 阜宁县| 镇平县| 寿阳县| 开封市| 靖安县| 临湘市| 新余市| 牙克石市| 同江市| 承德市| 长乐市| 临汾市| 新平| 新竹县| 日喀则市| 吴旗县| 中江县| 通化市| 资源县| 抚远县| 弥渡县| 达拉特旗| 嘉义市| 黑河市| 临湘市| 靖边县| 南投县| 凉山| 嘉义市| 闻喜县| 阜城县|