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

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

?? tlv.java

?? Short Message Peer to Peer
?? JAVA
字號:
/*
 * 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.tlv;

import org.smpp.pdu.ByteData;
import org.smpp.util.ByteBuffer;
import org.smpp.util.NotEnoughDataInByteBufferException;
import org.smpp.pdu.ValueNotSetException;
import org.smpp.pdu.tlv.WrongLengthException;

/**
 * Base class for classes implementing representations of optional parameters
 * of various types. Acronym TLV means Tag-Length-Value. Derived from ByteData
 * this class "knows" how to parse from ByteBuffer and how to create a
 * ByteBuffer from it's data. Descanedants of the class (concrete types)
 * should rewrite <code>setValueData</code> and <code>getValueData</code>
 * methods for setting and getting of the particular data type. The
 * tag and the length is set and get by the <code>TLV</code> class.
 * The class also provides additiona methods for checking various
 * type validity.
 *
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.1 $
 * @see TLVByte
 * @see TLVEmpty
 * @see TLVInt
 * @see TLVOctets
 * @see TLVShort
 * @see TLVString
 */
public abstract class TLV extends ByteData {
	/** The tag of the instance of TLV as defined in SMPP v3.4 */
	private short tag = 0;

	/**
	 * If the value was set to the TLV; if yes, then the optional param
	 * was present in the PDU (for received PDUs) or it was set the value
	 * (for PDUs which will be transmitted)
	 */
	private boolean valueIsSet = false; // must be set by setValueData()

	/**
	 * For checking the min/max length limits that the particular limit
	 * <i>shouldn't</i> be checked.
	 */
	private static int DONT_CHECK_LIMIT = -1;

	/**
	 * The minimal length of the data. If no min length is required,
	 * then set to <code>DONT_CHECK_LIMIT</code>.
	 */
	private int minLength = DONT_CHECK_LIMIT;

	/**
	 * The maximal length of the data. If no max length is required,
	 * then set to <code>DONT_CHECK_LIMIT</code>.
	 */
	private int maxLength = DONT_CHECK_LIMIT;

	/** Everything is default. Not particularly good idea. */
	public TLV() {
		super();
	}

	/** Sets only the tag of the TLV. */
	public TLV(short tag) {
		super();
		this.tag = tag;
	}

	/** Sets minimal an maximal length; no tag set. */
	public TLV(int min, int max) {
		super();
		minLength = min;
		maxLength = max;
	}

	/** Sets all the necessary params of the TLV. */
	public TLV(short tag, int min, int max) {
		super();
		this.tag = tag;
		minLength = min;
		maxLength = max;
	}

	/**
	 * Sets the data of the value carried by the TLV.
	 * Derived classes must override this method to provide their
	 * data related parsing of the value.
	 * @exception TLVException if the buffer contains somehow invalid data
	 */
	protected abstract void setValueData(ByteBuffer buffer) throws TLVException;

	/**
	 * Returns the data of the value carried by the TLV as binary data.
	 * Derived classes must override this method to provide their
	 * data related creation of the buffer based on the value.
	 * @exception ValueNotSetException if the TLV wasn't set any data
	 *            then there is nothing to be returned (the optional parameter
	 *            isn't transmitted then.)
	 */
	protected abstract ByteBuffer getValueData() throws ValueNotSetException;

	/** Sets the tag of this TLV. */
	public void setTag(short tag) {
		this.tag = tag;
	}

	/** Returns the tag of this TLV. */
	public short getTag() {
		return tag;
	}

	/**
	 * Returns the length of the actual binary data representing the
	 * value carried by this TLV.
	 * @exception ValueNotSetException as this method uses
	 *            <code>getValueData</code> for calculation of the length
	 *            this exception can be thrown
	 * @see #getValueData()
	 */
	public int getLength() throws ValueNotSetException {
		if (hasValue()) {
			ByteBuffer valueBuf = getValueData();
			if (valueBuf != null) {
				return valueBuf.length();
			} else {
				return 0;
			}
		} else {
			return 0;
		}
	}

	/**
	 * Overwrites <code>ByteData</code>'s <code>setData</code> and parses
	 * tag, length and the binary data value from the buffer. For parsing the 
	 * data value calls abstract <code>setValueData</code>.
	 */
	public void setData(ByteBuffer buffer) throws NotEnoughDataInByteBufferException, TLVException {
		short newTag = buffer.removeShort();
		int length = buffer.removeShort();
		ByteBuffer valueBuf = buffer.removeBuffer(length);
		setValueData(valueBuf);
		setTag(newTag);
	}

