dealtext.java

来自「spring+struts+hibernate做的银行系统」· Java 代码 · 共 685 行 · 第 1/2 页

JAVA
685
字号
//Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
//Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
//Decompiler options: packimports(3) fieldsfirst ansi 
//Source File Name:   dealText.java

package cn.com.tym.util.text;


import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.util.*;

//Referenced classes of package com.zs.util.text:
//         exchangeInput

public class DealText
{

 private static LinkedHashMap PYSpellMap;

 public DealText()
 {
 }

 public static String dealToSql(String input)
 {
     input = ExchangeInput.StringToString(input);
     input = input.replaceAll("'", "''");
     return input;
 }

 public static float culDoubleStringLength(String input)
 {
     float count = 0.0F;
     byte inputByte[] = input.getBytes();
     count = (float)inputByte.length / 2.0F;
     return count;
 }

 public static String delSubString(String input, int doubleLength)
 {
     String output = "";
     input = ExchangeInput.StringToString(input);
     byte inputByte[] = input.getBytes();
     int singleLength = inputByte.length;
     int splitLength = 0;
     float position = doubleLength * 2;
     for(int i = 0; i < inputByte.length; i++)
     {
         if(inputByte[i] > 255 || inputByte[i] < 0)
             splitLength++;
         else
             splitLength += 2;
         position--;
         if(position == 0.0F)
             break;
     }

     if(singleLength < doubleLength * 2)
         output = input;
     else
         output = input.substring(0, splitLength / 2);
     return output;
 }

 public static String addBr(String input)
 {
     String output = "";
     input = ExchangeInput.StringToString(input);
     output = output.replaceAll("\r", "");
     output = output.replaceAll("\n", "<br>");
     return output;
 }

 public static String Encode(String input, String newEncode)
 {
     String output = "";
     input = ExchangeInput.StringToString(input);
     try
     {
         CharBuffer cb = CharBuffer.wrap(input.toCharArray());
         ByteBuffer by = ByteBuffer.wrap(input.getBytes());
         Charset ch = Charset.forName(newEncode);
         CharsetEncoder ce = ch.newEncoder();
         ByteBuffer bm = ce.encode(cb);
         byte b[] = bm.array();
         String dm = "";
         for(int i = 0; i < b.length; i++)
         {
             if(b[i] == 0)
                 break;
             dm = dm + "%" + Integer.toHexString(b[i]).replaceAll("ffffff", "");
         }

         output = dm;
     }
     catch(Exception ex) { }
     return output;
 }

 public static String HTMLEncode(String input)
 {
     input = ExchangeInput.StringToString(input);
     input = input.replaceAll(">", "&gt;");
     input = input.replaceAll("<", "&lt;");
     input = input.replaceAll("chr(60)", "&lt;");
     input = input.replaceAll("chr(37)", "&gt;");
     input = input.replaceAll("\"", "&quot;");
     input = input.replaceAll("'", "&#39;");
     return input;
 }

 public static String UnHTMLEncode(String input)
 {
     input = ExchangeInput.StringToString(input);
     input = input.replaceAll("&nbsp;", " ");
     input = input.replaceAll("<br />", "\n");
     input = input.replaceAll("&quot;", "\"");
     input = input.replaceAll("&gt;", ">");
     input = input.replaceAll("&lt;", "<");
     input = input.replaceAll("&#39;", "'");
     return input;
 }

