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

📄 constants.java~1~

📁 本人为友邦公司做的模拟网关源代码
💻 JAVA~1~
字号:
package  smsc;

import java.util.*;
import java.io.*;
public class Constants {

	public static int  nStartNumber = 0;
	public static int  nEndNumber = 0;
	public static boolean SEND_FLAG = true;
	public static boolean SMSC_DEBUG = true;
	public static boolean DISPLAY_ACTIVE = false;
	public static boolean DISPLAY_BINARY = false;
	public static boolean DISPLAY_MSG    = false;

	public static Vector vSmpp = new Vector(300,300);
	public static Vector vSmppResp = new Vector(300,300);
	public static int nSequence = 0;

	//public static int nMsgMode = 1;
	public static int nMsgTime = 0;
	public static int nMsgNumber = 0;
	public static int nTimeInterval = 0;
	public static String strDestAddr = "";
	public static int nSendMode = Constants.NUMBER;
	public static int nMsgType = SmscConstants.SMPP_DELIVER_SM;


	public static SmscShortMsg smscMsg = new SmscShortMsg();

	public static String CONNECTION_URL    = "jdbc:oracle:thin:@128.128.10.200:1521:ora8";
	public static String DB_USER           = "smgway";
	public static String DB_PASS           = "smgway";
	public static String DB_DRIVER         = "oracle.jdbc.driver.OracleDriver";
	public static String DB_ResendInterval = "20";

	public static int smppSvrPort = 6789;
	public static final int     WAIT_FOR_DOWNWARD_INTERVAL    = 100; //in milliseconds
	public static final int     MAX_UNSEND_MSG_COUNT =1000;

	public static int MBCP_MAX_MSG_LEN       =  5120;
	public static int MBCPRCVSOCK_TIMEOUT    =  20000;

	public static final int NUMBER   = 0;
	public static final int TIME     = 1;

	public static final String WORKING          =        "working";
	public static final String NOTCONNECTED     =        "not connected";
	public static final String NOTLOGIN         =        "not login";
	public static final String NOTACTIVE        =        "not active";
	public static final String Receiver      = " Receiver";
	public static final String Transmitter   = " Transmitter";

	public static final int ERROR_SOCKET        =             -1;
	public static final int ERROR_INTERRUPT     =             -2;
	public static final int ERROR_DATA          =             -3;
	public static final int ERROR_OTHER         =             -4;

	public Constants()  {   }


	public void initSequence() {
		String  strTime;
		strTime = Constants.formatDateTime();
		strTime = strTime.substring(8) + "0000";
		Constants.nSequence = Integer.parseInt(strTime);
	}

	public static int getSequence() {
		int nCurrentSeq = 0;

		nCurrentSeq = Constants.nSequence;
		Constants.nSequence += 1;
		Constants.nSequence = Constants.nSequence % (0x7fffffff);
		return nCurrentSeq;
	}

	public static void threadSleep(int miniSec) {
		try {
			Thread.sleep(miniSec);
		} catch(InterruptedException e) {
			//Log.error("sleep interrupt ."+e);
		}
	}

	public static String formatDateTime() {
		Calendar now = Calendar.getInstance();
		String year =  Integer.toString(now.get(Calendar.YEAR));
		String mon = Integer.toString(now.get(Calendar.MONTH)+1);
		String day  = Integer.toString(now.get(Calendar.DAY_OF_MONTH));
		String hour =  Integer.toString(now.get(Calendar.HOUR_OF_DAY));
		String min  = Integer.toString(now.get(Calendar.MINUTE));
		String sec  = Integer.toString(now.get(Calendar.SECOND));

		mon = (mon.length() == 1) ? "0" + mon : mon;
		day = (day.length() == 1) ? "0" + day : day;
		hour = (hour.length() == 1) ? "0" + hour : hour;
		min  = (min.length() == 1) ? "0" + min : min;
		sec  = (sec.length() == 1) ? "0" + sec : sec;
		return  (year + mon + day + hour + min + sec);
	}


	//部分参数从文件中获取
	public static boolean loadMsgData() {
		String userHome, cfgFile, strText;

		Constants.smscMsg.msgServiceType = "";
		Constants.smscMsg.msgDestAddressTon = 2;
		Constants.smscMsg.msgSourceAddressNpi = 8;
		Constants.smscMsg.msgSourceAddress = "13907310001";
		Constants.smscMsg.msgDestAddressTon = 2;
		Constants.smscMsg.msgDestAddressNpi = 8;
		Constants.smscMsg.msgDestAddress = "1200";
		Constants.smscMsg.msgEsmClass = 0;
		Constants.smscMsg.msgProtocolID = 0;
		Constants.smscMsg.msgPriorityFlag = 0;
		Constants.smscMsg.msgScheduleDeliveryTime = "";
		Constants.smscMsg.msgValidityPeroid = "";
		Constants.smscMsg.msgRegisterdDeliveryFlag = 0;
		Constants.smscMsg.msgReplaceIfPresentFlag = 0;
		Constants.smscMsg.msgDataCoding = 0;
		Constants.smscMsg.msgSmDefaultMsgID = 0;
		Constants.smscMsg.msgSmLength = 22;
		Constants.smscMsg.msgShortMsgText = "d 111111 1111111111111";
		try {
			userHome = System.getProperties().getProperty("CONFIG_PATH");
			if( userHome == null )
				userHome="";
			else
				userHome = userHome + File.separator;

			cfgFile = userHome + "cfg" + File.separator + "MsgData";

			InputStream is = new FileInputStream(cfgFile);
			Properties  pt = new Properties() ;
			pt.load(is);

			Constants.smscMsg.msgServiceType = pt.getProperty("Service_type", "1");

			strText = pt.getProperty("Source_address_ton", "2");
			Constants.smscMsg.msgSourceAddressTon = (byte)Integer.parseInt(strText);
			strText = pt.getProperty("Source_address_npi", "8");
			Constants.smscMsg.msgSourceAddressNpi = (byte)Integer.parseInt(strText);
			Constants.smscMsg.msgSourceAddress = pt.getProperty("Source_address", "13907310001");

			strText = pt.getProperty("Dest_address_ton", "2");
			Constants.smscMsg.msgDestAddressTon = (byte)Integer.parseInt(strText);
			strText = pt.getProperty("Dest_address npi", "8");
			Constants.smscMsg.msgDestAddressNpi = (byte)Integer.parseInt(strText);
			Constants.smscMsg.msgDestAddress = pt.getProperty("Dest_address", "1200");

			strText = pt.getProperty("Esm_class", "0");
			Constants.smscMsg.msgEsmClass = (byte)Integer.parseInt(strText);
			strText = pt.getProperty("Protocol_ID", "0");
			Constants.smscMsg.msgProtocolID = (byte)Integer.parseInt(strText);
			strText = pt.getProperty("Priority_flag", "0");
			Constants.smscMsg.msgPriorityFlag = (byte)Integer.parseInt(strText);
			Constants.smscMsg.msgScheduleDeliveryTime = pt.getProperty("Schedule_delivery_time", "");
			Constants.smscMsg.msgValidityPeroid = pt.getProperty("Validity_peroid", "");

			strText = pt.getProperty("Registered_delivery_flag", "0");
			Constants.smscMsg.msgRegisterdDeliveryFlag = (byte)Integer.parseInt(strText);
			strText = pt.getProperty("Replace_if_present_flag", "0");
			Constants.smscMsg.msgReplaceIfPresentFlag = (byte)Integer.parseInt(strText);
			strText = pt.getProperty("Data_coding", "0");
			Constants.smscMsg.msgDataCoding = (byte)Integer.parseInt(strText);
			strText = pt.getProperty("SM_default_msg_id", "0");
			Constants.smscMsg.msgSmDefaultMsgID = (byte)Integer.parseInt(strText);
			Constants.smscMsg.msgShortMsgText = pt.getProperty("Short_message_text", "d 222222 1111111111111");
			Constants.smscMsg.msgSmLength = (byte)Constants.smscMsg.msgShortMsgText.length();

			is.close() ;
			return true;
		} catch (Exception e) {
			SMSCFrame.RecvArea.append("Load config file failed .\n");
			return false;
		}
	}
}



⌨️ 快捷键说明

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