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

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

?? wbxmldecoder.java~4~

?? jwap 協議 udp 可以用于手機通訊
?? JAVA~4~
?? 第 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();
     System.out.println(""+publicIdIndex);
     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 {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
捆绑调教一区二区三区| 国产欧美综合在线观看第十页| 欧美成人猛片aaaaaaa| 一区二区三区欧美久久| 爽好久久久欧美精品| 91亚洲精品久久久蜜桃网站| 精品视频999| 一区二区三区日韩在线观看| 日本不卡视频一二三区| 欧美日韩另类一区| 日本一区二区三区免费乱视频| 久久99精品国产.久久久久久| 欧美电影影音先锋| 天天色综合天天| 99热在这里有精品免费| 国产精品嫩草影院com| 天天射综合影视| 69堂国产成人免费视频| 国产精品久久夜| 91视视频在线直接观看在线看网页在线看| 欧美丝袜丝交足nylons图片| 亚洲免费av网站| 欧美日韩久久不卡| 精品一区二区在线播放| 亚洲国产成人一区二区三区| 日本亚洲三级在线| 精品免费一区二区三区| 国产成人精品一区二区三区网站观看 | 日本欧美肥老太交大片| 日韩精品一区二区三区在线| 亚洲黄色av一区| 欧美日韩亚洲国产综合| 亚洲一区二区三区精品在线| 成人av先锋影音| 91小视频免费看| 4438亚洲最大| 国产欧美日韩不卡| 色婷婷狠狠综合| 久久国产精品免费| 亚洲日穴在线视频| 亚洲成人777| 成人午夜激情片| 成人综合在线网站| 一二三区精品视频| 欧美色精品在线视频| 色婷婷国产精品久久包臀| 欧美日韩一本到| 久久久噜噜噜久噜久久综合| 日韩美女主播在线视频一区二区三区| 不卡电影一区二区三区| 国产午夜亚洲精品不卡| 国产精品一区专区| av男人天堂一区| 欧美性大战久久久久久久蜜臀| 亚洲mv在线观看| 日韩欧美123| 久久精品久久综合| 亚洲天堂2014| 在线不卡的av| 亚洲国产精品尤物yw在线观看| 韩国av一区二区三区在线观看| 狠狠网亚洲精品| 欧美成人欧美edvon| 国产精品久久久久久久裸模| 美女视频一区在线观看| 日韩精品一二三| 婷婷中文字幕综合| 亚洲啪啪综合av一区二区三区| 综合精品久久久| 国产精品视频在线看| 国产不卡视频一区二区三区| 欧美国产日韩精品免费观看| 欧美成人精品福利| 欧美偷拍一区二区| 成人av免费在线播放| 亚洲精品一区二区三区香蕉| 手机精品视频在线观看| 91麻豆精品视频| 欧美乱妇15p| 国产亚洲精品福利| 风间由美性色一区二区三区| 日本成人在线一区| 欧美日韩一区高清| 国产91综合一区在线观看| 国产精品18久久久久久久网站| 精品播放一区二区| 99热这里都是精品| 日韩美女久久久| 在线不卡中文字幕| 欧美网站大全在线观看| www.66久久| 色综合av在线| 欧美日韩国产精品成人| 精品无人码麻豆乱码1区2区| 五月婷婷另类国产| 蜜臀久久99精品久久久久宅男| 国产精品久久久久久久久免费丝袜| 久久奇米777| 18成人在线视频| 69堂精品视频| ww亚洲ww在线观看国产| 国产三级精品三级在线专区| 91小视频免费看| 韩国成人精品a∨在线观看| 成人激情动漫在线观看| 日本在线不卡一区| 亚洲人成精品久久久久| 午夜精品久久久久久久久久| 久久丁香综合五月国产三级网站| 国产一区二区免费视频| 亚州成人在线电影| 国产又粗又猛又爽又黄91精品| 欧美激情在线一区二区三区| 亚洲123区在线观看| 91丨九色丨黑人外教| 国产一区免费电影| 蜜桃av噜噜一区| 美脚の诱脚舐め脚责91| 成人动漫一区二区| 中文字幕中文字幕一区二区| 欧美日韩一区不卡| 国产精品素人一区二区| 欧美日韩欧美一区二区| 日韩一区中文字幕| 欧美日韩美女一区二区| 亚洲国产精品一区二区久久| 69av一区二区三区| 国产精品一区二区在线观看网站| 一区二区三区日本| 精品av久久707| 91精品久久久久久蜜臀| 国产91综合网| 99久久国产免费看| 国产精品国产三级国产| 亚洲国产激情av| 国产精品一区久久久久| 亚洲成a人片在线观看中文| 欧美人牲a欧美精品| 天天影视涩香欲综合网| 国产精品不卡一区二区三区| 欧美电影一区二区| 久久久一区二区| 欧美videossexotv100| 精品国产免费久久| 日韩亚洲欧美在线观看| 国产河南妇女毛片精品久久久| 国产真实乱偷精品视频免| 久久99久久99| 99久久精品久久久久久清纯| www.av亚洲| 欧美久久高跟鞋激| 欧美成人一区二区三区| 亚洲精品在线三区| 久久久精品人体av艺术| 国产三级一区二区| 亚洲五码中文字幕| 一区二区三区成人在线视频| 经典一区二区三区| 大尺度一区二区| 欧美一区二区三区在线电影| 日韩欧美一级二级三级| 亚洲人成在线播放网站岛国 | 欧美视频日韩视频| 日本韩国精品在线| wwww国产精品欧美| 国产精品午夜在线| 亚洲成av人**亚洲成av**| 美女视频网站黄色亚洲| 亚洲国产精品成人综合| 免费在线视频一区| 国产一区二区三区| 欧美日韩高清一区二区三区| 欧美一级黄色录像| 亚洲国产成人av| 国产原创一区二区| 91麻豆免费在线观看| 99久久精品国产精品久久| 欧美精品自拍偷拍动漫精品| 久久久99久久精品欧美| 亚洲欧美在线观看| 午夜免费久久看| 在线观看欧美日本| 久久久国产精品午夜一区ai换脸| 日韩中文字幕亚洲一区二区va在线| 国产美女视频一区| www国产成人| 亚洲国产一区在线观看| 色呦呦国产精品| 久久色在线视频| 久久99日本精品| 91成人在线免费观看| 一区二区三区精品在线观看| 精品午夜久久福利影院| 日韩欧美在线观看一区二区三区| 中文字幕一区二区三区四区不卡| 岛国一区二区三区| 欧美一区二区二区| 久久精品国产澳门| 99精品在线观看视频| 亚洲欧洲精品一区二区精品久久久 |