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

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

?? wbxmldecoder.java~6~

?? jwap 協議 udp 可以用于手機通訊
?? JAVA~6~
?? 第 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 int decodeFowChk(InputStream wbxmlStream) {
            int ret=0;
                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一区二区三区免费野_久草精品视频
亚洲欧美在线高清| 久草在线在线精品观看| 又紧又大又爽精品一区二区| 亚洲国产精品久久不卡毛片| 天堂成人国产精品一区| 久久成人久久鬼色| www.在线成人| 69av一区二区三区| 亚洲国产精品v| 日韩av中文字幕一区二区三区| 不卡视频一二三四| 欧美日韩不卡在线| 欧美国产禁国产网站cc| 午夜视频一区二区三区| 成人三级在线视频| 日韩免费高清电影| 一区二区三区在线视频免费观看| 久久99国内精品| 91精品久久久久久久久99蜜臂| 中文字幕va一区二区三区| 日韩vs国产vs欧美| 欧美日韩中字一区| 自拍偷拍国产亚洲| 成人高清伦理免费影院在线观看| 日韩欧美中文字幕公布| 亚洲va韩国va欧美va| 一本大道综合伊人精品热热| 国产亚洲一区二区三区| 免费观看在线色综合| 欧美性高清videossexo| 亚洲黄色小说网站| 欧亚一区二区三区| 亚洲专区一二三| 欧美性大战久久久久久久蜜臀| 亚洲欧美激情小说另类| 一本到高清视频免费精品| 国产精品国产三级国产aⅴ原创| 高清视频一区二区| 久久精品亚洲精品国产欧美| 激情欧美一区二区| 久久久久国产精品麻豆| 国产成人精品免费视频网站| 国产亚洲精品久| 成人在线一区二区三区| 日韩理论在线观看| 在线看日韩精品电影| 午夜免费久久看| 久久综合色一综合色88| 丁香婷婷综合色啪| 亚洲精品伦理在线| 欧美一区二区三区小说| 国产一区欧美一区| 中文字幕久久午夜不卡| 91黄色免费观看| 经典三级在线一区| 亚洲日本在线a| 日韩欧美久久久| 成人短视频下载| 一区二区高清免费观看影视大全 | 久久久噜噜噜久久人人看| 国产成人鲁色资源国产91色综 | 国产老妇另类xxxxx| 亚洲乱码国产乱码精品精小说| 欧美一区二区三区人| 国产在线视频一区二区| 成人欧美一区二区三区1314| 日韩欧美视频一区| 91碰在线视频| 国产在线播放一区| 五月婷婷综合网| 一区在线中文字幕| 久久久久久久久一| 欧美日韩综合在线免费观看| 成人动漫精品一区二区| 日韩激情视频网站| 久久久久久一级片| 欧美伊人久久大香线蕉综合69| 毛片不卡一区二区| 国产精品久久精品日日| 欧美另类变人与禽xxxxx| 国产精品自在欧美一区| 午夜视频在线观看一区| 国产精品久久久久影院色老大| 欧美一区二区三区免费| 一本大道综合伊人精品热热| a级高清视频欧美日韩| 另类调教123区| 午夜伦理一区二区| 亚洲乱码一区二区三区在线观看| 国产欧美一区二区三区网站| 欧美精品色一区二区三区| 成人18视频在线播放| 久久aⅴ国产欧美74aaa| 亚洲成人免费影院| 一区二区三区精品视频| 久久亚洲综合av| 精品国产欧美一区二区| 777a∨成人精品桃花网| 在线观看网站黄不卡| 色94色欧美sute亚洲线路一ni| 成人在线综合网站| 国产suv一区二区三区88区| 免费观看成人鲁鲁鲁鲁鲁视频| 又紧又大又爽精品一区二区| 亚洲日本成人在线观看| 中文字幕一区二区在线观看| 欧美激情一区二区三区不卡| 2020国产精品久久精品美国| 精品国一区二区三区| 欧美成人伊人久久综合网| 日韩女优制服丝袜电影| 日韩西西人体444www| 精品少妇一区二区三区在线播放| 精品国产欧美一区二区| 日本一区二区三区免费乱视频 | 男人的j进女人的j一区| 老司机免费视频一区二区| 久久99在线观看| 国产成人啪午夜精品网站男同| 国产九色精品成人porny| 99在线精品一区二区三区| 欧洲精品在线观看| 日韩免费观看高清完整版| 日本一区二区在线不卡| 亚洲欧美激情小说另类| 亚洲大片在线观看| 久久激情五月激情| 粉嫩蜜臀av国产精品网站| 色综合天天综合狠狠| 911精品国产一区二区在线| 国产网站一区二区| 亚洲午夜激情av| 国产精品夜夜爽| 欧美日韩一区二区在线观看| 久久久一区二区三区捆绑**| 国产精品成人午夜| 国产综合久久久久影院| 欧美亚洲综合一区| 国产精品每日更新在线播放网址 | 岛国精品在线观看| 这里只有精品电影| 亚洲综合免费观看高清完整版 | 亚洲欧美综合网| 国产伦精品一区二区三区视频青涩| 色哟哟亚洲精品| 欧美国产欧美亚州国产日韩mv天天看完整 | 日韩一区二区免费在线观看| 一区二区三区四区精品在线视频| 99热国产精品| 亚洲在线视频网站| 欧美影视一区在线| 美女网站视频久久| 日韩三级av在线播放| 国产剧情av麻豆香蕉精品| 国产精品三级av在线播放| 99re这里只有精品首页| 亚洲综合免费观看高清完整版| 欧美色图天堂网| 男女男精品网站| 国产婷婷色一区二区三区在线| 成人av片在线观看| 亚洲一区二区在线免费观看视频| 欧美人牲a欧美精品| 美女精品自拍一二三四| 欧美国产一区视频在线观看| 91九色最新地址| 美日韩黄色大片| 欧美激情一区二区| 欧美日韩卡一卡二| 国产精品99久久不卡二区| 综合分类小说区另类春色亚洲小说欧美| 色综合天天视频在线观看| 美美哒免费高清在线观看视频一区二区 | 肉肉av福利一精品导航| 中文字幕第一区第二区| 欧美久久久久久久久| 粉嫩aⅴ一区二区三区四区| 亚洲综合视频网| 久久精品亚洲精品国产欧美kt∨| 欧美视频在线观看一区| 国产**成人网毛片九色| 免费成人av资源网| 亚洲最大成人网4388xx| 国产亚洲成av人在线观看导航| 欧美日本在线看| 在线观看日韩国产| 国产成人综合在线观看| 老司机精品视频导航| 国产精品久久久久国产精品日日| 日韩欧美色电影| 欧美网站一区二区| av中文字幕在线不卡| 国产成人精品www牛牛影视| 国产呦萝稀缺另类资源| 日韩和欧美一区二区三区| 亚洲自拍偷拍欧美| 亚洲男人的天堂在线aⅴ视频| 自拍av一区二区三区| 国产精品视频线看| 国产精品不卡一区二区三区|