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

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

?? xmlwriter.java

?? java servlet著名論壇源代碼
?? JAVA
字號:
/*
 * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/importexport/XMLWriter.java,v 1.2 2004/01/18 19:13:10 minhnn Exp $
 * $Author: minhnn $
 * $Revision: 1.2 $
 * $Date: 2004/01/18 19:13:10 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002-2004 by MyVietnam.net
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * All copyright notices regarding mvnForum MUST remain intact
 * in the scripts and in the outputted HTML.
 * The "powered by" text/logo with a link back to
 * http://www.mvnForum.com and http://www.MyVietnam.net in the
 * footer of the pages MUST remain visible when the pages
 * are viewed on the internet or intranet.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Support can be obtained from support forums at:
 * http://www.mvnForum.com/mvnforum/index
 *
 * Correspondence and Marketing Questions can be sent to:
 * info@MyVietnam.net
 *
 * @author: Igor Manic   imanic@users.sourceforge.net
 */
package com.mvnforum.admin.importexport;

import java.io.*;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.myvietnam.mvncore.exception.ExportException;

/**
 * @author <a href="mailto:imanic@users.sourceforge.net">Igor Manic</a>
 * @version $Revision: 1.2 $, $Date: 2004/01/18 19:13:10 $
 * <br/>
 * <code>XMLWriter</code> class encapsulates methods for creating and writing
 * data to XML files with automatic indentation and special characters encoding.
 */
public class XMLWriter {

    /** Message log. */
    private static Log log = LogFactory.getLog(XMLWriter.class);

    private static String lineSeparator=System.getProperty("line.separator", "\n");
    private StringBuffer textBuffer;
    private int indentLevel=0; //current XML element level
    private String indentString=""; //indent string for each next level of XML output
    private OutputStreamWriter outWriter=null;
    private boolean startedNewElement=false;

    private XMLWriter() {
        super();
        textBuffer=null;
        indentLevel=0; indentString="";
        outWriter=null;
        startedNewElement=false;
    }

    public XMLWriter(String indentString, OutputStreamWriter outWriter) {
        this();
        this.indentString=indentString;
        this.outWriter=outWriter;
    }

    public XMLWriter(String indentString, File outputFile)
    throws ExportException {
        this();
        this.indentString=indentString;
        log.debug("Setting output to file \""+outputFile.getAbsolutePath()+"\"");
        if (!outputFile.exists())
            try {
                outputFile.createNewFile();
            } catch (IOException e) {
                log.error("XML output could not be created.");
                throw new ExportException("Error on server: "+
                      "Can't make XML output file.", e);
            }
        else if (!outputFile.isFile()) {
            log.error("XML output is not a file (it's probably directory).");
            throw new ExportException("Error on server: "+
                  "XML output is not a file (it's probably directory).");
        }
        if (!outputFile.canWrite()) {
            log.error("XML output file can't be written to.");
            throw new ExportException("Error on server: "+
                  "XML output file can't be written to.");
        } else {
            try {
                java.io.OutputStream outStream=new FileOutputStream(outputFile);
                this.outWriter=new OutputStreamWriter(outStream, "UTF8");
            } catch (FileNotFoundException e) {
                log.error("XML output file can't be found.");
                throw new ExportException("Error on server: "+
                      "XML output file can't be found.", e);
            } catch (UnsupportedEncodingException e) {
                log.error("UTF8 is unsupported encoding for XML output.");
                throw new ExportException("Error on server: "+
                      "Can't make XML output file.", e);
            }
        }
    }

    public XMLWriter(String indentString, String fileName)
    throws ExportException {
        this(indentString, new File(fileName));
    }


    public void close() throws IOException {
        outputFlush();
        if (outWriter!=null) outWriter.close();
    }

    public void startDocument(String dtdschemaDecl) throws IOException {
        String xmlDecl="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
        startedNewElement=false;
        outputText(xmlDecl); outputNewLine();
        outputText(dtdschemaDecl); outputNewLine();
    }

    public void endDocument() throws IOException {
        processBufferedData();
        outputNewLine();
        outputFlush();
    }

    public void startElement(String elementName)
    throws IOException {
        startElement(elementName, null);
    }

    public void startElement(String elementName, String[] attrNameValue)
    throws IOException {
        processBufferedData();
        outputNewLine();
        outputText("<"+elementName);
        if (attrNameValue!=null) for (int i=0; i<attrNameValue.length-1; i+=2) {
            String attrName=attrNameValue[i];
            String attrValue=attrNameValue[i+1];
            outputText(" ");
            outputText(attrName+"=\""+attrValue+"\"");
        }
        outputText(">");
        indentLevel++;
        //outputNewLine();
        startedNewElement=true;
    }

    public void endElement(String elementName)
    throws IOException {
        processBufferedData();
        indentLevel--;
        if (!startedNewElement) outputNewLine();
        outputText("</"+elementName+">");
        //outputNewLine();
        startedNewElement=false;
    }


    public void writeNewLine() throws IOException {
        outputNewLine();
    }

    public void writeComment(String comment) throws IOException {
        processBufferedData();
        /*if (startedNewElement)*/ outputNewLine();
        outputText("<!-- "+comment+" -->");
        //startedNewElement=false; I should leave this variable, otherwise, if
        //I have more comments one behind another, they'll all be output in
        //one row, one to another, which is bad
    }

    public void writeData(String data) throws IOException {
        if (textBuffer==null) {
            textBuffer=new StringBuffer(data);
        } else {
            textBuffer.append(data);
        }
    }

    public void encodeAndWriteData(String data) throws IOException {
        //we should encode all '<' and '&'
        int amp=data.indexOf('&');
        int lt=data.indexOf('<');
        int i=-1;
        if ((amp>=0) && (lt>=0))  i=(amp<lt)?amp:lt;
        else if (amp>=0) i=amp;
        else i=lt;
        while ((i<data.length()) && (i>=0)) {
            if (i==amp) {
                data=data.substring(0, i)+"&amp;"+data.substring(i+1);
                amp=data.indexOf('&', i+4);
                lt=data.indexOf('<', i+4);
                i+=4; //it should be 5, but nevermind
            } else if (i==lt) {
                data=data.substring(0, i)+"&lt;"+data.substring(i+1);
                amp=data.indexOf('&', i+3);
                lt=data.indexOf('<', i+3);
                i+=3; //it should be 5, but nevermind
            } else {
                log.error("processBufferedRawText(): i=="+i+
                          " is different than both amp=="+amp+" and lt=="+lt+"?!");
                i++;
                amp=data.indexOf('&', i);
                lt=data.indexOf('<', i);
            }
            if ((amp>=0) && (lt>=0))  i=(amp<lt)?amp:lt;
            else if (amp>=0) i=amp;
            else i=lt;
        }

        writeData(data);
    }



// ========================================================
// =================== RAW TEXT OUTPUT ====================
// ========================================================

    private void processBufferedData() throws IOException {
        if (textBuffer==null) return;
        String s=""+textBuffer;
        if (!s.trim().equals("")) textBuffer=null;
        if (s.equals("")) return;

        if (startedNewElement) outputNewLine();
        startedNewElement=false;
        String padding="";
        for (int i=0; i<indentLevel; i++) padding=padding+indentString;
        int pos=s.indexOf(lineSeparator);
        while ((pos<s.length()) && (pos>=0)) {
            s=s.substring(0, pos)+
              lineSeparator+ padding+
              s.substring(pos+lineSeparator.length());
            pos=s.indexOf(lineSeparator, pos+lineSeparator.length());
        }
        outputText(s);
    }

    private void outputText(String s) throws IOException {
        if (outWriter==null) {
            log.error("outputText(): outWriter==null.");
        } else {
            outWriter.write(s);
        }
    }

    private void outputFlush() throws IOException {
        if (outWriter==null) {
            log.error("outputFlush(): outWriter==null.");
        } else {
            outWriter.flush();
        }
    }