 public static String returnChineseToFirstPY(String input)
 {
     String output = "";
     input = ExchangeInput.StringToString(input);
     input = String.valueOf(input.charAt(0));
     byte charNum[] = input.getBytes();
     if(charNum != null && charNum.length <= 2 && charNum.length > 0)
         if(charNum.length == 1)
         {
             output = String.valueOf((char)charNum[0]).toUpperCase();
         } else
         {
             int highByte = 256 + charNum[0];
             int lowByte = 256 + charNum[1];
             int ascii = (256 * highByte + lowByte) - 0x10000;
             ascii += 65535;
             if(ascii >= 45217 && ascii <= 45252)
                 output = "A";
             if(ascii >= 45217 && ascii <= 45252)
                 output = "B";
             if(ascii >= 45253 && ascii <= 46317)
                 output = "C";
             if(ascii >= 46318 && ascii <= 46825)
                 output = "D";
             if(ascii >= 46826 && ascii <= 47009)
                 output = "E";
             if(ascii >= 47010 && ascii <= 47296)
                 output = "F";
             if(ascii >= 47297 && ascii <= 47613)
                 output = "G";
             if(ascii >= 47614 && ascii <= 48118)
                 output = "H";
             if(ascii >= 48119 && ascii <= 49601)
                 output = "J";
             if(ascii >= 49062 && ascii <= 49323)
                 output = "K";
             if(ascii >= 49324 && ascii <= 49865)
                 output = "L";
             if(ascii >= 49896 && ascii <= 50370)
                 output = "M";
             if(ascii >= 50371 && ascii <= 50613)
                 output = "N";
             if(ascii >= 50614 && ascii <= 50621)
                 output = "O";
             if(ascii >= 50622 && ascii <= 50905)
                 output = "P";
             if(ascii >= 50906 && ascii <= 51386)
                 output = "Q";
             if(ascii >= 51387 && ascii <= 51445)
                 output = "R";
             if(ascii >= 51446 && ascii <= 52217)
                 output = "S";
             if(ascii >= 52218 && ascii <= 52697)
                 output = "T";
             if(ascii >= 52698 && ascii <= 52979)
                 output = "W";
             if(ascii >= 52980 && ascii <= 53640)
                 output = "X";
             if(ascii >= 53689 && ascii <= 54480)
                 output = "Y";
             if(ascii >= 54481 && ascii <= 62289)
                 output = "Z";
         }
     return output;
 }

 private static void PYSpellPut(String PYSpell, int ascii)
 {
     PYSpellMap.put(PYSpell, new Integer(ascii));
 }

 private static void initializePYSpellMap()
 {
     PYSpellPut("a", -20319);
     PYSpellPut("ai", -20317);
     PYSpellPut("an", -20304);
     PYSpellPut("ang", -20295);
     PYSpellPut("ao", -20292);
     PYSpellPut("ba", -20283);
     PYSpellPut("bai", -20265);
     PYSpellPut("ban", -20257);
     PYSpellPut("bang", -20242);
     PYSpellPut("bao", -20230);
     PYSpellPut("bei", -20051);
     PYSpellPut("ben", -20036);
     PYSpellPut("beng", -20032);
     PYSpellPut("bi", -20026);
     PYSpellPut("bian", -20002);
     PYSpellPut("biao", -19990);
     PYSpellPut("bie", -19986);
     PYSpellPut("bin", -19982);
     PYSpellPut("bing", -19976);
     PYSpellPut("bo", -19805);
     PYSpellPut("bu", -19784);
     PYSpellPut("ca", -19775);
     PYSpellPut("cai", -19774);
     PYSpellPut("can", -19763);
     PYSpellPut("cang", -19756);
     PYSpellPut("cao", -19751);
     PYSpellPut("ce", -19746);
     PYSpellPut("ceng", -19741);
     PYSpellPut("cha", -19739);
     PYSpellPut("chai", -19728);
     PYSpellPut("chan", -19725);
     PYSpellPut("chang", -19715);
     PYSpellPut("chao", -19540);
     PYSpellPut("che", -19531);
     PYSpellPut("chen", -19525);
     PYSpellPut("cheng", -19515);
     PYSpellPut("chi", -19500);
     PYSpellPut("chong", -19484);
     PYSpellPut("chou", -19479);
     PYSpellPut("chu", -19467);
     PYSpellPut("chuai", -19289);
     PYSpellPut("chuan", -19288);
     PYSpellPut("chuang", -19281);
     PYSpellPut("chui", -19275);
     PYSpellPut("chun", -19270);
     PYSpellPut("chuo", -19263);
     PYSpellPut("ci", -19261);
     PYSpellPut("cong", -19249);
     PYSpellPut("cou", -19243);
     PYSpellPut("cu", -19242);
     PYSpellPut("cuan", -19238);
     PYSpellPut("cui", -19235);
     PYSpellPut("cun", -19227);
     PYSpellPut("cuo", -19224);
     PYSpellPut("da", -19218);
     PYSpellPut("dai", -19212);
     PYSpellPut("dan", -19038);
     PYSpellPut("dang", -19023);
     PYSpellPut("dao", -19018);
     PYSpellPut("de", -19006);
     PYSpellPut("deng", -19003);
     PYSpellPut("di", -18996);
     PYSpellPut("dian", -18977);
     PYSpellPut("diao", -18961);
     PYSpellPut("die", -18952);
     PYSpellPut("ding", -18783);
     PYSpellPut("diu", -18774);
     PYSpellPut("dong", -18773);
     PYSpellPut("dou", -18763);
     PYSpellPut("du", -18756);
     PYSpellPut("duan", -18741);
     PYSpellPut("dui", -18735);
     PYSpellPut("dun", -18731);
     PYSpellPut("duo", -18722);
     PYSpellPut("e", -18710);
     PYSpellPut("en", -18697);
     PYSpellPut("er", -18696);
     PYSpellPut("fa", -18526);
     PYSpellPut("fan", -18518);
     PYSpellPut("fang", -18501);
     PYSpellPut("fei", -18490);
     PYSpellPut("fen", -18478);
     PYSpellPut("feng", -18463);
     PYSpellPut("fo", -18448);
     PYSpellPut("fou", -18447);
     PYSpellPut("fu", -18446);
     PYSpellPut("ga", -18239);
     PYSpellPut("gai", -18237);
     PYSpellPut("gan", -18231);
     PYSpellPut("gang", -18220);
     PYSpellPut("gao", -18211);
     PYSpellPut("ge", -18201);
     PYSpellPut("gei", -18184);
     PYSpellPut("gen", -18183);
     PYSpellPut("geng", -18181);
     PYSpellPut("gong", -18012);
     PYSpellPut("gou", -17997);
     PYSpellPut("gu", -17988);
     PYSpellPut("gua", -17970);
     PYSpellPut("guai", -17964);
     PYSpellPut("guan", -17961);
     PYSpellPut("guang", -17950);
     PYSpellPut("gui", -17947);
     PYSpellPut("gun", -17931);
     PYSpellPut("guo", -17928);
     PYSpellPut("ha", -17922);
     PYSpellPut("hai", -17759);
     PYSpellPut("han", -17752);
     PYSpellPut("hang", -17733);
     PYSpellPut("hao", -17730);
     PYSpellPut("he", -17721);
     PYSpellPut("hei", -17703);
     PYSpellPut("hen", -17701);
     PYSpellPut("heng", -17697);
     PYSpellPut("hong", -17692);
     PYSpellPut("hou", -17683);
     PYSpellPut("hu", -17676);
     PYSpellPut("hua", -17496);
     PYSpellPut("huai", -17487);
     PYSpellPut("huan", -17482);
     PYSpellPut("huang", -17468);
     PYSpellPut("hui", -17454);
     PYSpellPut("hun", -17433);
     PYSpellPut("huo", -17427);
     PYSpellPut("ji", -17417);
     PYSpellPut("jia", -17202);
     PYSpellPut("jian", -17185);
     PYSpellPut("jiang", -16983);
     PYSpellPut("jiao", -16970);
     PYSpellPut("jie", -16942);
     PYSpellPut("jin", -16915);
     PYSpellPut("jing", -16733);
     PYSpellPut("jiong", -16708);
     PYSpellPut("jiu", -16706);
     PYSpellPut("ju", -16689);
     PYSpellPut("juan", -16664);
     PYSpellPut("jue", -16657);
     PYSpellPut("jun", -16647);
     PYSpellPut("ka", -16474);
     PYSpellPut("kai", -16470);
     PYSpellPut("kan", -16465);
     PYSpellPut("kang", -16459);
     PYSpellPut("kao", -16452);
     PYSpellPut("ke", -16448);

⌨️ 快捷键说明

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