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

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

?? shortmessage.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;

import java.io.UnsupportedEncodingException;
import sun.io.CharToByteConverter;

import org.smpp.Data;
import org.smpp.util.ByteBuffer;
import org.smpp.util.NotEnoughDataInByteBufferException;
import org.smpp.util.TerminatingZeroNotFoundException;

/**
 * Provides encapsulation of message data with optional message encoding.
 * Can contain an ordinary data message or a message containing data encoded
 * in one of the Java supported encodings, including multibyte.
 * On Java encodings see <a href="http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html">Supported encodings</a>
 * 
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.3 $
 */
public class ShortMessage extends ByteData {
	/**
	 * Minimal size of the message in bytes. For multibyte encoded messages
	 * it means size after converting to sequence of octets.
	 */
	int minLength = 0;

	/**
	 * Max size of the message in octets. For multibyte encoded messages
	 * it means size after converting to sequence of octets.
	 */
	int maxLength = 0;

	/**
	 * The actual message encoded with the provided encoding.
	 * @see #encoding
	 */
	String message = null;

	/**
	 * The encoding of the message
	 */
	String encoding = null;

	/**
	 * The length of the message data.
	 */
	int length = 0;

	/**
	 * The message data after conversion to the sequence of octets,
	 * i.e. the octets.
	 */
	byte[] messageData = null;

	/**
	 * Construct the short message with max data length -- the max count
	 * of octets carried by the massege. It's not count of chars when interpreted
	 * with certain encoding.
	 * @param maxLength the max length of the message
	 */
	public ShortMessage(int maxLength) {
		this.maxLength = maxLength;
	}

	/**
	 * Construct the short message with mina nd max data length --
	 * the min and max count of octets carried by the massege.
	 * It's not count of chars when interpreted with certain encoding.
	 * @param minLength the min length of the message
	 * @param maxLength the max length of the message
	 */
	public ShortMessage(int minLength, int maxLength) {
		this.minLength = minLength;
		this.maxLength = maxLength;
	}

	/**
	 * Reads data from the buffer and stores them into <code>messageData</code>.
	 * The data can be later fetched using one of the <code>getMessage</code>
	 * methods.
	 * @param buffer the buffer containing the message data; must contain exactly
	 *               the data of the message (not zero terminated nor length tagged)
	 * @see #getMessage()
	 * @see #getMessage(String)
	 */
	public void setData(ByteBuffer buffer)
		throws PDUException, NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException {
		byte[] messageData = null;
		int length = 0;
		if (buffer != null) {
			messageData = buffer.getBuffer();
			length = messageData == null ? 0 : messageData.length;
			checkString(minLength, length, maxLength);
		}
		this.message = null;
		this.messageData = messageData;
		this.length = length;
	}

	/**
	 * Returns the sequence of octets generated from the message according the encoding
	 * provided.
	 * @return the bytes generated from the message
	 */
	public ByteBuffer getData() {
		ByteBuffer buffer = null;
		buffer = new ByteBuffer(messageData);
		return buffer;
	}

	/**
	 * Sets the message a new value. Default encoding <code>Data.ENC_GSM7BIT</code>
	 * is used.
	 * @param message the message
	 * @exception WrongLengthOfStringException thrown when the message
	 *            too short or long
	 */
	public void setMessage(String message) throws WrongLengthOfStringException {
		try {
			setMessage(message, Data.ENC_GSM7BIT);
		} catch (UnsupportedEncodingException e) {
			try {
				setMessage(message, Data.ENC_ASCII);
			} catch (UnsupportedEncodingException uee) {
				// ascii always supported
			}
		}
	}

	/**
	 * Sets the message to a value with given encoding.
	 * @param message the message
	 * @param encoding the encoding of the message provided
	 * @exception WrongLengthOfStringException thrown when the message
	 *            too short or long
	 * @exception UnsupportedEncodingException if the required encoding is not
	 *            available for the Java Runtime system
	 */
	public void setMessage(String message, String encoding)
		throws WrongLengthOfStringException, UnsupportedEncodingException {
		checkString(message, minLength, maxLength, encoding);
		if (message != null) {
			try {
				messageData = message.getBytes(encoding);
			} catch (UnsupportedEncodingException e) {
				debug.write("encoding " + encoding + " not supported. Exception " + e);
				event.write(e, "encoding " + encoding + " not supported");
				throw e; // re-throw
			}
			this.message = message;
			this.length = messageData.length;
			this.encoding = encoding;
		} else {
			this.message = null;
			this.messageData = null;
			this.encoding = encoding;
			this.length = 0;
		}
	}

	/**
	 * Sets the encoding of the messasge.
	 * Handy for message read from <code>ByteBuffer</code> to set the encoding ad hoc.
	 * @param encoding the message encoding
	 * @exception UnsupportedEncodingException if the required encoding is not
	 *            available for the Java Runtime system
	 */
	public void setEncoding(String encoding) throws UnsupportedEncodingException {
		message = new String(messageData, encoding);
		this.encoding = encoding;
	}

