⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buildsimplecode.java

📁 java 读写EXCEL文件的源码
💻 JAVA
字号:
/********************************************************************
 *
 * $RCSfile: BuildSimpleCode.java,v $  $Revision: 1.1 $  $Date: 2003/09/22 08:06:23 $
 *
 * $Log: BuildSimpleCode.java,v $
 * Revision 1.1  2003/09/22 08:06:23  icestone
 * init
 *
 *
 *
 **********************************************************************/
package pcdmupgradedata;


/**
*功能:根据全码生成简码
*入参:库连接串、mslink串(冗余参数可删除),设施全码
*out: String SimpleCode
*/
import java.sql.*;
import java.net.*;
import java.util.*;

 public class BuildSimpleCode{
 /**
 *功能:拆分简码
 *算法分析:只按规则取第一个分隔符后的所有字符为简码
 *
 */
  public static String getSimpleCode_other (
  Connection conn,
  String mslinkStr,
  String allCode
  ){
   String SimpleCod=null;
   String StrToken=null;
   StringTokenizer CodeToken;
   int codeLeng=0;

  /*拆分全码字符串*/
      if(allCode==null) return null;
      CodeToken = new StringTokenizer(allCode,"/",false);
      if(CodeToken.countTokens()==1)
        {

          SimpleCod=allCode;
        }
      else
       {
        while(CodeToken.hasMoreTokens())
          {
      	     StrToken = CodeToken.nextToken();
      	     if(StrToken.length()>6)
      	       { 
      	          codeLeng+=StrToken.length();
      	          break;
               }
          }//end while

          SimpleCod=allCode.substring(codeLeng+1);

       }//end if

    return SimpleCod;

  } //end getSimpleCode

 /**
 *功能:拆分判断(自定义)
 *算法分析:(1)无'/'特征的取本身字符串(2)有一个'/'特征的,取串后的编码为简码
 *         (3)有多个'/'特征的分几(目前四种)种情况(4)过于复杂的编码用全码表示
 */

//  public static String getSimpleCode_custom (
  public static String getSimpleCode (
  Connection conn,
  String mslinkStr,
  String allCode
  ){
   String SimpleCod=null;
   String StrToken;
   String TmpStr;
   String FrontV=null;
   Vector SToken =new Vector();
   StringTokenizer CodeToken;
   StringTokenizer MidToken;//再'-'拆分

  /*拆分全码字符串*/
      if(allCode==null) return null;
      CodeToken = new StringTokenizer(allCode,"/",false);
      if(CodeToken.countTokens()==1)
        {
  /*无分隔符考虑用全码包括:区域、子区域、局站、机房等*/

          SimpleCod=allCode;

        }
      else
       {
        while(CodeToken.hasMoreTokens())
          {
      	     StrToken = CodeToken.nextToken();

             SToken.addElement(StrToken);
          }//end while

     loop1:
        for(int i=1;i<SToken.size();i++){
              TmpStr=(String)SToken.elementAt(i);
              MidToken=new StringTokenizer(TmpStr,"-",false);
 /*判断'-'的特征数量*/
                if(MidToken.countTokens()==1) continue;

                while(MidToken.hasMoreTokens())
                   {
                     FrontV= (String)MidToken.nextToken();

                     break loop1;
                   }//end while
            }//end for
              if(FrontV==null)
                SimpleCod=(String)SToken.lastElement();
              else
                SimpleCod=FrontV+"-"+(String)SToken.lastElement();

       }//end if

    return SimpleCod;

  } //end getSimpleCode

/*拆分(根据规范的编码定义拆分)得到人手井ID--引上点表*/
  public static String getMhCode
  (
  String ysd_code
  ){

       StringTokenizer CodeToken;
       Vector SToken =new Vector();
       String Mh_code=null;
       CodeToken = new StringTokenizer(ysd_code,"/",false);

       if(CodeToken.countTokens()==1||CodeToken.countTokens()==2) return null;

       while(CodeToken.hasMoreTokens())
              {
                 Mh_code= (String)CodeToken.nextToken();

                 SToken.addElement(Mh_code);

              }//end while

  	 String Rcode =(String)SToken.elementAt(SToken.size()-3)+"/"+(String)SToken.elementAt(SToken.size()-2);

        return Rcode;


  	}//end getMhCode



/*拆分区域、子区域、局站全码*/
  public static String getRootCode
  (
  Connection conn,
  String mslinkStr,
  String allCode,
  int jzflag
  )
  {
   String SimpleCod=null;
   String T_SimpleCod=null;
   String TmpStr;
   Vector SToken =new Vector();
   StringTokenizer CodeToken;

  /*拆分全码字符串*/
  /*无分隔符考虑用全码包括:区域、子区域、局站、机房等*/
        if(allCode.length()<5)
         {
          SimpleCod=allCode;
         }
        else
         {
          if(jzflag==0) //qy,zqy
             T_SimpleCod=allCode.substring(allCode.length()-3);
          else
             T_SimpleCod=allCode.substring(allCode.length()-5);//jz

             CodeToken = new StringTokenizer(T_SimpleCod,".",false);
             while(CodeToken.hasMoreTokens())
              {
                 TmpStr= (String)CodeToken.nextToken();
                 SToken.addElement(TmpStr);
              }//end while
            SimpleCod=(String)SToken.lastElement();
          }//end if
     return SimpleCod;

   }//end    getRootCode

 /**
 *拆分分线盒全码字符串得到交接箱编码
 **/
 public static String getJjxCode
 (
  Connection conn,
  String mslinkStr,
  String FxhCode
 )
  {
   String JJXCod=null;
   String TmpStr;
   Vector SToken =new Vector();
   StringTokenizer CodeToken;


                  CodeToken = new StringTokenizer(FxhCode,"/",false);
                  while(CodeToken.hasMoreTokens())
                   {
                            TmpStr= (String)CodeToken.nextToken();
                            SToken.addElement(TmpStr);
                    }//end while

                   if(CodeToken.countTokens()==1) return null;

                   JJXCod=(String)SToken.elementAt(0);

                   for(int i=1;i<SToken.size()-1;i++)
                      {
                      	          JJXCod= JJXCod+"/"+(String)SToken.elementAt(i);
                       }//end for

     return JJXCod;

   }//end getjjxcode



/*改写新-旧管孔编码方式*/
  public static String  getnewCode
  (
  String gkCode
  )
  {
   String Str=null;
   String T_fristCod=null;
   String T_secondCod=null;
             T_fristCod=gkCode.substring(0,1);
             T_secondCod=String.valueOf(((Integer.valueOf(gkCode.substring(1))).intValue()));
             Str=T_fristCod+"/"+T_secondCod;
             return Str;
   }//end    getnewCode

 } //end class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -