?? tinysaxwriter.java
字號(hào):
/**
* IgaLib -> String
* Copyright (C) 2001 Tosiki IGA , IgaLib project member
* (http://homepage2.nifty.com/igat/igapyon/index.html)
*
* 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 jp.ne.nifty.iga.tosiki.string;
import java.io.*;
/**
* 挻彫偝偄SAX彂偒弌偟Writer僋儔僗<BR>
* 彫偝偄偺偩偗偑庢?zhèn)钑總蘏AX彂偒弌偟僋儔僗偱偡丅
* 摿偵巊偄彑庤偼柍偄偱偟傚偆丅
*
* @author Tosiki IGA
*/
public class TinySaxWriter
{
protected BufferedWriter writer=null;
protected int indent=0;
protected boolean isPastStart=true;
/**
* 挻彫偝偄SAX彂偒弌偟Writer僋儔僗偺僐儞僗僩儔僋僞
*
* @param BufferedWriter writer 楢寢偡傞尦偺Writer
*/
public TinySaxWriter(BufferedWriter writer)
{
this.writer=writer;
}
public void startDocument()
throws IOException
{
writer.write("<?xml version=\"1.0\" encoding=\"Shift_JIS\" standalone=\"yes\"?>");
writer.newLine();
}
public void endDocument()
throws IOException
{
}
/**
* String偺攝楍傪 Object攝楍偱擖傟偰偔偩偝偄丅
*/
public void startElement(String name,java.util.ArrayList attributes)
throws IOException
{
if(isPastStart)
{
writer.newLine();
}
isPastStart=true;
writer.write(MojiUtil.padLeft("",indent*2,' '));
writer.write('<');
writer.write(name);
if(attributes!=null)
{
for(int index=0;index<attributes.size();index++)
{
String[] param=(String[])attributes.get(index);
writer.write(' ');
writer.write(param[0]);
writer.write('=');
writer.write('"');
writer.write(param[1]);
writer.write('"');
}
}
writer.write('>');
indent++;
}
public void endElement(String name)
throws IOException
{
indent--;
if(isPastStart==false)
{
writer.write(MojiUtil.padLeft("",indent*2,' '));
}
isPastStart=false;
writer.write('<');
writer.write('/');
writer.write(name);
writer.write('>');
writer.newLine();
}
public void characters(String strLine)
throws IOException
{
writer.write(strLine);
}
/**
* Writer傪僼儔僢僔儏偟傑偡
*
* @throws IOException 壗偐偟傜偺I/O椺奜偺敪惗
*/
public final void flush()
throws IOException
{
if(writer!=null)
{
writer.flush();
}
}
/**
* Writer傪僋儘乕僘偟傑偡
*
* @throws IOException 壗偐偟傜偺I/O椺奜偺敪惗
*/
public final void close()
throws IOException
{
if(writer!=null)
{
writer.close();
writer=null;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -