亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pdu.java

?? Short Message Peer to Peer
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
/*
 * Copyright (c) 1996-2001
 * Logica Mobile Networks Limited
 * All rights reserved.
 *
 * This software is distributed under Logica Open Source License Version 1.0
 * ("Licence Agreement"). You shall use it and distribute only in accordance
 * with the terms of the License Agreement.
 *
 */
package org.smpp.pdu;

import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Vector;

import org.smpp.Data;
import org.smpp.pdu.tlv.TLV;
import org.smpp.pdu.tlv.TLVException;
import org.smpp.pdu.tlv.TLVOctets;
import org.smpp.util.*;

/**
 * Class <code>PDU</code> is abstract base class for all classes which
 * represent a PDU. It contains methods for manipulating PDU header,
 * checking validity of PDU, automatic parsing and generation of optional
 * part of PDU, methods for creating instance of proper class representing
 * certain PDU based only in command id, methods for detection if the 
 * PDU is request or response PDU, automatic sequence number
 * assignment, etc. It also implements <code>setData</code> and
 * <code>getData</code> methods as the header and optional params
 * parsing and composition is the same for all PDUs. The derived
 * classes on turn implement functions <code>setBody</code> and
 * <code>getBody</code>.
 * <p>
 * The <code>PDU</code> has two descendants, <code>Request</code> and
 * <code>Response</code>, which serve as a base classes for concrete
 * PDU classes like SubmitSM, SubmitSMResp etc.
 *
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.7 $
 */
public abstract class PDU extends ByteData {
	/**
	 * This constant indicates that parsing of the buffer failed
	 * parsing of the header of PDU.
	 *
	 * @see #setData(ByteBuffer)
	 * @see #valid
	 */
	public static final byte VALID_NONE = 0;

	/**
	 * This constant indicates that parsing of the buffer passed
	 * parsing of the header of PDU but failed parsing of mandatory
	 * part of body.
	 *
	 * @see #setData(ByteBuffer)
	 * @see #valid
	 */
	public static final byte VALID_HEADER = 1;

	/**
	 * This constant indicates that parsing of the buffer passed
	 * parsing of the mandatory part of body of PDU but failed parsing
	 * of optional parameters.
	 *
	 * @see #setData(ByteBuffer)
	 * @see #valid
	 */
	public static final byte VALID_BODY = 2;

	/**
	 * This constant indicates that parsing of the buffer passed
	 * all parts of the PDU, i.e. headet, mandator and optional
	 * parameters.
	 *
	 * @see #setData(ByteBuffer)
	 * @see #valid
	 */
	public static final byte VALID_ALL = 3;

	/**
	 * This vector contains instances of all possible PDUs whic can be
	 * received and sent. It is used to create new instance of
	 * class based only on command id.
	 *
	 * @see #createPDU(int)
	 * @see #createPDU(ByteBuffer)
	 */
	private static Vector pduList = null;

	/**
	 * This is counter of sequence numbers. Each time the method
	 * <code>assignSequenceNumber</code> is called, this counter
	 * is increased and the it's value is assigned as a sequence number
	 * of th PDU.
	 *
	 * @see #assignSequenceNumber()
	 */
	private static int sequenceNumber = 0;

	/**
	 * Indicates that the sequence number has been changed either by setting
	 * by method <code>setSequenceNumber(int) or by reading from buffer by
	 * method <code>setHeader</code>.
	 *
	 * @see #setSequenceNumber(int)
	 * @see #assignSequenceNumber()
	 */
	private boolean sequenceNumberChanged = false;

	/**
	 * This is the header of the PDU. It's only created when necessary.
	 * <code>PDU</code> class implements accessor methdos for setting
	 * and getting parameters of header like comand id, sequence
	 * number etc.
	 *
	 * @see #checkHeader()
	 * @see #setHeader(ByteBuffer)
	 * @see #getHeader()
	 */
	private PDUHeader header = null;

	/**
	 * This contains all optional parameters defined for particular
	 * concrete PDU. E.g. for submit_sm class <code>SubmitSM</code>
	 * puts  here all it's possible optional parameters. It is used
	 * to build a byte buffer from optional parameters as well as
	 * fill them from a buffer.
	 *
	 * @see #registerOptional(TLV)
	 * @see TLV
	 */
	private Vector optionalParameters = new Vector(10, 2);

	/**
	 * Contains optional parameters which aren't defined in the SMPP spec.
	 *
	 * @see #setExtraOptional(TLV)
	 * @see #setExtraOptional(short,ByteBuffer)
	 * @see #getExtraOptional(short)
	 * @see #registerExtraOptional(TLV)
	 */
	private Vector extraOptionalParameters = new Vector(1, 1);

	/**
	 * This indicates what stage was reached when parsing byte buffer
	 * in <code>setData</code> method.
	 *
	 * @see #VALID_NONE
	 * @see #VALID_HEADER
	 * @see #VALID_BODY
	 * @see #VALID_ALL
	 * @see #setData(ByteBuffer)
	 */
	private byte valid = VALID_ALL;

	/**
	 * Application developers can attach application specific data to an instance
	 * of PDU or derived class. This facility can be used to carry data
	 * over different components  of the application in the PDU without explicit
	 * development of PDU to data mapping functionality.
	 * Typical use would be attaching an information about data from which a
	 * Request was created and after receiving a Response to that Request
	 * these data can be used for controling the proper reaction to the Response.
	 * If you use string gey, be carefull and choose a key which would be expected
	 * to be unique, fo example your class name qualified with full package name
	 * and with additional key description name appended.
	 * @see #setApplicationSpecificInfo(Object,Object)
	 * @see #getApplicationSpecificInfo(Object)
	 * @see #removeApplicationSpecificInfo(Object)
	 */
	private Dictionary applicationSpecificInfo = null;

	/**
	 * Default constructor, what else.
	 */
	public PDU() {
		super();
	}

	/**
	 * Initialises PDU with given command id. Derived classes should
	 * provide correct command id for their type, e.g. SubmitSM should
	 * provide <code>Data.SUBMIT_SM</code>, which is equal to 4 (as defined
	 * in SMPP 3.4 spec.)
	 *
	 * @param commandId the numerical id of the PDU as specified in SMPP
	 *                  specification
	 */
	public PDU(int commandId) {
		super();
		checkHeader();
		setCommandId(commandId);
	}

	/**
	 * Default method for seting mandatory parameters of the PDU.
	 * Derived classes should overwrite this method if they want
	 * to fill their member variables with data from the binary
	 * data buffer.
	 *
	 * @param buffer the buffer with the PDU's data as received from SMSC
	 * @see #setData(ByteBuffer)
	 */
	public void setBody(ByteBuffer buffer)
		throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException {
	}

	/**
	 * Default method for composing binary representation of
	 * the mandatory part of the PDU. Derived classes should overwrite this
	 * method with composition of buffer from their member variables.
	 *
	 * @see #getData()
	 */
	public ByteBuffer getBody() throws ValueNotSetException {
		return null;
	}

	/**
	 * This method indicates that the object represents PDU which can
	 * and should be responded to. For example for <code>SubmitSM</code>
	 * class this should return <code>true</code>, while for
	 * <code>SubmitSMResp</code> or <code>AlertNotification</code> classes
	 * this should return <code>false</code>. This method is overwritten in
	 * class <code>Request</code> as most "request" PDUs have response
	 * counterparts. (Exception to this rule is above mentioned
	 * <code>AlertNotification</code> which doesn't have response.)
	 * @return if the PDU can have a response
	 * @see Request#canResponse()
	 * @see Response#canResponse()
	 * @see AlertNotification#canResponse()
	 */
	public boolean canResponse() {
		return false;
	}

	/**
	 * Returns if the object represents PDU which is a request.
	 * E.g. classes derived from <code>Request</code> class return
	 * <code>true</code>.
	 * @return if the PDU represents request
	 */
	public abstract boolean isRequest();

	/**
	 * Returns if the object represents PDU which is response.
	 * E.g. classes derived from <code>Response</code> class return
	 * <code>true</code>.
	 * @return if the PDU represents response
	 */
	public abstract boolean isResponse();

	/**
	 * Assigns newly generated sequence number if the sequence number
	 * hasn't been assigned yet. Doesn't have any effect if the sequence
	 * number was already assigned.
	 *
	 * @see #assignSequenceNumber(boolean)
	 * @see #setSequenceNumber(int)
	 * @see #setHeader(ByteBuffer)
	 */
	public void assignSequenceNumber() {
		assignSequenceNumber(false);
	}

	/**
	 * Assigns newly generated sequence number. If the sequence
	 * number was previously set by <code>setSequenceNumber</code> method or
	 * from byte buffer in <code>setHeader</code>, this method only assigns the
	 * number if the parameter <code>always</code> is true.
	 *
	 * @param always if the number has to be assigned even if it was already assigned
	 * @see #setSequenceNumber(int)
	 * @see #setHeader(ByteBuffer)
	 */
	public void assignSequenceNumber(boolean always) {
		if ((!sequenceNumberChanged) || always) {
			setSequenceNumber(++sequenceNumber);
		}
	}

	/**
	 * If the sequence number was previously set to a value, this function
	 * resets that fact. I.e. if the PDU is re-used for another say submit,
	 * then after calling of this function a new sequence number will
	 * assigned to it the PDU despite of the fact that there was another one
	 * assigned to it before.
	 */
	public void resetSequenceNumber() {
		setSequenceNumber(0);
		sequenceNumberChanged = false;
	}

	/**
	 * Parses the binary buffer to get the PDUs header, fields from mandatory
	 * part and fields from the optional part.<br>
	 * The header and optional part are parsed common way for all PDUs
	 * using functions <code>setHeader</code> and <code>setOptionalBody</code>
	 * the mandatory body is parsed by the derived classes in
	 * <code>setBody</code> function. If parsing throws an exception, the PDU's
	 * <code>getValid</code> function returns the phase which was correct
	 * last.<br>
	 * The buffer can contain more than one PDU, then only one PDU is taken
	 * from the buffer and the rest remains unaltered.
	 * @param buffer the buffer containg the PDU binary data which are source
	 *               for the content of the fields of this PDU
	 * @see #setHeader(ByteBuffer)
	 * @see #setBody(ByteBuffer)
	 * @see #setOptionalBody(ByteBuffer)
	 * @see #getValid()
	 * @see #getData()
	 */
	public void setData(ByteBuffer buffer) throws InvalidPDUException, PDUException {
		int initialBufLen = buffer.length();
		try {
			setValid(VALID_NONE);
			// first try read header
			if (buffer.length() < Data.PDU_HEADER_SIZE) {
				if (debug.active(DPDU)) {
					debug.write(DPDU, "PDU.setData() not enough data for header in the buffer " + buffer.getHexDump());
				}
			}

			// get the header from the buffer
			ByteBuffer headerBuf = buffer.removeBytes(Data.PDU_HEADER_SIZE);
			if (debug.active(DPDU)) {
				debug.write(DPDU, "PDU.setData() parsing header " + headerBuf.getHexDump());
			}
			setHeader(headerBuf);
			setValid(VALID_HEADER);
			// now read pdu's body for hex dump
			if (debug.active(DPDU)) {
				if (getCommandLength() > Data.PDU_HEADER_SIZE) {
					ByteBuffer tempBodyBuf = buffer.readBytes(getCommandLength() - Data.PDU_HEADER_SIZE);
					debug.write(DPDU, "PDU.setData() parsing body " + tempBodyBuf.getHexDump());
				} else {
					debug.write(DPDU, "PDU.setData() no data for body");
				}
			}
			// parse the body
			setBody(buffer);
			setValid(VALID_BODY);
			if ((initialBufLen - buffer.length()) < getCommandLength()) {
				// i.e. parsed less than indicated by command length =>
				// must have optional parameters
				int optionalLength = getCommandLength() + buffer.length() - initialBufLen;
				try {
					debug.write(DPDU, "have " + optionalLength + " bytes left.");
					ByteBuffer optionalBody = buffer.removeBuffer(optionalLength);
					setOptionalBody(optionalBody);
				} catch(Exception e) {
					debug.write(DPDU, "Parsing optional parameters failed: " + e.getMessage());
				}
			}
			setValid(VALID_ALL);
		} catch (NotEnoughDataInByteBufferException e) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
7777精品伊人久久久大香线蕉超级流畅 | 国产精品久久三| 欧洲精品视频在线观看| 91在线观看高清| 91小视频在线观看| 日本乱码高清不卡字幕| 欧美午夜片在线看| 男男gaygay亚洲| 亚洲国产综合91精品麻豆| 亚洲影院久久精品| 亚洲成人免费影院| 久久成人免费网| 色婷婷av一区二区三区之一色屋| 欧美在线视频全部完| 久久精品在线观看| 亚洲国产另类精品专区| 成人网男人的天堂| 精品久久国产老人久久综合| 亚洲三级电影全部在线观看高清| 视频一区视频二区中文| 成人黄色在线视频| 日韩一卡二卡三卡| 天天综合网 天天综合色| 波多野结衣精品在线| 国产日韩一级二级三级| 日本午夜精品一区二区三区电影| www.66久久| 国产蜜臀97一区二区三区| 激情av综合网| 国产亚洲成aⅴ人片在线观看 | 亚洲精品国久久99热| av成人老司机| 日本一区二区三区四区| 高清不卡一区二区在线| 国产欧美一区视频| 91一区二区三区在线观看| 国产精品传媒入口麻豆| 91免费视频观看| 午夜精品成人在线| 色综合色综合色综合色综合色综合 | 国产毛片精品视频| 国产午夜精品理论片a级大结局| 国内一区二区视频| 亚洲欧洲三级电影| 91麻豆精品91久久久久久清纯| 日本亚洲最大的色成网站www| 日韩免费一区二区| 一本到三区不卡视频| 精品一区二区三区免费| 成人免费小视频| 国产亚洲精久久久久久| 欧美亚洲国产bt| 成人激情小说乱人伦| 免费观看一级欧美片| 亚洲国产一二三| 亚洲日本一区二区| 国产精品激情偷乱一区二区∴| 欧美亚一区二区| av亚洲精华国产精华精| 欧美96一区二区免费视频| 亚洲视频在线一区二区| 欧美大片在线观看| 91美女在线视频| 丁香激情综合国产| 国产美女精品一区二区三区| 视频一区二区三区中文字幕| 精品国产免费人成在线观看| 91在线观看下载| 99re8在线精品视频免费播放| 国产成人亚洲综合色影视| 久久99蜜桃精品| 国产成人午夜精品5599| 国产精品一区二区久久精品爱涩| 久久国产精品一区二区| 久久99久久99小草精品免视看| 人人精品人人爱| 国产在线国偷精品免费看| 国产成人综合网| 99re8在线精品视频免费播放| 日本精品免费观看高清观看| 欧美在线观看18| 久久美女艺术照精彩视频福利播放 | 欧美一区二区三区白人| 亚洲欧美国产三级| 538prom精品视频线放| 成人在线综合网站| 日韩**一区毛片| 久久99久国产精品黄毛片色诱| 精品在线播放免费| 91丨porny丨户外露出| 一级做a爱片久久| 国产一区999| 欧美日韩亚洲另类| 亚洲日穴在线视频| 国产曰批免费观看久久久| 91香蕉视频在线| 欧美午夜一区二区三区免费大片| 99re这里只有精品首页| 欧美日本在线视频| 国产嫩草影院久久久久| 国产一区福利在线| 日韩限制级电影在线观看| 亚洲一区免费观看| 欧美性生交片4| 亚洲成人www| 91精品国产91久久久久久一区二区| 欧美国产精品中文字幕| 国产成人免费高清| 中文字幕一区二区在线观看| 粉嫩欧美一区二区三区高清影视| 欧美大片拔萝卜| 久久草av在线| 中文字幕在线不卡一区二区三区 | 久久久久九九视频| 成人网在线播放| 亚洲女同一区二区| 欧美日韩国产首页| 日本 国产 欧美色综合| 国产亚洲婷婷免费| 99国产精品久久久| 欧美a一区二区| 亚洲欧美成人一区二区三区| 欧美性感一区二区三区| 精品一区二区三区在线观看 | 亚洲天堂中文字幕| 欧美日韩国产经典色站一区二区三区| 一区二区三区精品视频| 欧美欧美午夜aⅴ在线观看| 狠狠色丁香久久婷婷综| 亚洲青青青在线视频| 欧美精品日韩一本| 国产一区不卡视频| 亚洲成a人v欧美综合天堂| 日韩一级欧美一级| 一本大道久久a久久精二百| 日本va欧美va精品| 香港成人在线视频| 久久人人97超碰com| 91精品国产高清一区二区三区蜜臀 | 色综合天天综合网天天狠天天| 久久狠狠亚洲综合| 日本aⅴ精品一区二区三区| 亚洲成人一区二区| 国产精品国产成人国产三级 | 日本中文字幕一区二区视频| 亚洲婷婷在线视频| 亚洲激情六月丁香| 一区二区三区四区在线播放| 欧美蜜桃一区二区三区 | 老司机精品视频导航| 日韩激情一区二区| 裸体歌舞表演一区二区| 免费高清成人在线| 国产成人免费视频精品含羞草妖精 | 亚洲成人午夜影院| 久久成人免费电影| 91视频xxxx| 欧美伦理电影网| 久久亚洲精品小早川怜子| 久久综合狠狠综合久久激情| 日本一区二区免费在线| 中文字幕精品综合| 亚洲伊人伊色伊影伊综合网| 亚洲午夜日本在线观看| 久久se精品一区精品二区| 成人污视频在线观看| 色婷婷精品久久二区二区蜜臂av| 欧美大片拔萝卜| 亚洲成人av电影| 成人免费视频免费观看| 欧美一区二区免费| 亚洲精品日韩综合观看成人91| 久久精品国产成人一区二区三区 | 久久久久久久av麻豆果冻| 亚洲天堂网中文字| 99久久久久久| 久久久精品人体av艺术| 日韩国产精品91| 欧美日韩国产美| 亚洲二区视频在线| 欧美性色aⅴ视频一区日韩精品| 国产欧美一区二区精品秋霞影院 | 一区二区三区资源| 不卡一卡二卡三乱码免费网站| 久久人人97超碰com| 国内精品视频666| 久久你懂得1024| 国产一区 二区| 中文字幕亚洲一区二区va在线| 亚洲国产日韩a在线播放| 99久久99久久久精品齐齐| 国产精品久久久久影院亚瑟| 国产成人在线影院| 中文幕一区二区三区久久蜜桃| 韩国成人在线视频| 亚洲视频在线一区观看| 色噜噜狠狠一区二区三区果冻| |精品福利一区二区三区| 日本黄色一区二区| 亚洲gay无套男同|