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

📄 serviceinfo.java

📁 短信网关发送接受平台。
💻 JAVA
字号:
package Services;
import java.net.*;
import java.io.*;
import java.util.*;
import Utilities.*;
import Config;
/**
 * <p>Title: InHand SMS platform XMLRouter</p>
 * <p>Description: InHand 短信服务平台服务路由器</p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: 北京映翰通网络技术有限公司</p>
 * @author 韩传俊 shock2000@21cn.com
 * @version 1.0
 */

public class ServiceInfo {
        public String client_host="";
        public int id=0;
        public Vector services=new Vector();
        public ClientInput clientInput=null;
        public ClientOutput clientOutput=null;
        public DataPool data=new DataPool();
        public boolean is_connect=false;
        public Socket m_socket;
        private long mt=0;
        private long mo=0;
        private long input_number=0;
        private long output_number=0;

        public ServiceInfo(int id,String host) {
                this.id=id;
                this.client_host=host;
        }

        public synchronized void reset(){
                mt=0;
                mo=0;
                input_number=0;
                output_number=0;
        }

        public synchronized void incMt(){
                mt++;
        }

        public synchronized void incMo(){
                mo++;
        }

        public synchronized void incInputNumber(){
                this.input_number++;
        }

        public synchronized void incOutputNumber(){
                this.output_number++;
        }

        public synchronized long getMt(){
                return mt;
        }

        public synchronized long getMo(){
                return mo;
        }

        public synchronized long getInputNumber(){
                return input_number;
        }

        public synchronized long getOutputNumber(){
                return output_number;
        }


        public void addService(String service){
                this.services.add(service);
        }

        public void setConnect(Socket socket,InputStream in){
                try{
                        this.m_socket=socket;
                        this.clientInput=new ClientInput(this,in);
                        this.clientOutput=new ClientOutput(this,socket.getOutputStream());
                        this.clientInput.startup();
                        this.clientOutput.startup();
                        this.is_connect=true;
                }catch(Exception e){
                        Config.log.log(e,"while set connection form module["+this.id+"]");
                        return;
                }
        }

        public boolean checkValid(String service){
                int len=this.services.size();
                String temp="";
                if (len>0){
                        for (int i=0;i<len;i++){
                                temp=(String)this.services.elementAt(i);
                                //System.out.println(service+" ----------------- "+temp);
                                if (service.startsWith(temp)){
                                        return true;
                                }
                        }
                }
                return false;
        }

        public boolean checkServiceValid(String service,int msg_fmt){
                int len=this.services.size();
                String temp="";
                //if (!service.startsWith("9999"))
                if(msg_fmt==4){
                        return false;
                }
                service=toLowerCaseString(service,msg_fmt);
                if (len>0){
                        for (int i=0;i<len;i++){
                                temp=(String)this.services.elementAt(i);
                                temp=temp.toLowerCase();
                                //System.out.println("serivice---------------------------"+temp+"    "+service);
                                if (service.startsWith(temp)) {
                                        return true;
                                }
                                //temp=temp.toUpperCase();
                                //if (service.startsWith(Utility.toHexString(temp)) || service.startsWith(Utility.usctoHexString(temp))) {
                                //        return true;
                                //}
                        }
                }
                return false;
        }

        public String toLowerCaseString(String hexStr,int msg_fmt){
                String result="";
                String temp;
                int len=hexStr.length();
                if (hexStr.startsWith("00")){
                        len=len/4;
                        for (int i=0;i<len;i++){
                                temp=hexStr.substring(i*4+2,i*4+4);
                                if (Integer.parseInt(temp,16) > 0x7a)
                                        return result;
                                result+=(char)Byte.parseByte(temp,16);
                        }
                }else{
                        len=len/2;
                        for (int i=0;i<len;i++){
                                temp=hexStr.substring(i*2,i*2+2);
                                if (Integer.parseInt(temp,16) > 0x7a)
                                        return result;
                                result+=(char)Byte.parseByte(temp,16);
                        }
                }
                return result.toLowerCase();
        }

        public void release(){

                this.services.removeAllElements();
                this.data.release();
        }

        public static void main(String[] args) {
                ServiceInfo serv=new ServiceInfo(1,"127.0.0.1");
                System.out.println("0x003100320033="+serv.toLowerCaseString("003100320033",8));
                System.out.println("0x313233="+serv.toLowerCaseString("31"+Utility.toHexString("你好")+"3233",0));
                System.out.println("003100320033="+serv.toLowerCaseString("003100320033",8));
                System.out.println("313233="+serv.toLowerCaseString("313233"+Utility.toHexString("你好"),15));
                System.out.println("Hello this is ="+serv.toLowerCaseString(Utility.toHexString("Hello this is =你好"),15));

        }
}

⌨️ 快捷键说明

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