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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? mmencoder.java

?? 用于開(kāi)發(fā)mms應(yīng)用的Java庫(kù)
?? JAVA
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is the Tambur MMS library.
 *
 * The Initial Developer of the Original Code is FlyerOne Ltd.
 * Portions created by the Initial Developer are Copyright (C) 2005
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 * 	Anders Lindh <alindh@flyerone.com>
 *
 * ***** END LICENSE BLOCK ***** */

package net.tambur.mms;

import java.io.ByteArrayOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.Locale;
import java.util.StringTokenizer;

import org.apache.log4j.Logger;

/**
 *	This class performs conversions of MMMessages to other formats
 *	(i.e. to encapsulated, to string, etc.)
 *
 * @author Anders Lindh
 * @copyright Copyright FlyerOne Ltd 2005
 * @version $Revision: 1.1.1.1 $ $Date: 2005/04/14 09:04:10 $
 */
public class MMEncoder {
	
	/**
	 * logger 
	 */ 
	protected transient static Logger log = Logger.getLogger(MMEncoder.class);


	/**
	 * Encode the message, i.e. create a valid mms encapsulated byte array
	 * 
	 * @param msg MMMmessage to be encoded 
	 * @return byte[] containing the binary representation of this message
	 * @throws MMEncodingException
	 */
	public static byte[] encode(MMMessage msg) throws MMEncodingException {
		ByteArrayOutputStream res = new ByteArrayOutputStream();

		log.debug("Encoding message");
		validateMMMessage(msg);
		
		// first X-Mms-Message-Type, X-Mms-Transaction-Id and X-Mms-Version (in this order)
		// these codes can be found in [MMSEncapsulation]

		try {
			encodeInt(res, 0x0C); // message type 
			encodeInt(res, msg.getMessageType()); // (m-notification-ind)

			if (msg.getTransactionId() != null) {
				encodeInt(res, 0x18); // transaction-id
				encodeString(res, msg.getTransactionId());
			}

			encodeInt(res, 0x0d); // version 
			encodeInt(res, msg.version); // 1.0

			// add existing headers

			if (msg.getBcc() != null) {
				// encode all recipients
				Iterator i = msg.getBcc().iterator();
				while (i.hasNext()) {
					String s = (String) i.next();
					encodeInt(res, 0x01); // bcc
					encodeString(res, s);
				}
			}

			if (msg.getCc() != null) {
				// encode all recipients
				Iterator i = msg.getCc().iterator();
				while (i.hasNext()) {
					String s = (String) i.next();
					encodeInt(res, 0x02); // cc
					encodeString(res, s);
				}
			}

			if (msg.getContentLocation() != null) {
				encodeInt(res, 0x03); // content-location
				encodeString(res, msg.getContentLocation());
			}

			if (msg.getDate() != null) {
				encodeInt(res, 0x05); // date
				encodeDate(res, msg.getDate());
			}

			if (msg.getFrom() != null) {
				encodeInt(res, 0x09); // from
				encodeFrom(res, msg.getFrom());
			}

			if (msg.getTo() != null) {
				// encode all recipients
				Iterator i = msg.getTo().iterator();
				while (i.hasNext()) {
					String s = (String) i.next();
					encodeInt(res, 0x17); // to
					encodeString(res, s);
				}
			}

			if (msg.getSubject() != null) {
				encodeInt(res, 0x16); // subject
				encodeString(res, msg.getSubject());
			}

			if (msg.deliveryReport != null) {
				encodeInt(res, 0x06); // delivery-report
				encodeBoolean(res, msg.deliveryReport);
			}

			if (msg.getSenderVisibility() != null) {
				encodeInt(res, 0x14); // sender-visibility
				encodeBoolean(res, msg.getSenderVisibility());
			}

			if (msg.readReply != null) {
				encodeInt(res, 0x10); // read-reply
				encodeBoolean(res, msg.readReply);
			}

			if (msg.getMessageClass() > -1) {
				if (msg.getMessageClass() >= MMConstants.MESSAGE_CLASSES.length)
					throw new MMEncodingException("Invalid X-MMS-Message-Class");

				encodeInt(res, 0x0A); // message-class
				encodeInt(res, msg.getMessageClass());
			}

			if (msg.getExpiry() != null) {
				encodeInt(res, 0x08); // expiry
				encodeDateVariable(res, msg.getExpiry(), msg.expiryAbsolute);
			}

			if (msg.getDeliveryTime() != null) {
				encodeInt(res, 0x07); // delivery-time
				encodeDateVariable(res, msg.getDeliveryTime(), msg.deliveryTimeAbsolute);
			}

			if (msg.getStatus() > -1) {
				if (msg.getStatus() >= MMConstants.STATUSES.length)
					throw new MMEncodingException("Invalid X-MMS-Status");

				encodeInt(res, 0x15); // status
				encodeInt(res, msg.getStatus());
			}

			if (msg.isMessageIdAvailable()) {
				encodeInt(res, 0x0B); // message id
				encodeString(res, msg.getMessageId());
			}

			if (msg.getMessageSize() != -1) {
				encodeInt(res, 0x0E); // message-size
				encodeLong(res, msg.getMessageSize());
			}

			if (msg.getPriority() > -1) {
				if (msg.getPriority() >= MMConstants.PRIORITIES.length)
					throw new MMEncodingException("Invalid X-MMS-Priority");

				encodeInt(res, 0x0F); // priority
				encodeInt(res, msg.getPriority());
			}

			if (msg.reportAllowed != null) {
				encodeInt(res, 0x11); // report-allowed
				encodeBoolean(res, msg.reportAllowed);
			}

			if (msg.getResponseStatus() > -1) {
				if (msg.getResponseStatus() >= MMConstants.RESPONSE_STATUSES.length)
					throw new MMEncodingException("Invalid X-MMS-Response-Status");

				encodeInt(res, 0x12); // response-status
				encodeInt(res, msg.getResponseStatus());
			}

			if (msg.getResponseText() != null) {
				encodeInt(res, 0x13); // response-text
				encodeString(res, msg.getResponseText());
			}

			// encode any custom headers
			Iterator i = msg.getAttributes();

			while (i.hasNext()) {
				String name = (String) i.next();
				String value = msg.getAttribute(name);

				int a = 0;
				for (a = 0; a < MMConstants.knownMMSHeaders.length; a++)
					if (((String) MMConstants.knownMMSHeaders[a][0])
						.equalsIgnoreCase(name))
						break;

				if (a < MMConstants.knownMMSHeaders.length)
					continue;

				encodeMessageHeader(res, name, value);
			}

			if (msg.getContentType() != null) { // content-type, the last header
				encodeInt(res, 0x04);
				encodeContentType(res, msg.getContentType());
			}

			if (!msg.parts.isEmpty()) {
				log.debug("\tEncoding parts:");
				
				// a uintvar telling how many parts there are in this message
				encodeUintvar(res, msg.parts.size());

				// now add each part in message. We'll have to encode the headers if possible
				// Parts in the message follow the following rule:
				// Size of headers, size of data, headers, data

				i = msg.parts.iterator();
				int cnt = 1;
				while (i.hasNext()) {
					//debug(DEBUG_ENABLED, "	Part: " + cnt++);
					log.debug("\t\tPart: " + cnt++);

					MimeMessage.MimePart part = (MimeMessage.MimePart) i.next();
					byte[] c = part.getContent();

					// encode headers (in different stream - we need the size)
					ByteArrayOutputStream headers = new ByteArrayOutputStream();

					// first content-type
					ArrayList attribNames = part.getAttributeNames();
					ArrayList attribValues = part.getAttributeValues();

					String value = part.getContentType();

					if (value != null) {
						encodeContentType(headers, value);
						//debug(DEBUG_ENABLED, "	   Content-Type: " + value);
						log.debug("\t\tContent-type:" + value);
					}

					Iterator penum = attribNames.iterator();
					while (penum.hasNext()) {
						String name = (String) penum.next();
						value = part.getAttribute(name);
						if (name.equalsIgnoreCase("Content-type")) continue;
						encodeWSPHeader(headers, name, value);
					}

					byte[] h = headers.toByteArray();

					// write sizes
					encodeUintvar(res, h.length);
					encodeUintvar(res, c.length);
					
					log.debug("\t\tHeaders: " + h.length + ", content: " + c.length);

					res.write(h); // write headers
					res.write(c); // write content
				}
			}
			res.flush();
		} catch (Exception e) {
			throw new MMEncodingException("Failed to encapsulate: " + e.toString());
		}

		return res.toByteArray();
	}
	
	
	/**
	 * Convert given MMMessage into a valid mime formatted message
	 * 
	 * @param msg the message to be converted
	 * @throws MMEncodingException
	 */
	public static String toString(MMMessage msg) throws MMEncodingException {			
		
		MimeMessage mime = new MimeMessage();
		validateMMMessage(msg);
		
		// first X-Mms-Message-Type, X-Mms-Transaction-Id and X-Mms-Version (in this order)		
		try {
			mime.setAttribute("X-MMS-Message-Type", msg.getMessageTypeStr()); // (m-notification-ind)

			if (msg.getTransactionId() != null) 
				mime.setAttribute("X-MMS-Transaction-Id", msg.getTransactionId());

			mime.setAttribute("X-MMS-Version", MMDecoder.versionToString(msg.version)); 

			// add existing headers

			if (msg.isBccAvailable()) {
				// encode all recipients
				String bcc = "";
				Iterator i = msg.getBcc().iterator();
				while (i.hasNext()) {
					String s = (String) i.next();
					
					if (bcc.equals(""))
						bcc += s; else bcc += ", " + s;
				}
				
				mime.setAttribute("Bcc", bcc);
			}

			if (msg.isCcAvailable()) {
				// encode all recipients
				String cc = "";
				Iterator i = msg.getCc().iterator();
				while (i.hasNext()) {
					String s = (String) i.next();
					if (cc.equals(""))
						cc += s; else cc += ", " + s;
				}
				mime.setAttribute("Cc", cc);
			}

			if (msg.isContentLocationAvailable()) 
				mime.setAttribute("X-MMS-Content-Location", msg.getContentLocation());			

			if (msg.isDateAvailable()) 
				mime.setAttribute("Date", MMDecoder.formatDate(msg.getDate()));

			if (msg.isFromAvailable()) 
				mime.setAttribute("From", msg.getFrom());

			if (msg.isToAvailable()) {
				// encode all recipients
				String to = "";
				Iterator i = msg.getTo().iterator();
				while (i.hasNext()) {
					String s = (String) i.next();
					if (to.equals(""))
						to += s; else to += ", " + s;
				}
				mime.setAttribute("To", to);
			}

			if (msg.isSubjectAvailable()) 
				mime.setAttribute("Subject", msg.getSubject());

			if (msg.isDeliveryReportAvailable()) 
				mime.setAttribute("X-MMS-Delivery-Report", String.valueOf(msg.deliveryReport));

			if (msg.isSenderVisibilityAvailable()) 
				mime.setAttribute("X-MMS-Sender-Visibility", String.valueOf(msg.getSenderVisibility()));

			if (msg.isReadReplyAvailable())
				mime.setAttribute("X-MMS-Read-Reply", String.valueOf(msg.readReply));

			if (msg.isMessageClassAvailable()) {
				if (msg.getMessageClass() >= MMConstants.MESSAGE_CLASSES.length)
					throw new MMEncodingException("Invalid X-MMS-Message-Class");
				mime.setAttribute("X-MMS-Message-Class", msg.getMessageClassStr());
			}

			if (msg.isExpiryAvailable()) 
				mime.setAttribute("X-MMS-Expiry", MMDecoder.formatDate(msg.getExpiry()));
			
			if (msg.isDeliveryTimeAvailable())
				mime.setAttribute("X-MMS-Delivery-Time", MMDecoder.formatDate(msg.getDeliveryTime()));

			if (msg.isStatusAvailable()) {
				if (msg.getStatus() >= MMConstants.STATUSES.length)
					throw new MMEncodingException("Invalid X-MMS-Status");
				mime.setAttribute("X-MMS-Status", msg.getStatusStr());
			}

			if (msg.isMessageIdAvailable())
				mime.setAttribute("Message-ID", msg.getMessageId());

			if (msg.getMessageSize() != -1)
				mime.setAttribute("Message-Size", String.valueOf(msg.getMessageSize()));

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品亚洲成a人在线观看| 欧美午夜精品久久久久久超碰 | 蜜臀久久久久久久| 麻豆国产精品777777在线| 国产盗摄精品一区二区三区在线| 国产成人精品一区二区三区四区 | 欧美经典三级视频一区二区三区| 国产午夜亚洲精品羞羞网站| 亚洲精品欧美综合四区| 精品一区二区三区不卡| 91小视频在线观看| 欧美成人国产一区二区| 亚洲卡通欧美制服中文| 秋霞午夜鲁丝一区二区老狼| 成人永久aaa| 91精品国产色综合久久不卡蜜臀 | 成人免费高清在线观看| 91久久精品日日躁夜夜躁欧美| 精品国产免费久久| 亚洲线精品一区二区三区| 国内精品嫩模私拍在线| 欧美日韩一二区| 欧美国产97人人爽人人喊| 五月婷婷另类国产| av亚洲精华国产精华精| 精品国产露脸精彩对白| 亚洲成人免费影院| 99国产精品国产精品久久| 欧美顶级少妇做爰| 曰韩精品一区二区| 成人激情黄色小说| 2024国产精品| 日产欧产美韩系列久久99| 99久精品国产| 久久九九全国免费| 精彩视频一区二区三区| 777久久久精品| 亚洲精品日产精品乱码不卡| 国产精品一区在线| 日韩免费一区二区三区在线播放| 一区二区在线观看视频| 99久久er热在这里只有精品66| 欧美激情在线一区二区| 日本不卡的三区四区五区| 欧美性受xxxx| 亚洲天堂a在线| 99视频在线精品| 国产日本亚洲高清| 成人精品视频一区| 日韩理论片一区二区| 99国产精品一区| 国产精品午夜免费| 成人免费av网站| 国产精品三级在线观看| 岛国精品一区二区| 中文字幕在线一区二区三区| 国产一区二区三区精品视频| 欧美精品一区二区三区很污很色的| 蜜臀av性久久久久av蜜臀妖精| 在线不卡免费欧美| 青青草97国产精品免费观看| 日韩网站在线看片你懂的| 蜜芽一区二区三区| 国产欧美日韩卡一| 99这里都是精品| 亚洲乱码国产乱码精品精的特点| 色妹子一区二区| 亚洲成人一区在线| 2021国产精品久久精品| 顶级嫩模精品视频在线看| 亚洲丝袜制服诱惑| 在线观看91视频| 日韩va亚洲va欧美va久久| 精品国产免费久久| 99国产精品99久久久久久| 一区二区三区日韩欧美| 欧美亚洲综合一区| 久久精品国产亚洲5555| 久久色成人在线| 色av一区二区| 久久精品国产免费看久久精品| 26uuu国产电影一区二区| 成人动漫在线一区| 午夜不卡av在线| 欧美大胆一级视频| 国产成a人亚洲精| 亚洲综合视频网| 精品国产3级a| 欧美综合一区二区三区| 狠狠狠色丁香婷婷综合久久五月| 国产精品久久久久久久久免费丝袜| 欧美性大战久久| 国产在线精品一区二区三区不卡 | 日韩欧美自拍偷拍| 国产露脸91国语对白| 亚洲乱码国产乱码精品精小说 | 大陆成人av片| 日韩国产在线一| 国产精品高潮久久久久无| 欧美日韩和欧美的一区二区| 粉嫩在线一区二区三区视频| 丝袜脚交一区二区| 国产区在线观看成人精品| 欧洲亚洲精品在线| 成人爽a毛片一区二区免费| 日本最新不卡在线| 有坂深雪av一区二区精品| 日韩一区日韩二区| 亚洲人成伊人成综合网小说| 中文字幕欧美三区| 国产天堂亚洲国产碰碰| 久久精品夜色噜噜亚洲a∨| 久久久精品免费网站| 久久久精品天堂| 国产午夜精品一区二区| 久久精品一区二区三区不卡牛牛| 久久久亚洲精品石原莉奈| www国产亚洲精品久久麻豆| 久久久久国色av免费看影院| 国产亚洲福利社区一区| 久久久亚洲高清| 日本一区二区视频在线观看| 国产精品久久久久久福利一牛影视 | 偷拍自拍另类欧美| 午夜激情一区二区三区| 午夜国产精品影院在线观看| 日本最新不卡在线| 国产一区福利在线| 成人自拍视频在线观看| 色哟哟一区二区三区| 欧美视频第二页| 日韩一区二区三区精品视频 | 国产真实乱子伦精品视频| 国产一区二区三区精品欧美日韩一区二区三区 | 94色蜜桃网一区二区三区| 91麻豆成人久久精品二区三区| 日本韩国欧美一区| 制服丝袜国产精品| 久久久久久99久久久精品网站| 国产日韩精品一区二区三区| 亚洲少妇30p| 亚洲成av人片在线观看无码| 麻豆成人在线观看| 成+人+亚洲+综合天堂| 欧洲人成人精品| 日韩欧美一级精品久久| 国产精品久久久久久亚洲毛片| 亚洲黄网站在线观看| 九九视频精品免费| 99国产精品久久久久久久久久 | 国产精品婷婷午夜在线观看| 亚洲欧美日韩久久精品| 美女脱光内衣内裤视频久久影院| 高清视频一区二区| 欧美日韩国产首页在线观看| 2021久久国产精品不只是精品| 亚洲精品少妇30p| 精品在线播放免费| 色噜噜狠狠色综合中国| 欧美刺激午夜性久久久久久久| 国产精品国产三级国产普通话三级 | 国产福利不卡视频| 欧美日韩精品欧美日韩精品一| 精品国产污网站| 亚洲成av人影院| 99麻豆久久久国产精品免费| 日韩欧美中文字幕公布| 亚洲免费观看高清完整版在线观看| 精品在线播放午夜| 宅男噜噜噜66一区二区66| 中文字幕在线不卡国产视频| 韩国av一区二区| 欧美精品丝袜中出| 亚洲视频在线观看三级| 国产一区三区三区| 欧美一区二区黄| 亚洲成人在线免费| 在线观看国产91| 亚洲日本成人在线观看| 成人高清视频免费观看| 久久精品一区二区三区av| 久久成人麻豆午夜电影| 欧美日韩不卡一区二区| 亚洲激情自拍偷拍| 一本色道久久综合狠狠躁的推荐| 久久久久久久久久看片| 久久99精品一区二区三区三区| 欧美日韩免费观看一区三区| 国产精品国模大尺度视频| 国产成人亚洲综合a∨猫咪| 久久美女高清视频| 久久91精品久久久久久秒播| 91精品欧美综合在线观看最新 | 综合电影一区二区三区 | 欧美亚洲综合在线| 亚洲国产日韩a在线播放性色| 色久综合一二码| 一区二区在线观看不卡| 在线观看一区二区精品视频| 亚洲一二三四区|