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

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

?? wbxmldecoder.java~3~

?? jwap 協議 udp 可以用于手機通訊
?? JAVA~3~
?? 第 1 頁 / 共 2 頁
字號:
/**
 * JWAP - A Java Implementation of the WAP Protocols
 * Copyright (C) 2001-2004 Niko Bender
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

package net.sourceforge.jwap.util.wbxml;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import net.sourceforge.jwap.util.TransTable;

import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.Text;

/**
 * to do's :- string table length is in multiple byte format, currently it is assumed to be single byte
 * index in string table should also be read as multiple byte format
 * character encoding supported is only utf-8,
 * for other encodings the termination character in string table can be different...
 *
 *
 * @author <a href="mailto:suvarna@witscale.com">Suvarna Kadam</a>
 */

public class WBXMLDecoder {
	private static WBXMLDecoder instance;
	private DataInputStream wbxmlStream;
	private Document xmlDocument;
	private String publicId = "UNKNOWN";
	private byte publicIdIndex = -1;
	private String encoding;
	private StringBuffer stringTable;

	private byte parentBitMask = (byte) 0x40;
	// The bit representation 10000000
	private byte attributeBitMask = (byte) 0x80;
	// The bit representation 01000000
	private TokenRepository tokenRepository;
	public static WBXMLDecoder getInstance() {
		if (instance == null)
			instance = new WBXMLDecoder();
		return instance;
	}

	private WBXMLDecoder() {
		initialize();
	}

	private void initialize() {

	}

	public Document decode(InputStream wbxmlStream) {
		this.wbxmlStream = new DataInputStream(wbxmlStream);
		try {
			xmlDocument =
				DocumentBuilderFactory
					.newInstance()
					.newDocumentBuilder()
					.newDocument();
			decodeProlog();
			decodeBody();
		} catch (Exception exp) {
			//exp.printStackTrace();
		}
		return xmlDocument;

	}


        public Document decodeFowChk(InputStream wbxmlStream) {
                this.wbxmlStream = new DataInputStream(wbxmlStream);
                try {
                        xmlDocument =
                                DocumentBuilderFactory
                                        .newInstance()
                                        .newDocumentBuilder()
                                        .newDocument();

                                    try {
       byte version = this.wbxmlStream.readByte();


     readPublicID();
     byte charset =  this.wbxmlStream.readByte(); // to do for mutiple byte
     encoding =  TransTable.getTable("charsets").code2str(charset);
     byte strtblSize =  this.wbxmlStream.readByte();
     // TODO for multi-byte and negative size
     stringTable = new StringBuffer(strtblSize);
     for (int i = 0; i < strtblSize; i++)
             stringTable.append((char)  this.wbxmlStream.readByte());
     if (publicIdIndex != -1)
             readPublicIDFromStringTable();
     // Now initialze the token repository as per the public identifier specified
     String publicIDInHex =
             PublicIdentifiers.getInstance().getPublicIdentifierValueHex(
                     publicId);
     tokenRepository = TokenRepository.getInstance(publicIDInHex);
     }
     catch (IOException ex) {
     }

                        decodeBody();
                } catch (Exception exp) {
                        //exp.printStackTrace();
                }
                return xmlDocument;

        }


	/**
	 *  currently encoding cannot be specifies as DOM does not have any API to access the XML declaration.
	 * by default utf-16 is used.. If encoding is to be used ...
	 * xmlDocument.getImplementation().String piData = "version=\"1.0\" encoding=\"" + encoding + "\"";
	 * ProcessingInstruction xmlDeclaration = xmlDocument.createProcessingInstruction("xml", piData);
	 * xmlDocument.insertBefore(xmlDeclaration, xmlDocument.getDocumentElement());
	 **/

	private void decodeProlog(){
                try {
                  byte version = wbxmlStream.readByte();


		readPublicID();
		byte charset = wbxmlStream.readByte(); // to do for mutiple byte
		encoding =  TransTable.getTable("charsets").code2str(charset);
		byte strtblSize = wbxmlStream.readByte();
		// TODO for multi-byte and negative size
		stringTable = new StringBuffer(strtblSize);
		for (int i = 0; i < strtblSize; i++)
			stringTable.append((char) wbxmlStream.readByte());
		if (publicIdIndex != -1)
			readPublicIDFromStringTable();
		// Now initialze the token repository as per the public identifier specified
		String publicIDInHex =
			PublicIdentifiers.getInstance().getPublicIdentifierValueHex(
				publicId);
		tokenRepository = TokenRepository.getInstance(publicIDInHex);
                }
                catch (IOException ex) {
                }
	}

	private void readPublicIDFromStringTable() {
		char c = 0x0;
		int endIndex =
			stringTable.toString().indexOf(new String(new char[] { c }), publicIdIndex);
		if (endIndex == -1)
			publicId = stringTable.substring(publicIdIndex);
		else
			publicId = stringTable.substring(publicIdIndex, endIndex);

	}