	/**
	 * Returns the message. If the message was read from <code>ByteBuffer</code>
	 * and no explicit encoding is set, the <code>Data.ENC_GSM7BIT</code> encoding
	 * is used. Otherwise the encoding set is used.
	 */
	public String getMessage() {
		String useEncoding = encoding != null ? encoding : Data.ENC_GSM7BIT;
		String theMessage = null;
		try {
			theMessage = getMessage(useEncoding);
		} catch (UnsupportedEncodingException e) {
			// fall back to ascii
			try {
				theMessage = getMessage(Data.ENC_ASCII);
			} catch (UnsupportedEncodingException uee) {
				// ascii is always supported
			}
		}
		return theMessage;
	}

	/**
	 * Returns the message applying the provided encoding to convert
	 * the sequence of octets.
	 * @param encoding the required encoding of the resulting (String) message
	 * @exception UnsupportedEncodingException if the required encoding is not
	 *            available for the Java Runtime system
	 */
	public String getMessage(String encoding) throws UnsupportedEncodingException {
		String message = null;
		if (messageData != null) {
			if ((encoding != null) && (this.encoding != null) && (encoding.equals(this.encoding))) {
				// if the required encoding is the same as current encoding
				// or if the encoding haven't been set yet
				if (this.message == null) {
					this.message = new String(messageData, encoding);
				}
				message = this.message;
			} else {
				if (encoding != null) {
					message = new String(messageData, encoding);
				} else {
					message = new String(messageData);
				}
			}
		}
		return message;
	}

	/** Returns the length of the message in octets. */
	public int getLength() {
		return messageData.length;
	}

	/** Returns the encoding of the message. */
	public String getEncoding() {
		return encoding;
	}

	/** Returns if the encoding provided is supported by the Java Runtime system. */
	public static boolean encodingSupported(String encoding) {
		boolean supported = true;
		try {
			CharToByteConverter.getConverter(encoding);
		} catch (UnsupportedEncodingException e) {
			supported = false;
		}
		return supported;
	}

