📄 jsourcecodewizardprocessortsv.java
字号:
/**
* IgaLib -> wizard
* 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.wizard;
import jp.ne.nifty.iga.tosiki.string.*;
import java.io.*;
import java.util.*;
/**
* JSourceCodeWizardProcessor 偺僿儖僷乕僋儔僗<BR>
* TSV晹暘偱偡<BR>
*
* @author Tosiki IGA
*/
public class JSourceCodeWizardProcessorTsv
{
protected String TITLE="Tsv";
protected String SEPARATOR="\\t";
protected String getTitle()
{
return TITLE;
}
protected String getSeparator()
{
return SEPARATOR;
}
/**
* 娭悢傪偢偽偭偲憓擖偟傑偡丅
*/
public void writeFunction(
JSourceCodeWizard wizard,JSourceCodeWizardChannel dataChannel,ArrayList vecItem,IndentWriter out)
throws IOException
{
out.println(" /**");
out.println(" * 梌偊傜傟偨"+getTitle()+"暥帤楍傪僷乕僗偟偰僼傿乕儖僪偵戙擖偟傑偡");
out.println(" * ");
out.println(" * @param String strLine 擖椡峴");
out.println(" */");
out.println(" public void parse"+getTitle()+"(String strLine)");
out.println(" {");
out.println(" StringReader reader=new StringReader(strLine);");
for(int index=0;index<vecItem.size();index++)
{
JSourceCodeWizardField item=(JSourceCodeWizardField)vecItem.get(index);
if(item.isAvailableTsv()==false)
{
continue;
}
out.addIndent(2);
item.writeTsvSetParam("wizTsvNextToken(reader)",out);
out.addIndent(-2);
}
out.println(" }");
out.println("");
out.println(" protected String wiz"+getTitle()+"NextToken(Reader reader)");
out.println(" {");
out.println(" StringWriter writer=new StringWriter();");
out.println(" try{");
out.println(" for(;;)");
out.println(" {");
out.println(" int iRead=reader.read();");
out.println(" if(iRead<0)break;");
out.println(" if(iRead=='"+getSeparator()+"')break;");
out.println(" if(iRead=='\\n')break;");
out.println(" writer.write(iRead);");
out.println(" }");
out.println(" writer.flush();");
out.println(" writer.close();");
out.println(" }catch(IOException ex){");
out.println(" System.out.println(ex.toString());");
out.println(" ex.printStackTrace();");
out.println(" }");
out.println(" return writer.toString();");
out.println(" }");
out.println("");
out.println(" /**");
out.println(" * 梌偊傜傟偨"+getTitle()+"僼傽僀儖偵彂偒弌偟偟傑偡");
out.println(" * ");
out.println(" * @param File fileFile 弌椡"+getTitle()+"僼傽僀儖");
out.println(" */");
out.println(" public void serialize"+getTitle()+"(Writer writer)");
out.println(" throws IOException");
out.println(" {");
boolean isFirstColumn=true;
for(int index=0;index<vecItem.size();index++)
{
JSourceCodeWizardField item=(JSourceCodeWizardField)vecItem.get(index);
if(item.isAvailableTsv()==false)
{
continue;
}
if(isFirstColumn)
{
isFirstColumn=false;
}
else
{
out.println(" writer.write('"+getSeparator()+"');");
}
out.println(" writer.write("+WizType.getConvertPatternForType(item.getType(),"String","get"+JSourceCodeWizardProcessor.getUpper(item.getName())+"()")+");");
}
out.println(" }");
out.println("");
out.println(" /**");
out.println(" * 梌偊傜傟偨"+getTitle()+"僼傽僀儖偵彂偒弌偟偟傑偡");
out.println(" * ");
out.println(" * @param File fileFile 弌椡"+getTitle()+"僼傽僀儖");
out.println(" */");
out.println(" public void serialize"+getTitle()+"(File fileFile)");
out.println(" throws IOException");
out.println(" {");
out.println(" BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileFile)));");
out.println(" serialize"+getTitle()+"(writer);");
out.println(" writer.newLine();");
out.println(" writer.flush();");
out.println(" writer.close();");
out.println(" }");
out.println("");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -