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

📄 submit.java

📁 移动CMPP2.0 Java SDK
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		ServiceId = serviceId;
	}
	
	//SrcId
	public String getSrcId() {
		return SrcId;
	}
	public void setSrcId(String srcId) {
		SrcId = srcId;
	}
	
	//TPPid
	public int getTPPid() {
		return TPPid;
	}
	public void setTPPid(int pid) {
		TPPid = pid;
	}

	//TPUdhi
	public int getTPUdhi() {
		return TPUdhi;
	}
	public void setTPUdhi(int udhi) {
		TPUdhi = udhi;
	}
	
	//ValidTime
	public String getValidTime() {
		return ValidTime;
	}
	public void setValidTime(String validTime) {
		ValidTime = validTime;
	}
	
	//FeeType
	public String getFeeType() {
		return FeeType;
	}
	public void setFeeType(String feeType) {
		FeeType = feeType;
	}
	
    /**
     * 字节数组转换成16进制可打印字符串
     * @param b
     * @param charset
     * @return
     */
    private String byteToHexString(byte[] b, String charset) {
    	String  str = null;
    	
    	if( b == null ) {
    		return null;
    	}
    	if( charset != null ) {
	    	try {
				str = new String(b, charset);
			} catch (UnsupportedEncodingException e1) {
	    		StringBuffer sb = new StringBuffer(); 
	    		for( int i=0; i<b.length; i++ ) {		// con't change, change to binary
	    			char chHi  = Character.forDigit((b[i]&0xF0)>>4	,16);
	    			char chLow = Character.forDigit((b[i]&0x0F)	,16);
	    			sb.append(chHi);
	    			sb.append(chLow);
	    			sb.append(' ');
	    		}
	    		str = sb.toString().toUpperCase();
			}
    	} else {
			str = new String(b);
    	}
    	return str;
    }

	/**
	 * to protableString
	 * @param b
	 * @return
	 */
	private String toPrintableString(byte[] b) {

		if( b == null ) return null;
		
		StringBuffer sb = new StringBuffer();
		byte[] t = new byte[1];
		for( int i=0; i<b.length; i++ ) {		// con't change, change to binary
			if( b[i]>=0x20 && b[i]<=0x7e ) {	// printable char
				t[0] = b[i];
				sb.append(new String(t));
			} else { 							//non-pritable char
				sb.append(".");
			}
		}
		return sb.toString();
	}

	/**
	 * parseBody 
	 */
	protected int parseBody()  {

    	if( super.bodyLength < commandLength ) {	//length too short.
    		return -1;
    	}
    	
    	byte[] abyte0 = new byte[21];

    	int off = 0;
    	
    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+7, 0);
    	MsgId = CMPP.Bytes8ToLong(abyte0);
    	off += 8;
    	
    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0);
    	PkTotal = CMPP.ByteToInt(abyte0[0]);
    	off += 1;
    	
    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0);
    	PkNumber = CMPP.ByteToInt(abyte0[0]);
    	off += 1;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0);
    	RegisteredDelivery = CMPP.ByteToInt(abyte0[0]);
    	off += 1;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0);
    	MsgLevel = CMPP.ByteToInt(abyte0[0]);
    	off += 1;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+9, 0);
    	ServiceId = new String(abyte0,0,10);
    	off += 10;
    	
    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0);
    	FeeUserType = CMPP.ByteToInt(abyte0[0]);
    	off += 1;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+20, 0);
    	FeeTerminalId = new String(abyte0,0,21);
    	off += 21;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0);
    	TPPid = CMPP.ByteToInt(abyte0[0]);
    	off += 1;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0);
    	TPUdhi = CMPP.ByteToInt(abyte0[0]);
    	off += 1;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0);
    	MsgFmt = CMPP.ByteToInt(abyte0[0]);
    	off += 1;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+5, 0);
    	MsgSrc = new String(abyte0,0,6);
    	off += 6;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+1, 0);
    	FeeType = new String(abyte0,0,2);
    	off += 2;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+5, 0);
    	FeeCode = new String(abyte0,0,6);
    	off += 6;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+16, 0);
    	ValidTime = new String(abyte0,0,17);
    	off += 17;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+16, 0);
    	AtTime = new String(abyte0,0,17);
    	off += 17;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+20, 0);
    	SrcId = new String(abyte0,0,21);
    	off += 21;

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0);
    	DestUsrTl = CMPP.ByteToInt(abyte0[0]);
    	off += 1;

    	for( int i=0; i<DestUsrTl; i++ ) {
        	Arrays.fill(abyte0,(byte)0);
        	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+20, 0);
        	DestTerminalId.add(new String(abyte0,0,21));
        	off += 21;
    	}

    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off, 0);
    	MsgLength = CMPP.ByteToInt(abyte0[0]);
    	off += 1;

    	MsgContent = new byte[MsgLength];
    	CMPP.BytesCopy(super.bodybytes, MsgContent, off, off+MsgLength-1, 0);
    	off += MsgLength;
    	
    	Arrays.fill(abyte0,(byte)0);
    	CMPP.BytesCopy(super.bodybytes, abyte0, off, off+7, 0);
    	Reserve = new String(abyte0,0,8);
    	off += 8;

    	return 0;
    }

	/**
	 * makeBody 
	 */
	protected int makeBody()  {

    	// make bodybytes
    	super.bodyLength = commandLength + 21 * DestUsrTl + MsgLength; 
    	super.bodybytes  = new byte[super.bodyLength];
    	Arrays.fill(super.bodybytes,(byte)0);

    	// make parameter
    	if( ServiceId == null ) {
    		ServiceId = "";
    	}
    	if( FeeTerminalId == null ) {
    		FeeTerminalId = "";
    	}
    	if( MsgSrc == null ) {
    		MsgSrc = "";
    	}
    	if( FeeType == null ) {
    		FeeType = "";
    	}
    	if( FeeCode == null ) {
    		FeeCode = "";
    	}
    	if( ValidTime == null ) {
    		ValidTime = "";
    	}
    	if( AtTime == null ) {
    		AtTime = "";
    	}
    	if( SrcId == null ) {
    		SrcId = "";
    	}
    	if( Reserve == null ) {
    		Reserve = "";
    	}
    	if( MsgContent == null ) {
    		MsgContent = new byte[0];
    	}
    	
    	// make body
    	int off = 0;
    	CMPP.BytesCopy(CMPP.LongToBytes8(MsgId), super.bodybytes, 0, 7, off );
    	off += 8;
    	super.bodybytes[off] = CMPP.IntToByte(PkTotal);
    	off += 1;
    	super.bodybytes[off] = CMPP.IntToByte(PkNumber);
    	off += 1;
    	super.bodybytes[off] = CMPP.IntToByte(RegisteredDelivery);
    	off += 1;
    	super.bodybytes[off] = CMPP.IntToByte(MsgLevel);
    	off += 1;
    	CMPP.BytesCopy(ServiceId.getBytes(), super.bodybytes, 0, 9, off );
    	off += 10;
    	super.bodybytes[off] = CMPP.IntToByte(FeeUserType);
    	off += 1;
    	CMPP.BytesCopy(FeeTerminalId.getBytes(), super.bodybytes, 0, 20, off );
    	off += 21;
    	super.bodybytes[off] = CMPP.IntToByte(TPPid);
    	off += 1;
    	super.bodybytes[off] = CMPP.IntToByte(TPUdhi);
    	off += 1;
    	super.bodybytes[off] = CMPP.IntToByte(MsgFmt);
    	off += 1;
    	CMPP.BytesCopy(MsgSrc.getBytes(), super.bodybytes, 0, 5, off );
    	off += 6;
    	CMPP.BytesCopy(FeeType.getBytes(), super.bodybytes, 0, 1, off );
    	off += 2;
    	CMPP.BytesCopy(FeeCode.getBytes(), super.bodybytes, 0, 5, off );
    	off += 6;
    	CMPP.BytesCopy(ValidTime.getBytes(), super.bodybytes, 0, 16, off );
    	off += 17;
    	CMPP.BytesCopy(AtTime.getBytes(), super.bodybytes, 0, 16, off );
    	off += 17;
    	CMPP.BytesCopy(SrcId.getBytes(), super.bodybytes, 0, 20, off );
    	off += 21;
    	super.bodybytes[off] = CMPP.IntToByte(DestUsrTl);
    	off += 1;

    	for( int i=0; i<DestTerminalId.size(); i++ ) {
    		String id = (String)DestTerminalId.get(i);
        	CMPP.BytesCopy(id.getBytes(), super.bodybytes, 0, 20, off );
        	off += 21;
    	}
    	
    	super.bodybytes[off] = CMPP.IntToByte(MsgLength);
    	off += 1;
    	CMPP.BytesCopy(MsgContent, super.bodybytes, 0, MsgLength-1, off );
    	off += MsgContent.length;
    	CMPP.BytesCopy(Reserve.getBytes(), super.bodybytes, 0, 7, off );
    	off += 8;
    	
        return 0;
    }


}

⌨️ 快捷键说明

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