	public String debugString() {
		String dbgs = "(sm: ";
		if (encoding != null) {
			dbgs += "enc: ";
			dbgs += encoding;
			dbgs += " ";
		}
		dbgs += "msg: ";
		if(encoding != null) {
			try {
				dbgs += getMessage(encoding);
			} catch(UnsupportedEncodingException e) {
				dbgs += getMessage();
			}
		} else {
			dbgs += getMessage();
		}
		dbgs += ") ";
		return dbgs;
	}
}
/*
 * $Log: ShortMessage.java,v $
 * Revision 1.3  2003/09/30 10:24:45  sverkera
 * Corrected typo as described in bug id 792803
 *
 * Revision 1.2  2003/09/30 09:05:22  sverkera
 * Use GSM 7Bit encoding as default but fall back to Ascii if there is any problem
 *
 * Revision 1.1  2003/07/23 00:28:39  sverkera
 * Imported
 *
 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本高清不卡视频| 中文字幕欧美一| 日韩三级视频在线观看| 欧美人妖巨大在线| 欧美色电影在线| 欧美日韩夫妻久久| 7777精品伊人久久久大香线蕉经典版下载 | 韩国欧美国产一区| 极品少妇xxxx精品少妇偷拍| 国产精品自拍毛片| 成人午夜视频免费看| 不卡区在线中文字幕| 97久久超碰国产精品电影| 色综合天天性综合| 欧美系列在线观看| 91精品国产91久久久久久一区二区| 精品视频在线免费看| 91精品国产91热久久久做人人| 日韩欧美中文字幕公布| 欧美精品一区二区三| 国产欧美视频一区二区三区| 亚洲视频一区二区免费在线观看| 亚洲乱码国产乱码精品精可以看| 亚洲va韩国va欧美va| 男女男精品网站| 国产成人午夜电影网| 97久久超碰国产精品| 欧美精品一二三四| 久久综合久久99| 亚洲色图视频网站| 日韩精品一二三| 国产一区二区三区视频在线播放| 99久久99久久综合| 欧美人狂配大交3d怪物一区| 精品国产百合女同互慰| 国产精品色一区二区三区| 亚洲一区在线观看视频| 久久精品国产澳门| 99国产精品久久久久久久久久久| 欧美日韩精品一区二区三区| 欧美xxxxxxxxx| 最新不卡av在线| 免费成人美女在线观看| 处破女av一区二区| 欧美午夜精品久久久| 亚洲精品一区二区三区福利| 亚洲免费av观看| 韩国午夜理伦三级不卡影院| 日本精品视频一区二区三区| 欧美成va人片在线观看| 自拍偷自拍亚洲精品播放| 欧美aaaaaa午夜精品| 成人av午夜影院| 精品人伦一区二区色婷婷| 一区二区三区欧美久久| 国产精品一品视频| 欧美日韩一卡二卡| 国产精品美女久久久久av爽李琼| 首页国产丝袜综合| 99re热这里只有精品免费视频| 日韩一区二区高清| 亚洲激情网站免费观看| 国产99一区视频免费| 91精品国产免费久久综合| 最新久久zyz资源站| 国内偷窥港台综合视频在线播放| 欧美午夜影院一区| 中文字幕欧美一| 国产河南妇女毛片精品久久久| 欧美日免费三级在线| 亚洲欧美视频在线观看视频| 国产一区二区在线看| 666欧美在线视频| 亚洲免费伊人电影| 丁香婷婷综合色啪| 26uuu色噜噜精品一区二区| 午夜影院久久久| 一本一道综合狠狠老| 国产欧美精品一区二区色综合 | 亚洲综合成人在线视频| 不卡免费追剧大全电视剧网站| 精品国产亚洲在线| 日韩av中文在线观看| 欧美午夜精品久久久久久孕妇 | 99精品视频在线观看免费| 欧美mv日韩mv国产网站app| 午夜视频久久久久久| 欧美性生交片4| 夜夜操天天操亚洲| 日本精品免费观看高清观看| 亚洲欧洲日韩在线| 国产高清不卡一区二区| 久久奇米777| 国产一区不卡在线| 久久综合九色综合97_久久久| 蜜臀91精品一区二区三区| 51精品视频一区二区三区| 午夜精品在线看| 欧美高清hd18日本| 日韩国产高清在线| 欧美精选午夜久久久乱码6080| 亚洲无人区一区| 欧美日韩一区不卡| 日产欧产美韩系列久久99| 69堂国产成人免费视频| 蜜桃视频一区二区三区| 日韩免费福利电影在线观看| 韩国一区二区三区| 国产欧美日韩精品一区| 91在线观看下载| 一区二区三区精品在线| 欧美日韩一级二级| 日韩av电影一区| 精品日韩99亚洲| 懂色av一区二区三区免费观看| 中文字幕精品—区二区四季| jiyouzz国产精品久久| 亚洲三级理论片| 欧美日韩国产电影| 久久精品国产久精国产爱| www日韩大片| 不卡一区二区中文字幕| 亚洲综合av网| 欧美一级免费大片| 国产又黄又大久久| 亚洲欧洲国产日本综合| 欧美日韩在线一区二区| 日本亚洲最大的色成网站www| 久久一夜天堂av一区二区三区| av中文字幕一区| 亚洲国产视频a| 精品国产成人系列| 91亚洲精品久久久蜜桃| 天天射综合影视| 国产日本欧美一区二区| 欧美专区亚洲专区| 久久精品国产亚洲aⅴ| 亚洲国产精品成人综合色在线婷婷| 在线视频国产一区| 免费观看91视频大全| 国产精品久久久久久久裸模| 欧美日韩一区二区三区四区| 国产一区二区三区久久悠悠色av| 成人免费在线播放视频| 欧美丰满美乳xxx高潮www| 国产精品一品二品| 亚洲sss视频在线视频| 久久久久久黄色| 欧美网站一区二区| 国产成人欧美日韩在线电影| 一区二区三区四区乱视频| 精品久久久久久久人人人人传媒 | 精品国产制服丝袜高跟| 99在线精品免费| 青青国产91久久久久久| 国产精品久久久久久久久免费丝袜| 欧美日韩免费电影| 不卡的看片网站| 日本不卡一区二区三区高清视频| 中文字幕免费不卡| 欧美精品少妇一区二区三区| 国产v综合v亚洲欧| 日韩av不卡一区二区| 中文字幕一区二区三区不卡在线| 91精品久久久久久久久99蜜臂| 波多野结衣中文字幕一区二区三区| 日本不卡视频在线观看| 亚洲视频你懂的| 国产拍欧美日韩视频二区| 91精品国产一区二区三区香蕉| 91丝袜美女网| 国产麻豆日韩欧美久久| 男男视频亚洲欧美| 亚洲一区二区三区精品在线| 国产精品毛片久久久久久久| 精品美女一区二区三区| 欧美日韩一区高清| 91蝌蚪porny九色| 国产91清纯白嫩初高中在线观看| 日韩精品一卡二卡三卡四卡无卡| 一区二区在线看| 中文字幕一区二区三区精华液| 久久久综合视频| 精品国产91久久久久久久妲己 | 亚洲国产综合在线| 亚洲欧美日韩中文字幕一区二区三区| 亚洲精品一区二区在线观看| 欧美一级二级三级乱码| 欧美日韩国产精品自在自线| 色偷偷久久人人79超碰人人澡| 成人国产在线观看| 国产aⅴ综合色| 国产成人综合视频| 国产自产高清不卡| 韩国精品免费视频| 国产真实精品久久二三区| 另类小说一区二区三区| 日本一区中文字幕| 免费三级欧美电影| 久久国产精品一区二区|