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

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

?? wbxmldecoder.java~11~

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

               if(rootElementName.equals("wml"))
               {
                   ret=0;
               }



     }
     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))

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本最新不卡在线| 国产suv精品一区二区883| 欧美在线小视频| 国产成人高清视频| 日韩精品一区二区三区中文精品| 视频一区二区国产| 欧美日韩在线三级| 亚洲香肠在线观看| 欧美日韩一区二区三区在线看| 亚洲影院久久精品| 欧美午夜精品一区二区蜜桃| 亚洲一区二区美女| 欧美欧美欧美欧美| 日本va欧美va欧美va精品| 91麻豆精品国产91| 免费观看成人av| 精品久久人人做人人爰| 国产一区二区在线观看视频| 久久久久久久久久美女| 国产成人精品午夜视频免费| 国产欧美日本一区视频| 波多野洁衣一区| 亚洲欧美日本在线| 欧美在线一二三| 午夜精品视频一区| 欧美大片免费久久精品三p | 亚洲色欲色欲www在线观看| jizzjizzjizz欧美| 亚洲乱码中文字幕综合| 欧美日韩免费一区二区三区 | 久国产精品韩国三级视频| 精品久久五月天| 国产mv日韩mv欧美| 樱花影视一区二区| 7777女厕盗摄久久久| 美脚の诱脚舐め脚责91| 久久午夜电影网| 成人av片在线观看| 亚洲午夜精品17c| 日韩欧美高清dvd碟片| 国产河南妇女毛片精品久久久| 成人欧美一区二区三区在线播放| 色拍拍在线精品视频8848| 亚洲一区二区三区四区在线观看| 欧美精品1区2区| 国产成人综合亚洲网站| 国产精品久久久久久久第一福利| 色成年激情久久综合| 日韩精品三区四区| 国产性色一区二区| 欧美在线你懂的| 久久精品国产亚洲a| 国产精品女主播av| 欧美人与性动xxxx| 国产精品一区久久久久| 亚洲欧美另类综合偷拍| 欧美日本韩国一区二区三区视频| 国产精品亚洲一区二区三区妖精| 亚洲欧美日韩一区| 日韩欧美国产综合| 91免费国产在线观看| 奇米精品一区二区三区在线观看一| 国产喷白浆一区二区三区| 欧美在线free| 国产麻豆精品95视频| 亚洲国产综合色| 日日夜夜一区二区| 国产精品国产三级国产a| 欧美一级专区免费大片| 本田岬高潮一区二区三区| 日韩和的一区二区| 中文字幕一区二区三区乱码在线| 日韩欧美一级在线播放| 在线免费精品视频| 国产精品亚洲第一区在线暖暖韩国| 亚洲第一狼人社区| 国产精品欧美极品| 日韩免费看的电影| 在线免费观看成人短视频| 国产美女在线精品| 丝袜亚洲另类丝袜在线| 国产精品免费网站在线观看| 欧美sm美女调教| 精品视频1区2区| av成人动漫在线观看| 精品一区二区免费| 亚洲午夜国产一区99re久久| 国产精品日产欧美久久久久| 日韩欧美卡一卡二| 欧美性感一区二区三区| 成人免费电影视频| 激情综合五月婷婷| 婷婷一区二区三区| 亚洲欧美色一区| 中文字幕欧美国产| 欧美精品一区二区三区一线天视频 | 成人午夜免费视频| 毛片av一区二区| 亚洲电影第三页| 亚洲欧美国产毛片在线| 国产免费观看久久| 欧美大片顶级少妇| 91精品免费在线观看| 欧洲精品在线观看| 91首页免费视频| 成人免费毛片嘿嘿连载视频| 国产在线国偷精品产拍免费yy| 三级影片在线观看欧美日韩一区二区| 亚洲综合免费观看高清完整版 | 亚洲国产精品久久久男人的天堂| 成人欧美一区二区三区视频网页| 国产日产欧美一区二区三区| 久久综合网色—综合色88| 日韩一二三区不卡| 8v天堂国产在线一区二区| 在线观看国产一区二区| 色婷婷激情一区二区三区| a4yy欧美一区二区三区| 成人高清免费在线播放| 成人激情小说网站| 成人午夜电影网站| 国产成人免费视频网站高清观看视频| 久久99日本精品| 老司机精品视频线观看86| 日韩av成人高清| 免费在线成人网| 免费精品视频在线| 美洲天堂一区二卡三卡四卡视频| 日韩影院免费视频| 日韩精品久久久久久| 天天色天天爱天天射综合| 天堂久久一区二区三区| 午夜精品免费在线| 日韩电影在线看| 奇米色一区二区| 蜜桃一区二区三区在线| 黑人巨大精品欧美一区| 国产精品18久久久久| 国产成人综合精品三级| 成人av在线一区二区三区| 成人sese在线| 色欧美乱欧美15图片| 欧美中文字幕不卡| 3d成人h动漫网站入口| 欧美一卡二卡在线观看| 精品电影一区二区三区| 久久久不卡网国产精品二区| 欧美激情一区二区三区全黄| 成人欧美一区二区三区小说| 一区二区三区电影在线播| 亚洲成人久久影院| 青青青伊人色综合久久| 久久99久久精品| 国产99精品视频| 亚洲国产精品v| 一区二区国产视频| 日精品一区二区三区| 激情综合色丁香一区二区| 成人性生交大片免费看中文 | 99久久免费精品| 欧美自拍偷拍午夜视频| 日韩一区二区三区在线视频| 久久精品人人爽人人爽| 亚洲色图视频免费播放| 亚洲成人动漫在线免费观看| 精品一区二区三区久久久| 成人综合婷婷国产精品久久蜜臀| 在线中文字幕不卡| 日韩欧美美女一区二区三区| 国产精品丝袜在线| 香蕉av福利精品导航| 国产一区在线视频| 色综合久久88色综合天天免费| 91麻豆精品国产91久久久资源速度| 亚洲精品一区二区三区蜜桃下载| 国产精品成人免费在线| 亚洲h动漫在线| 国产69精品一区二区亚洲孕妇| 在线免费观看视频一区| 精品国产乱码久久久久久免费| 亚洲欧美综合色| 青青草成人在线观看| 成人黄色在线网站| 欧美日韩精品久久久| 国产人成亚洲第一网站在线播放| 亚洲永久精品国产| 国产精品一区二区你懂的| 91成人在线观看喷潮| 亚洲精品一线二线三线| 亚洲一区二区三区不卡国产欧美| 国产一区二区免费看| 欧美午夜精品久久久久久超碰| 精品久久久久av影院| 亚洲精品免费在线| 国产乱码字幕精品高清av| 欧美少妇bbb| 中文字幕第一区| 男人的j进女人的j一区| 色欧美日韩亚洲| 国产欧美日韩久久|