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

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

?? wbxmldecoder.java~9~

?? jwap 協議 udp 可以用于手機通訊
?? JAVA~9~
?? 第 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);

     byte maskedTokenValue = (byte) 0;
               try {
                 maskedTokenValue = this.wbxmlStream.readByte();
               }
               catch (IOException ex) {
               }
               byte actualTokenValue = getTokenValue(maskedTokenValue);
               String rootElementName = tokenRepository.getTagName(actualTokenValue);



     }
     catch (IOException ex) {
     }

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

        }


	/**
	 *  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) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区导航在线播放| 91网上在线视频| 国产精品自拍三区| a美女胸又www黄视频久久| 色婷婷综合久久久中文一区二区| 欧美熟乱第一页| 久久美女艺术照精彩视频福利播放 | 国产在线视频一区二区| 成人性生交大片免费看在线播放| 91麻豆免费看片| 精品福利一区二区三区免费视频| 日韩久久一区二区| 国产一区二区三区四区五区美女| 成人精品一区二区三区中文字幕| 懂色av一区二区三区免费观看| 欧美视频第二页| 一区二区激情小说| 91天堂素人约啪| 中文字幕亚洲电影| 国产成人8x视频一区二区 | 亚洲老司机在线| 成人理论电影网| 久久久久国产精品麻豆| 午夜免费欧美电影| 欧美三级日韩三级| 亚洲一区二区三区在线| 一本一道综合狠狠老| 国产精品网站在线观看| jlzzjlzz欧美大全| 成人欧美一区二区三区1314| 粉嫩在线一区二区三区视频| 久久久精品国产99久久精品芒果 | 欧美丰满嫩嫩电影| 国产成人小视频| 国产一区不卡在线| 精品视频在线免费看| 亚洲午夜久久久久久久久电影网| 日本福利一区二区| 亚洲丝袜精品丝袜在线| 一本一本大道香蕉久在线精品 | 一本久久a久久免费精品不卡| 国产精品美女视频| 91久久精品一区二区三| 丝袜美腿亚洲一区二区图片| 91精品国产乱码久久蜜臀| 美国三级日本三级久久99 | 99久久精品情趣| 婷婷夜色潮精品综合在线| 欧美mv日韩mv国产| 成人app网站| 日av在线不卡| 亚洲日本青草视频在线怡红院| 在线不卡一区二区| 国产精品综合一区二区| 亚洲一级二级三级| 国产三级一区二区| 制服丝袜亚洲网站| 99久久99精品久久久久久| 免费国产亚洲视频| 一区二区三区电影在线播| 国产午夜精品久久久久久久 | 国产综合成人久久大片91| 一区二区三区加勒比av| 欧美国产综合一区二区| 欧美成人一区二区三区在线观看| 色综合久久88色综合天天6| 国产一区二区三区不卡在线观看 | 亚洲精品一线二线三线| 一本到一区二区三区| 懂色av中文字幕一区二区三区 | 久久久久久亚洲综合影院红桃 | 国产黑丝在线一区二区三区| 亚洲一卡二卡三卡四卡| 亚洲天堂福利av| 亚洲三级小视频| 亚洲乱码国产乱码精品精98午夜 | 91视频免费观看| 91色porny在线视频| av一本久道久久综合久久鬼色| 国产一区二区福利| 高清国产一区二区| 日本久久一区二区| 欧美日韩亚洲高清一区二区| 欧美日韩一区中文字幕| 日韩欧美国产电影| 国产欧美一区二区精品久导航| 日本一区二区久久| 一区二区三区中文在线观看| 夜夜精品浪潮av一区二区三区 | 在线观看不卡一区| 欧美日韩aaaaaa| 日韩欧美高清在线| 最新国产成人在线观看| 婷婷综合久久一区二区三区| 国产一区二区网址| 在线视频一区二区免费| 久久综合五月天婷婷伊人| 国产精品视频一二三| 亚洲一区影音先锋| 国产 日韩 欧美大片| 欧美日韩在线免费视频| 国产人久久人人人人爽| 亚洲国产综合视频在线观看| 日韩精品一二三| 波多野结衣一区二区三区| 制服丝袜成人动漫| 亚洲日本中文字幕区| 国产精品一区免费视频| 欧美二区三区91| 亚洲一区二区三区中文字幕在线| 高清不卡一区二区在线| 精品国产sm最大网站免费看| 午夜精彩视频在线观看不卡| 99国产精品国产精品久久| 国产性色一区二区| 在线精品视频免费播放| 亚洲另类中文字| 欧美三级电影网| 午夜精品免费在线| 日韩一级完整毛片| 久久狠狠亚洲综合| 欧美精品一区二区精品网| 免费视频一区二区| 日韩精品一区二区在线| 麻豆一区二区三| 久久久久国产成人精品亚洲午夜| 久久激情综合网| 国产欧美一区二区精品秋霞影院| 黄色资源网久久资源365| 精品精品欲导航| 国产成人免费视频| ...av二区三区久久精品| 成人sese在线| 亚洲午夜影视影院在线观看| 51精品国自产在线| 国产精品主播直播| 亚洲欧美日韩久久| 欧美久久久久久久久中文字幕| 秋霞成人午夜伦在线观看| 亚洲精品在线观| 日本韩国一区二区| 国产综合色产在线精品| 亚洲制服丝袜在线| 国产亚洲成av人在线观看导航| 福利91精品一区二区三区| 亚洲图片另类小说| 久久嫩草精品久久久精品一| 色综合久久综合网97色综合| 麻豆国产精品777777在线| 国产精品传媒在线| 欧美成人一区二区三区片免费| 色域天天综合网| 成人免费看视频| 美女在线观看视频一区二区| 亚洲午夜私人影院| 中文字幕欧美一区| 亚洲国产欧美一区二区三区丁香婷| 久久久www免费人成精品| 欧美一区二区视频在线观看2020| 国产一区二区免费视频| 午夜亚洲福利老司机| 亚洲国产日韩a在线播放| 中文字幕中文字幕一区二区| 国产欧美精品一区二区三区四区 | 国产精品影视在线| 免费高清视频精品| 另类专区欧美蜜桃臀第一页| 日韩精彩视频在线观看| 亚洲一二三四区| 亚洲成年人影院| 成人性视频免费网站| www.欧美精品一二区| 97se狠狠狠综合亚洲狠狠| 99国产精品久久久久久久久久久 | 亚洲大片精品永久免费| 亚洲444eee在线观看| 人人狠狠综合久久亚洲| 麻豆成人在线观看| 懂色一区二区三区免费观看| thepron国产精品| 欧美主播一区二区三区| 91精品国产综合久久精品| 精品欧美一区二区在线观看| 久久亚洲捆绑美女| 亚洲欧美韩国综合色| 日本91福利区| 972aa.com艺术欧美| 欧美一区二区三区四区视频| 久久综合国产精品| 亚洲综合一区二区精品导航| 韩国欧美一区二区| 麻豆精品国产传媒mv男同| 亚洲国产综合人成综合网站| 亚洲午夜免费福利视频| 日本一区二区动态图| 午夜精品一区在线观看| 在线播放国产精品二区一二区四区| 亚洲中国最大av网站| 欧美男生操女生| 国产一区二区三区av电影|