	/**
	 * Returns the binary TLV created from tag, length and binary data value
	 * carried by this TLV.
	 */
	public ByteBuffer getData() throws ValueNotSetException {
		if (hasValue()) {
			ByteBuffer tlvBuf = new ByteBuffer();
			tlvBuf.appendShort(getTag());
			tlvBuf.appendShort(encodeUnsigned(getLength()));
			tlvBuf.appendBuffer(getValueData());
			return tlvBuf;
		} else {
			return null;
		}
	}

	/** 'Remembers' that the value was (somehow) set. */
	protected void markValueSet() {
		valueIsSet = true;
	}

	/** Returns if the value has been set. */
	public boolean hasValue() {
		return valueIsSet;
	}

	/**
	 * Compares this TLV to another TLV. TLV are equal if their tags
	 * are equal.
	 */
	public boolean equals(Object obj) {
		if ((obj != null) && (obj instanceof TLV)) {
			return getTag() == ((TLV) obj).getTag();
		}
		return false;
	}

	/**
	 * Throws exception if the <code>length</code> provided isn't between
	 * provided <code>min</code> and <code>max</code> inclusive.
	 */
	protected static void checkLength(int min, int max, int length) throws WrongLengthException {
		if ((length < min) || (length > max)) {
			throw new WrongLengthException(min, max, length);
		}
	}

	/**
	 * Throws exception if the length provided isn't between min and max
	 * lengths of this TLV.
	 */
	protected void checkLength(int length) throws WrongLengthException {
		int min = 0;
		int max = 0;
		if (minLength != DONT_CHECK_LIMIT) {
			min = minLength;
		} else {
			min = 0;
		}
		if (maxLength != DONT_CHECK_LIMIT) {
			max = maxLength;
		} else {
			max = Integer.MAX_VALUE;
		}
		checkLength(min, max, length);
	}

	/**
	 * Throws exception if the length of the buffer provided isn't between
	 * min and max lengths provided.
	 */
	protected static void checkLength(int min, int max, ByteBuffer buffer) throws WrongLengthException {
		int length;
		if (buffer != null) {
			length = buffer.length();
		} else {
			length = 0;
		}
		checkLength(min, max, length);
	}

	/**
	 * Throws exception if the length of the buffer provided isn't between
	 * min and max lengths of this TLV.
	 */
	protected void checkLength(ByteBuffer buffer) throws WrongLengthException {
		int length;
		if (buffer != null) {
			length = buffer.length();
		} else {
			length = 0;
		}
		checkLength(length);
	}