    private void outputNewLine() throws IOException {
        if (outWriter==null) {
            log.error("outputNewLine(): outWriter==null.");
        } else {
            outWriter.write(lineSeparator);
            for (int i=0; i<indentLevel; i++) outWriter.write(indentString);
        }
    }


}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产美女精品人人做人人爽| 亚洲人xxxx| 国产精品色在线观看| 亚洲女人的天堂| 日本伊人午夜精品| 国产成人精品三级| 欧美性猛交xxxx黑人交| 欧美大白屁股肥臀xxxxxx| 中文一区二区在线观看| 亚洲国产精品久久久久婷婷884| 久久精品久久久精品美女| 99在线精品一区二区三区| 日韩一二在线观看| 亚洲婷婷国产精品电影人久久| 偷窥少妇高潮呻吟av久久免费| 国产丶欧美丶日本不卡视频| 精品视频全国免费看| 国产亚洲精品aa| 午夜视频在线观看一区| 成人av在线网站| 欧美老女人在线| 亚洲色欲色欲www在线观看| 麻豆91免费看| 91激情在线视频| 久久婷婷久久一区二区三区| 亚洲成va人在线观看| 成人黄色免费短视频| 日韩视频永久免费| 一区二区免费看| 成人av集中营| 久久综合给合久久狠狠狠97色69| 亚洲一区二区欧美日韩| 成人白浆超碰人人人人| 精品成人一区二区三区四区| 亚洲图片有声小说| av亚洲精华国产精华精| 久久这里只有精品6| 日日夜夜精品视频天天综合网| 99综合影院在线| 久久久久九九视频| 蜜桃视频一区二区三区| 欧洲日韩一区二区三区| 国产精品国产三级国产| 国产精品99久久久| 欧美一区二区三区性视频| 亚洲国产中文字幕| 91麻豆免费视频| 中文字幕av一区二区三区免费看 | 91香蕉国产在线观看软件| 精品理论电影在线| 日日夜夜精品视频免费| 欧美三级一区二区| 一区二区三区日韩| 91免费版在线| 亚洲三级电影网站| av不卡在线播放| 中文字幕精品综合| 国产精品一区二区三区99| 欧美成人性福生活免费看| 青青草国产精品97视觉盛宴| 欧美福利视频一区| 香港成人在线视频| 911精品国产一区二区在线| 亚洲一卡二卡三卡四卡| 欧美在线一二三| 一区二区三区电影在线播| 色偷偷久久一区二区三区| 一区二区三区电影在线播| 色哟哟国产精品| 亚洲精品国产a久久久久久| 91小宝寻花一区二区三区| 亚洲老妇xxxxxx| 色综合久久久久久久久久久| 亚洲精品一二三| 欧美午夜一区二区| 亚洲小说春色综合另类电影| 欧美色手机在线观看| 婷婷丁香激情综合| 欧美大黄免费观看| 国产一区二区在线免费观看| 久久久午夜精品| 99久久精品久久久久久清纯| 亚洲精品视频自拍| 欧美区在线观看| 美女爽到高潮91| 国产欧美一区二区三区沐欲| 高清不卡一区二区在线| 亚洲特黄一级片| 欧美三级三级三级爽爽爽| 日本成人在线不卡视频| 久久亚洲捆绑美女| 成人a免费在线看| 亚洲一区中文日韩| 日韩三级在线观看| 国产成人三级在线观看| 亚洲欧美日韩在线不卡| 777久久久精品| 国产精品亚洲视频| 亚洲激情在线激情| 91精品免费在线观看| 国产一区二区福利| 自拍偷拍亚洲欧美日韩| 欧美日韩精品电影| 狠狠色狠狠色合久久伊人| 国产精品日韩成人| 欧美三级蜜桃2在线观看| 麻豆国产精品一区二区三区 | 成人动漫一区二区三区| 亚洲影院在线观看| 欧美成人激情免费网| 99麻豆久久久国产精品免费 | 欧美一区二区三区视频免费 | 亚洲欧洲另类国产综合| 欧美三级韩国三级日本三斤| 国产在线不卡一卡二卡三卡四卡| 国产精品视频免费看| 在线成人小视频| 国产精品一二三| 午夜天堂影视香蕉久久| 国产无人区一区二区三区| 欧美日韩一区小说| 国产精品夜夜嗨| 丝袜亚洲另类丝袜在线| 国产精品欧美久久久久无广告| 欧美日韩视频一区二区| 国产精品资源网| 亚洲成人在线观看视频| 久久午夜免费电影| 欧美高清精品3d| 成人免费看视频| 久久精品国产亚洲一区二区三区| 日韩一区欧美小说| 久久噜噜亚洲综合| 欧美三级一区二区| 99久久精品国产麻豆演员表| 久久精品99国产精品日本| 樱花影视一区二区| 国产婷婷色一区二区三区四区| 欧美精三区欧美精三区| 99精品国产99久久久久久白柏| 久久99久久精品欧美| 亚洲无线码一区二区三区| 中文字幕色av一区二区三区| 精品国产伦理网| 91精品久久久久久蜜臀| 91国模大尺度私拍在线视频| 成人av资源在线| 国产精品18久久久久久久网站| 热久久免费视频| 亚洲高清在线视频| 亚洲精品国产品国语在线app| 久久久不卡影院| 日韩欧美卡一卡二| 在线播放亚洲一区| 欧美怡红院视频| 欧洲中文字幕精品| 91视频国产资源| www.亚洲人| 不卡免费追剧大全电视剧网站| 国产毛片精品视频| 寂寞少妇一区二区三区| 蜜臀av性久久久久蜜臀av麻豆 | 欧美一区二区三区四区久久| 91黄色激情网站| 91视频免费看| 色综合久久中文字幕| 成人免费观看男女羞羞视频| 国产麻豆一精品一av一免费| 国产在线精品不卡| 美女免费视频一区二区| 日韩av一区二区在线影视| 香蕉乱码成人久久天堂爱免费| 亚洲一卡二卡三卡四卡| 亚洲小说春色综合另类电影| 亚洲最大的成人av| 亚洲精品高清在线| 亚洲激情av在线| 曰韩精品一区二区| 一区二区成人在线| 亚洲一区中文在线| 亚洲成人一区二区在线观看| 午夜精品福利视频网站| 日韩av网站在线观看| 日本视频中文字幕一区二区三区| 日韩精彩视频在线观看| 日韩高清不卡一区二区三区| 日韩精品电影在线| 久久99久久久久久久久久久| 国产毛片精品视频| 成人综合在线视频| 91在线一区二区| 91福利小视频| 51精品视频一区二区三区| 日韩精品中文字幕在线不卡尤物| 日韩精品一区二区三区四区视频| 久久久亚洲欧洲日产国码αv| 国产精品视频一二| 亚洲一区二区四区蜜桃| 亚洲国产成人av| 久草热8精品视频在线观看|