	private void readPublicID(){
		byte[] multipleBytes = new byte[4];
                byte nextByte = (byte) 0;
                try {
                  nextByte = wbxmlStream.readByte();

                  if (nextByte == 0) {
                    // public id is encoded as string in form:-  0 indexInstringtable
                    publicIdIndex = wbxmlStream.readByte();

                  }
                  else { // public id is encoded in multi-byte integer format(mb_u_int32)
                    int i = 0;
                    StringBuffer strBuf = new StringBuffer();
                    while ( (nextByte & 0x80) == 0x80) { //msb IS 1
                      String str = Integer.toBinaryString(nextByte & 0x7F);
                      if (str.length() < 7) {
                        int zerosToPumpIn = 7 - str.length();
                        for (int j = 0; j < zerosToPumpIn; j++)
                          strBuf.append('0');

                      }
                      strBuf.append(str);
                      nextByte = wbxmlStream.readByte();
                    }
                    String str = Integer.toBinaryString(nextByte & 0x7F);
                    if (str.length() < 7) {
                      int zerosToPumpIn = 7 - str.length();
                      for (int j = 0; j < zerosToPumpIn; j++)
                        strBuf.append('0');

                    }
                    strBuf.append(str);
                    int publicIdValue =
                        Integer.valueOf(strBuf.toString(), 2).intValue();
                    publicId =
                        PublicIdentifiers.getInstance().getPublicIdentifier(
                            publicIdValue);
                  }
                }

             catch (IOException ex) {
             }

	}

	private void decodeBody(){
		writeRootElement();
	}

	private void writeRootElement(){
                byte maskedTokenValue = (byte) 0;
                try {
                  maskedTokenValue = wbxmlStream.readByte();
                }
                catch (IOException ex) {
                }
		byte actualTokenValue = getTokenValue(maskedTokenValue);
		String rootElementName = tokenRepository.getTagName(actualTokenValue);
		try {
			DocumentBuilder builder =
				DocumentBuilderFactory.newInstance().newDocumentBuilder();
			String systemId =
				PublicIdentifiers.getInstance().getSystemIdentifier(publicId);
			DocumentType docType =
				builder.getDOMImplementation().createDocumentType(
					rootElementName,
					publicId,
					systemId);
			xmlDocument =
				builder.getDOMImplementation().createDocument(
					"",
					rootElementName,
					docType);
			if (hasAttributes(maskedTokenValue))
				setAttributes(xmlDocument.getDocumentElement());
			if (hasContent(maskedTokenValue))
				writeChildElement(xmlDocument.getDocumentElement());

		} catch (Exception exp) {
			//exp.printStackTrace();
		}

	}

