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

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

?? serviceindicationmessage.java

?? 用于開(kāi)發(fā)mms應(yīng)用的Java庫(kù)
?? JAVA
字號(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.net.URL;
import java.util.Date;

import org.jdom.Document;
import org.jdom.Element;

/**
 * This class representes a wap-push Service Indication.
 * <p>
 * push-id is used as si-id 
 * <p>
 * References: 
 * <p>
 * <a href="http://www1.wapforum.org/tech/documents/WAP-167-ServiceInd-20010731-a.pdf">
 * WAP-167-ServiceInd-20010731-a 
 * </a>
 * <p> 
 * 
 * @author Anders Lindh
 * @copyright Copyright FlyerOne Ltd 2005
 * @version $Revision: 1.1.1.1 $ $Date: 2005/04/14 09:04:10 $
 */
public class ServiceIndicationMessage extends PpgMessage {

	protected String href = null;
	protected String message = null;

	/**
	 * Constructor for ServiceIndicationMessage.
	 */
	public ServiceIndicationMessage() {
		super();
	}
	
	public ServiceIndicationMessage(String pushId, String address) { 
		super(pushId, address); 
	}
	
	/**
	 * Set Href (i.e. target)
	 */
	public String getHref() { return href; }
	
	/**
	 * Get Href
	 */
	public void setHref(String href) { this.href = href; }

	/**
	 * Get message
	 */
	public String getMessage() { return message; }
	
	/**
	 * Set message
	 */
	public void setMessage(String message) { this.message = message; }

	/**
	 * convert to string (MIME representation)
	 */
	public String toString() {
		Document doc = createSI();
		if (doc == null) return null;
		
		String content = toXMLString(doc);
		setContent(content.getBytes());
		setContentType("text/vnd.wap.si");
		
		return super.toString();
	}
	
	public byte[] getBytes() {
		Document doc = createSI();
		if (doc == null) return null;
		
		String content = toXMLString(doc);
		setContent(content.getBytes());
		setContentType("text/vnd.wap.si");
		
		return super.getBytes();
	}
	
	/**
	 * create an encoded version of this message
	 * (according to WAP-167-ServiceInd-20010731-a. 8.1)
	 * @return
	 */
	public byte[] encode() throws Exception {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		
		baos.write(0x02); // version number - WBXML version 1.2
		baos.write(0x05); // SI 1.0 Public Identifier
		baos.write(0x6A); // Charset=UTF-8 (MIBEnum 106)
		baos.write(0x00); // String table length
		baos.write(0x45); // si, with content
		baos.write(0xC6); // indication, with content and attributes
		
		// parse url
		
		URL url = new URL(href);
		String host = url.getHost();
		String h = href;
		
		if (h.startsWith("http://www.")) {
			 baos.write(0x0D);
			 h = h.substring(11);
			 host = host.substring(4); 
		} else if (h.startsWith("https://www.")) {
			baos.write(0x0F); 
			h = h.substring(12);
			host = host.substring(5);
		} else if (h.startsWith("http://")) {
			baos.write(0x0C);
			h = h.substring(7); 
		} else if (h.startsWith("https://")) {
			baos.write(0x0E); 
			h = h.substring(8);
		} else {
			baos.write(0x0B);
		}	
		
		baos.write(0x03); // inline string follows
		
		boolean hasKnownEnding = false;
		if (host.endsWith(".com") || host.endsWith(".net") || host.endsWith(".org") || host.endsWith(".edu"))
			hasKnownEnding = true;
			
		if (hasKnownEnding) {
			String tmp = host.substring(0, host.lastIndexOf("."));
			baos.write(tmp.getBytes());
			baos.write(0x00); // end of inline string
			
			if (host.endsWith(".com")) baos.write(0x85); else
			if (host.endsWith(".edu")) baos.write(0x86); else
			if (host.endsWith(".net")) baos.write(0x87); else
			if (host.endsWith(".org")) baos.write(0x88);
			
			baos.write(0x03); // inline string follows
			String path = url.getPath();
			if (url.getQuery() != null) {
				path += "?" + url.getQuery();
			}
			if (path.length() > 0) path = path.substring(1);
			baos.write(path.getBytes());			
			baos.write(0x00);  // end of inline string
		} else {					
			baos.write(h.getBytes());
			baos.write(0x00); // end of inline string			
		}
		
	/*	baos.write(0x0A); // created
		baos.write(0xC3); // opaque data
		baos.write(0x07); // length
		// TODO: get date
		 
		baos.write(0x10); // si-expires
		baos.write(0xC3); // opaque data
		baos.write(0x07); // length
		// TODO: get date */
				
		baos.write(0x01); // END (of indication attribute list)
		
		baos.write(0x03); // inline string follows
		baos.write(message.getBytes());
		baos.write(0x00);  // end of inline string
		
		baos.write(0x01); // END (of indication element)
		baos.write(0x01); // END (of si element)

		byte[] body = baos.toByteArray();

		// do headers
		ByteArrayOutputStream headers = new ByteArrayOutputStream();
		
		headers.write(0xAE); //	Content Type=application/vnd.wap.sic (0x80 | 0x2E)
		//headers.write(0x96); //	Host, WAP - 230, Appendix A, table 39 (wsp)
		//headers.write(host.getBytes()); // 
		headers.write(0x00); // end of string
		//headers.write(0x8D); //	Content-Length (wsp, table 39)
		//headers.write(body.length);
		headers.write(0xB4); //	Push-Flag (wsp, table 39)
		headers.write(0x80); // no flags set (wsp, chapter 8.4.2.59 & chapter

		byte[] head = headers.toByteArray();
		
		// finalize
		ByteArrayOutputStream res = new ByteArrayOutputStream();

		res.write(0x01); // Transaction id (push id)
		res.write(0x06); // PDU Type (Push PDU)
		res.write(head.length); // header length
		res.write(head);
		res.write(body);
			
		return res.toByteArray();
	}
		
	
	/**
	 * create a SI XML doc
	 */
	protected Document createSI() {
		// check that we have required info
		if (href == null) return null;
		if (message == null) return null;		
		
		// create doc		
		Document doc = new Document(new Element("si"));

		Element indication = new Element("indication");
		indication.setAttribute("href", getHref());
		indication.setAttribute("si-id", getPushId());
		indication.setAttribute("created", formatDate(new Date())); // now
		if (getDeliverBefore() != null)
			indication.setAttribute("expires", formatDate(getDeliverBefore())); 		
		indication.setText(message);
				
		doc.getRootElement().addContent(indication);				
		
		return doc;
	}
		
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲gay无套男同| 精品国产乱码久久久久久老虎| 日本久久精品电影| 欧美三级欧美一级| 在线播放欧美女士性生活| 欧美一级久久久久久久大片| 欧美亚洲日本国产| 欧美肥妇free| 91精品一区二区三区久久久久久| 久久综合色8888| 亚洲色图在线播放| 日韩成人午夜精品| 国产69精品久久99不卡| 91福利小视频| 精品久久久久久久久久久院品网| 国产欧美一区二区三区网站| 亚洲一区二区在线视频| 免费观看在线综合色| 国产黄人亚洲片| 在线观看av一区二区| 日韩丝袜情趣美女图片| 欧美国产成人精品| 婷婷成人综合网| 成人免费视频app| 欧美日韩卡一卡二| 国产亚洲1区2区3区| 午夜精品123| 成人综合婷婷国产精品久久 | 亚洲一卡二卡三卡四卡 | 欧美精品123区| 欧美日韩国产美| 国产精品美日韩| 亚洲一区二三区| 国产成人一区在线| 欧美精品在线视频| 亚洲欧美视频在线观看| 精品一区二区在线观看| 国产美女一区二区| 日韩欧美卡一卡二| 亚洲免费观看高清完整版在线观看熊 | 精品久久久久久无| 国产精品久久久久aaaa| 国产综合色产在线精品| 日本久久一区二区| 亚洲视频小说图片| 激情另类小说区图片区视频区| 色综合色狠狠综合色| 久久免费美女视频| 男男视频亚洲欧美| 欧美在线视频全部完| 久久久国产精华| 激情欧美日韩一区二区| 欧美日韩mp4| 亚洲一区二区三区三| 成人一级片网址| 国产日韩欧美在线一区| 麻豆国产欧美日韩综合精品二区| 欧美亚洲综合一区| 一区免费观看视频| 国产传媒久久文化传媒| 精品久久久久一区| 三级欧美在线一区| 在线观看亚洲精品视频| 亚洲精品国产一区二区三区四区在线 | 国产精华液一区二区三区| 欧美精品一区二区在线观看| 午夜欧美大尺度福利影院在线看| 成人午夜视频福利| 中文字幕一区二区三| 精品一区二区三区在线播放| 欧美大片免费久久精品三p| 亚洲国产中文字幕在线视频综合| 91久久一区二区| 中文字幕欧美一区| 91视频在线观看| 自拍偷拍亚洲综合| 日本乱码高清不卡字幕| 亚洲图片另类小说| 91极品视觉盛宴| 一区二区三区不卡视频| 成人美女视频在线观看18| 国产女人18毛片水真多成人如厕 | 91蝌蚪porny成人天涯| 亚洲人成精品久久久久| 99在线精品一区二区三区| 日韩一级片网址| 精品一区二区在线免费观看| 精品日韩在线观看| 国产馆精品极品| 日本一区二区三区四区在线视频| bt7086福利一区国产| 中文子幕无线码一区tr| 国产精品一区二区在线看| 久久久99精品久久| 高清不卡一区二区在线| 亚洲精品你懂的| 欧美色图在线观看| 麻豆精品一区二区三区| 精品久久久久香蕉网| 成人免费毛片app| 亚洲欧美另类综合偷拍| 欧美日韩精品一二三区| 日本成人在线电影网| 久久久久国产免费免费 | 欧美一区二区福利视频| 国产激情91久久精品导航| 国产精品天美传媒| 欧美日韩一卡二卡| 青青草一区二区三区| 欧美一级夜夜爽| 国产精品18久久久久| 精品国产髙清在线看国产毛片| 国产超碰在线一区| 亚洲欧美激情插 | 肉丝袜脚交视频一区二区| 日韩精品一区二区三区视频| 国产成人免费av在线| 有坂深雪av一区二区精品| 欧美一区二区三区电影| 成人精品电影在线观看| 亚洲综合久久久| 欧美卡1卡2卡| 99riav久久精品riav| 亚洲丰满少妇videoshd| 国产情人综合久久777777| 色综合色狠狠综合色| 黄一区二区三区| 亚洲欧洲成人精品av97| 这里是久久伊人| 成人免费高清在线| 美日韩一区二区三区| 国产精品全国免费观看高清| 欧美日本在线视频| 丰满亚洲少妇av| 免费在线观看一区二区三区| 国产欧美精品一区二区色综合 | 亚洲色图一区二区| 精品日韩成人av| 色狠狠色狠狠综合| 日本欧美久久久久免费播放网| 日本一区二区免费在线| 色综合天天综合狠狠| 国产一区二区不卡老阿姨| 亚洲另类春色国产| 国产精品乱码一区二区三区软件 | 精品国产欧美一区二区| 99精品视频在线观看免费| 久久精品久久久精品美女| 亚洲久本草在线中文字幕| 国产视频一区不卡| 欧美精品精品一区| 91精彩视频在线| 成人深夜视频在线观看| 日本中文字幕一区| 亚洲乱码中文字幕| 国产精品久久久久aaaa樱花| 日韩精品一区二区三区四区视频 | 一区二区免费视频| 中文字幕一区二区三区在线不卡 | 天堂资源在线中文精品| 亚洲男女一区二区三区| 国产午夜精品一区二区三区嫩草| 欧美一级xxx| 欧美视频在线一区| 日本黄色一区二区| 国产成人福利片| 国产成人精品亚洲午夜麻豆| 日韩成人一级片| 日日夜夜精品视频天天综合网| 中文文精品字幕一区二区| 久久精品欧美一区二区三区不卡 | 国产精品美日韩| 日本一区二区三区四区在线视频| 日韩亚洲欧美在线| 5566中文字幕一区二区电影| 欧美午夜一区二区| 欧美四级电影在线观看| 色婷婷久久综合| 91精品91久久久中77777| 99久久精品99国产精品 | 亚洲乱码国产乱码精品精可以看| 日本一区二区三区久久久久久久久不| 欧美mv和日韩mv的网站| 欧美日韩一级黄| 91超碰这里只有精品国产| 色菇凉天天综合网| 欧美无砖砖区免费| 在线观看免费成人| 欧美日韩美女一区二区| 成人动漫一区二区三区| 99精品久久久久久| 波波电影院一区二区三区| 91网上在线视频| 成人午夜看片网址| 91麻豆免费观看| 美女在线视频一区| 国产乱色国产精品免费视频| 久久激情综合网| 韩国视频一区二区| 国产mv日韩mv欧美|