submitsmrespwithtrailinggarbage.java

来自「Logica lastest SMPP API」· Java 代码 · 共 48 行

JAVA
48
字号
package com.logica.smpp.pdu.invalid;

import com.logica.smpp.Data;
import com.logica.smpp.pdu.SubmitSMResp;
import com.logica.smpp.pdu.ValueNotSetException;
import com.logica.smpp.util.ByteBuffer;

/**
 * @author paolo@bulksms.com
 *
 * For testing purposes only. Useful for testing how the code deals with invalid PDUs.
 *
 * This will produce a submit_sm_resp which has some arbitrary garbage appended
 * to it.
 * 
 */

public class SubmitSMRespWithTrailingGarbage extends SubmitSMResp
{

	private String messageId = Data.DFLT_MSGID;


	public SubmitSMRespWithTrailingGarbage()
	{
		super();
	}

	public ByteBuffer getData()
		throws ValueNotSetException
	{
		ByteBuffer buffer = super.getData();
		// here's some garbage which implies a massive command_length, but is
		// actually very short:
		String garbage = "ffffffff0000";
		// and here's the opposite:
		// String garbage = "00000043ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
		for (int i = 0; i < garbage.length(); i+=2) {
			String thisCharString = garbage.substring(i,i+2);
			char thisChar = (char)Integer.parseInt(thisCharString,16);
			buffer.appendByte((byte)thisChar);
		}

		return buffer;
	}


}

⌨️ 快捷键说明

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