	private void writeChildElement(Element parent) throws IOException {
		byte maskedTokenValue = wbxmlStream.readByte();

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
粉嫩高潮美女一区二区三区 | 国产欧美一区在线| 日韩电影免费在线| 91精品蜜臀在线一区尤物| 日韩高清一区在线| 精品日产卡一卡二卡麻豆| 国产乱一区二区| 中文字幕一区视频| 欧美高清视频一二三区 | 亚洲精品成a人| 欧美日韩精品一区二区| 日韩国产高清影视| 久久亚洲免费视频| av不卡在线观看| 亚洲电影一区二区三区| 日韩三级在线免费观看| 成人性生交大合| 亚洲国产欧美一区二区三区丁香婷| 4438x亚洲最大成人网| 麻豆精品一二三| 中文字幕五月欧美| 欧美另类z0zxhd电影| 国产成人亚洲综合a∨猫咪| √…a在线天堂一区| 欧美精品乱码久久久久久按摩 | 国产成人欧美日韩在线电影| 国产精品网站在线观看| 欧美日韩电影一区| 国产大片一区二区| 亚洲国产综合人成综合网站| wwwwxxxxx欧美| 欧美在线视频全部完| 精品影院一区二区久久久| 综合久久久久综合| 日韩精品中文字幕在线一区| 91麻豆文化传媒在线观看| 久久99国产精品尤物| 三级亚洲高清视频| 国产精品高潮呻吟| 日韩午夜精品视频| 色av一区二区| 盗摄精品av一区二区三区| 天堂精品中文字幕在线| 国产精品美女久久久久av爽李琼| 91麻豆精品久久久久蜜臀| 波多野结衣在线aⅴ中文字幕不卡| 青青草91视频| 亚洲精品成a人| 国产精品福利一区二区三区| 欧美变态tickling挠脚心| 91国产免费观看| 成人免费看片app下载| 精品一区二区影视| 日韩和欧美一区二区| 亚洲成精国产精品女| 亚洲视频一二三| 亚洲欧美在线观看| 久久精品人人爽人人爽| 日韩免费看网站| 欧美精品日日鲁夜夜添| 精品视频一区三区九区| 色偷偷久久人人79超碰人人澡| 成人综合在线观看| 国产成人综合在线| 黑人精品欧美一区二区蜜桃| 狂野欧美性猛交blacked| 日韩电影免费在线| 日本色综合中文字幕| 天天影视网天天综合色在线播放| 亚洲午夜在线视频| 亚洲一线二线三线视频| 亚洲黄色av一区| 一区二区三区日韩欧美精品| 亚洲精品美国一| 一区二区三区四区亚洲| 一区二区视频在线| 一二三区精品福利视频| 亚洲高清视频在线| 亚洲高清视频的网址| 秋霞午夜av一区二区三区| 蜜臀av一区二区在线观看| 久久精品国产99国产| 黄色小说综合网站| 国产精品一区二区你懂的| 国产成人亚洲综合色影视| 成人av网站免费| 色成人在线视频| 这里只有精品电影| 久久综合av免费| 国产精品久久久爽爽爽麻豆色哟哟 | 捆绑调教美女网站视频一区| 免费成人在线播放| 国产又粗又猛又爽又黄91精品| 国产真实乱偷精品视频免| 国产不卡在线视频| 91麻豆精东视频| 91麻豆精品91久久久久久清纯| 日韩久久精品一区| 国产欧美一区二区精品性| 国产精品成人在线观看| 亚洲一区二区三区在线播放| 午夜精品久久久久久久99水蜜桃| 青草国产精品久久久久久| 国产成人啪午夜精品网站男同| 99精品国产热久久91蜜凸| 欧美日韩1区2区| 久久久三级国产网站| 亚洲视频小说图片| 天堂va蜜桃一区二区三区 | 中国av一区二区三区| 一区二区三区小说| 美女免费视频一区二区| 风间由美性色一区二区三区| 在线看不卡av| 久久久精品综合| 亚洲综合丁香婷婷六月香| 欧美a一区二区| 99国产精品久久久久久久久久久 | 欧美成人三级在线| 国产精品久久久一区麻豆最新章节| 亚洲va欧美va人人爽午夜| 韩国v欧美v亚洲v日本v| 色乱码一区二区三区88| 久久综合色综合88| 亚洲午夜久久久久| 国产精品91xxx| 7799精品视频| 亚洲精品乱码久久久久久黑人| 久久99在线观看| 在线观看视频一区| 国产日韩亚洲欧美综合| 性欧美大战久久久久久久久| 99re这里都是精品| 久久久亚洲精华液精华液精华液 | 日韩免费在线观看| 亚洲精品中文在线影院| 国产福利精品导航| 91精品国产综合久久婷婷香蕉| 日韩毛片精品高清免费| 国产伦精一区二区三区| 欧美精品在线视频| 精品一二线国产| 欧美精品丝袜中出| 亚洲视频一二三区| 成人丝袜高跟foot| 久久精品亚洲一区二区三区浴池| 日韩精品免费视频人成| 欧美亚洲国产怡红院影院| 国产精品成人一区二区艾草 | 91精品欧美福利在线观看| 亚洲欧美日本在线| 99久久99久久久精品齐齐| 国产三级精品三级在线专区| 理论片日本一区| 日韩一区二区在线播放| 亚洲v中文字幕| 欧美日韩国产在线播放网站| 亚洲自拍另类综合| 91黄色激情网站| 亚洲一区自拍偷拍| 91色porny在线视频| 亚洲色图色小说| 99精品欧美一区二区蜜桃免费| 中文字幕在线观看不卡| 成人午夜视频在线观看| 国产精品毛片久久久久久| 国产一区二区成人久久免费影院| 精品国产一区二区三区久久久蜜月| 日本欧美久久久久免费播放网| 91精品婷婷国产综合久久性色 | 欧美性淫爽ww久久久久无| 亚洲色图在线播放| 色激情天天射综合网| 一区二区三区美女| 欧美揉bbbbb揉bbbbb| 天堂av在线一区| 欧美大片顶级少妇| 国产剧情一区在线| 国产日韩欧美高清在线| 成人免费毛片app| 亚洲日本成人在线观看| 在线观看日韩精品| 无吗不卡中文字幕| 欧美va亚洲va| 国产成人久久精品77777最新版本| 中文字幕精品—区二区四季| 不卡视频一二三| 亚洲综合久久av| 欧美乱妇15p| 欧美一级免费大片| 青青草原综合久久大伊人精品| 久久久久久久网| 26uuu国产日韩综合| 欧美日韩一区二区欧美激情| 不卡电影一区二区三区| 成人晚上爱看视频| 亚洲一区二区精品3399| 亚洲欧美一区二区视频| 国产人妖乱国产精品人妖| 中文字幕在线不卡视频|