	/**
	 * Returns more specific debug info about this TLV.
	 * @see ByteData#debugString()
	 */
	public String debugString() {
		String dbgs = "(tlv: ";
		dbgs += tag;
		dbgs += ") ";
		return dbgs;
	}

}
/*
 * $Log: TLV.java,v $
 * Revision 1.1  2003/07/23 00:28:39  sverkera
 * Imported
 *
 * 
 * Old changelog:
 * 02-10-01 ticp@logica.com comments added, indentation changed -> spaces
 * 02-10-01 ticp@logica.com removed some historical unused code
 * 01-11-01 ticp@logica.com TLV length now returned as int to
 *						    allow express the lengths > 32767 (they're stored as
 *						    negative values in vars of type short)
 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区三区国产| 欧美三日本三级三级在线播放| 欧美日韩一区二区三区四区五区| 亚洲图片欧美激情| 99re免费视频精品全部| 亚洲国产一区二区三区青草影视| 在线精品视频小说1| 午夜视频在线观看一区| 欧美精品一二三四| 久久精品国产99久久6| 久久精品日韩一区二区三区| 国产成人h网站| 国产一区二区三区四| 99精品国产一区二区三区不卡| 中文字幕一区av| 精品视频在线看| 久久国产精品99久久人人澡| 中文字幕免费一区| 精品视频在线看| 精品国产自在久精品国产| 欧美一级黄色大片| 国产精品久久久久影院| 亚洲久草在线视频| 精品一二三四在线| 在线看不卡av| 中文在线一区二区| 免费在线观看日韩欧美| 91在线高清观看| 欧美成人欧美edvon| 亚洲一区成人在线| 高清不卡一区二区| 欧美一卡2卡三卡4卡5免费| 日本一二三不卡| 免费在线观看一区| 欧美日韩在线三级| 有码一区二区三区| 久久成人免费网| 精品少妇一区二区三区视频免付费 | 91在线视频免费观看| www.性欧美| 日本韩国精品在线| 精品国产乱码久久久久久影片| 国产精品久久久久毛片软件| 色哟哟国产精品免费观看| 六月丁香综合在线视频| 成人久久视频在线观看| 午夜精品久久久久久久久久久 | 国产成人一级电影| 99精品国产91久久久久久 | 高清成人在线观看| 日韩成人精品在线| 亚洲视频在线观看一区| 久久久久久久久久电影| 欧美一区二区三区精品| 欧美视频日韩视频在线观看| av中文字幕在线不卡| 精品一区二区三区不卡 | 亚洲蜜臀av乱码久久精品| 久久精品亚洲精品国产欧美kt∨| 日韩午夜小视频| 欧美精品一卡二卡| 欧美视频在线观看一区| 色婷婷综合五月| 99综合电影在线视频| 国产二区国产一区在线观看 | 高清不卡一区二区在线| 激情文学综合网| 久久99精品国产麻豆不卡| 日韩国产精品久久| 视频一区二区中文字幕| 亚洲成人在线网站| 亚洲国产中文字幕| 亚洲国产综合色| 亚洲18影院在线观看| 亚洲一区欧美一区| 亚洲午夜电影在线观看| 亚洲国产精品一区二区尤物区| 亚洲精选在线视频| 亚洲图片欧美色图| 日本人妖一区二区| 蜜桃久久av一区| 激情文学综合丁香| 成人免费毛片片v| www.欧美色图| 99视频精品全部免费在线| 91偷拍与自偷拍精品| 色狠狠综合天天综合综合| 色欧美片视频在线观看| 欧美性受xxxx| 日韩一区二区三区四区| 国产午夜亚洲精品午夜鲁丝片| 国产精品视频麻豆| 亚洲乱码国产乱码精品精的特点 | 激情六月婷婷综合| 国产成人精品三级麻豆| 99精品1区2区| 亚洲一区二区三区美女| 日本一区二区视频在线观看| 亚洲欧洲日韩综合一区二区| 一区二区三区鲁丝不卡| 男女激情视频一区| 国产精品123| 91久久线看在观草草青青 | 91精品国产色综合久久不卡蜜臀 | 日本精品一级二级| 粗大黑人巨茎大战欧美成人| 激情久久久久久久久久久久久久久久| 欧美aaaaa成人免费观看视频| 免费看欧美女人艹b| 日韩国产精品久久久| 香蕉影视欧美成人| 精品一区二区三区免费毛片爱| 久久国内精品视频| 不卡大黄网站免费看| 色婷婷亚洲精品| 欧美片网站yy| 精品第一国产综合精品aⅴ| 精品国产乱码久久久久久蜜臀| 国产日产亚洲精品系列| 亚洲手机成人高清视频| 亚洲视频一区在线观看| 国产成人免费在线观看| 国产91精品精华液一区二区三区 | 在线观看91精品国产入口| 日本精品一级二级| 椎名由奈av一区二区三区| 69堂精品视频| 91成人在线精品| 国产精品久久久久四虎| 日韩精品欧美精品| 成人app软件下载大全免费| 欧美电影影音先锋| 亚洲欧洲无码一区二区三区| 美腿丝袜亚洲三区| 色婷婷激情一区二区三区| 欧美精品一区二区三区一线天视频| 亚洲日本在线天堂| 国产中文字幕一区| 91精品中文字幕一区二区三区| 国产欧美日韩一区二区三区在线观看| 91蝌蚪porny| 91久久精品一区二区三| 久久欧美中文字幕| 日本亚洲电影天堂| 在线免费亚洲电影| 粉嫩一区二区三区性色av| 日产国产欧美视频一区精品| 免费一级片91| 欧美在线三级电影| 亚洲图片另类小说| 高清日韩电视剧大全免费| 精品国产1区二区| 麻豆极品一区二区三区| 欧洲av在线精品| 国产精品久线在线观看| 国产电影精品久久禁18| 欧美成人一区二区三区| 日韩国产在线一| 欧美视频在线观看一区| 一区二区三区四区激情| 99久久99久久免费精品蜜臀| 国产午夜亚洲精品不卡| 国产老女人精品毛片久久| 精品国产乱码久久久久久影片| 日韩一区精品视频| 欧美精品tushy高清| 亚洲一区在线观看视频| 精品视频在线免费看| 亚洲午夜影视影院在线观看| 欧美天堂亚洲电影院在线播放| 亚洲免费视频成人| 91免费看视频| 亚洲精选视频免费看| 色偷偷久久一区二区三区| 亚洲综合无码一区二区| 在线亚洲免费视频| 婷婷亚洲久悠悠色悠在线播放| 欧美体内she精高潮| 日韩高清在线电影| 欧美一级在线免费| 激情图区综合网| 国产欧美日韩另类视频免费观看 | 奇米影视一区二区三区| 欧美精品 国产精品| 三级久久三级久久久| 欧美一区二区三区色| 极品少妇一区二区| 日本一区二区三区免费乱视频| 国产一区二区精品久久91| 国产欧美一区在线| 91年精品国产| 日韩av电影天堂| 国产福利视频一区二区三区| 欧美日韩一区在线| 精品一区二区三区视频在线观看 | 国产精品久久久久一区| 色就色 综合激情| 伦理电影国产精品| 亚洲欧美在线视频| 制服视频三区第一页精品|