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

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

?? wbxmldecoder.java~10~

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

               }



     }
     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一区二区三区免费野_久草精品视频
欧美一区二区三区免费大片| 狠狠色2019综合网| 欧美日韩精品一区二区三区| 欧美大片免费久久精品三p| 日韩三级.com| 精品国产电影一区二区| 精品国产乱码久久久久久1区2区| www精品美女久久久tv| 美美哒免费高清在线观看视频一区二区| 九九精品视频在线看| 国产伦精品一区二区三区免费迷 | 一本到一区二区三区| 色综合一区二区| 91麻豆精品91久久久久同性| 久久九九国产精品| 欧美国产精品一区二区三区| 亚洲天堂网中文字| 另类中文字幕网| 91丨九色丨国产丨porny| 欧美午夜寂寞影院| 日本一区二区免费在线观看视频| 亚洲欧美经典视频| 久久久夜色精品亚洲| 亚洲第一在线综合网站| 国产91丝袜在线播放| 欧美日韩免费不卡视频一区二区三区| 中文字幕av不卡| 精品久久久久久久久久久久久久久久久 | 欧美日韩大陆一区二区| 久久久久亚洲蜜桃| 国产欧美日产一区| 亚洲成人激情av| 国产成人精品影视| 欧美日韩国产高清一区| 久久久久久久国产精品影院| 国产精品美女www爽爽爽| 国产aⅴ综合色| 欧美丰满美乳xxx高潮www| 国产欧美日韩另类一区| 图片区日韩欧美亚洲| 丁香婷婷综合网| 成人黄色免费短视频| 色婷婷久久99综合精品jk白丝| 日韩三级.com| 国产在线精品免费av| 欧美日韩一区久久| 亚洲精品乱码久久久久久黑人| 国产精品资源站在线| 91精品国产一区二区人妖| 蜜臀久久99精品久久久久久9| 91国偷自产一区二区开放时间| 久久众筹精品私拍模特| 日一区二区三区| 日本国产一区二区| 亚洲一区二区欧美激情| 91免费视频观看| 亚洲精品在线免费观看视频| 亚洲电影视频在线| 欧美午夜一区二区三区| 青青草原综合久久大伊人精品优势 | 高清av一区二区| 视频一区二区欧美| 成人白浆超碰人人人人| 久久久精品免费观看| 国产精品一区三区| 777午夜精品免费视频| 国内一区二区在线| 久久精品一区蜜桃臀影院| 黑人巨大精品欧美一区| 久久综合久久综合亚洲| 国产原创一区二区| 亚洲激情自拍视频| 欧美视频一区二区三区在线观看| 一区二区成人在线视频| 欧美午夜精品一区二区三区| 亚洲手机成人高清视频| 欧美一区二区视频在线观看 | 精品在线观看视频| 欧美精品一区二区三区高清aⅴ| 久久久久久99精品| 日本免费在线视频不卡一不卡二| 4438成人网| 国产一区三区三区| 国产精品嫩草影院com| 不卡的av网站| 久久99日本精品| 精品久久国产老人久久综合| 国产综合成人久久大片91| 国产欧美日韩另类视频免费观看| 4438x成人网最大色成网站| 国产一区二区三区免费播放| 国产精品电影一区二区| 色综合天天性综合| 国产精品三级电影| 日韩精品一区二区三区老鸭窝| 国产精品18久久久久久久网站| 国产精品久久久久久亚洲毛片 | 亚洲高清免费观看高清完整版在线观看 | 国产精品伦一区| 欧美无砖砖区免费| 国内精品自线一区二区三区视频| 日本在线不卡视频一二三区| 欧洲一区二区av| 免费在线观看视频一区| 中文字幕一区二| 欧美最猛性xxxxx直播| 久久国产精品第一页| 日本一区二区三区国色天香| 在线看一区二区| 国产精品情趣视频| 91精品国产91久久久久久一区二区| 国产一区二区三区四区五区美女 | 日日夜夜精品视频免费| 国产日产亚洲精品系列| 欧美系列日韩一区| 亚洲一区二区中文在线| 久久久天堂av| 欧美日韩1234| aaa欧美大片| 久久av中文字幕片| 亚洲成人av中文| 欧美成人video| 国产精品一区2区| 日本欧美在线看| 中文字幕一区在线观看| 一本一道综合狠狠老| 麻豆精品精品国产自在97香蕉| 一区二区三区中文字幕电影| 亚洲中国最大av网站| 国产精品免费视频网站| 1024成人网色www| 欧美激情在线观看视频免费| 国产精品毛片高清在线完整版| 日韩视频免费观看高清完整版在线观看 | 91麻豆精品国产91久久久久| 67194成人在线观看| 欧美在线看片a免费观看| 777奇米四色成人影色区| 欧美优质美女网站| 日韩一区二区三区四区五区六区| 欧美日韩精品系列| 精品国产免费久久| 精品剧情在线观看| 亚洲欧洲色图综合| 综合分类小说区另类春色亚洲小说欧美 | 成人性视频网站| 日本道免费精品一区二区三区| 成人精品高清在线| 在线不卡的av| 91精品国产综合久久小美女| 天堂久久久久va久久久久| 久久久久久久久一| 国产精品福利在线播放| 亚洲三级在线看| 美国欧美日韩国产在线播放| 国产综合色在线| 久久97超碰色| 国产麻豆日韩欧美久久| 精品免费一区二区三区| 国产精品免费丝袜| 亚洲欧美国产三级| 国产一区不卡精品| 国产福利一区二区| 91精品免费观看| 久久综合狠狠综合久久综合88 | 亚洲欧美成人一区二区三区| 最新中文字幕一区二区三区| 久久电影网站中文字幕| 国产乱子轮精品视频| 欧美日韩在线观看一区二区| 制服丝袜一区二区三区| 亚洲一区免费观看| 视频一区中文字幕| 不卡欧美aaaaa| 欧美色老头old∨ideo| 中文字幕一区二区三| 亚洲国产婷婷综合在线精品| 成人国产在线观看| 欧美日韩精品专区| 亚洲免费高清视频在线| 免费av网站大全久久| 在线观看一区二区视频| 精品国产一二三| 偷拍与自拍一区| 成人国产免费视频| 一区二区三区.www| 国产成人亚洲综合色影视| 精品亚洲国内自在自线福利| 欧美理论片在线| 中文在线一区二区| 丁香婷婷深情五月亚洲| 色欧美片视频在线观看| 亚洲色图制服丝袜| 久久99日本精品| 欧美一区中文字幕| 亚洲欧美经典视频| 色噜噜狠狠一区二区三区果冻| 欧美日韩国产区一| 免费看日韩a级影片| 91在线无精精品入口|