001 /* 002 * Copyright (c) 2009 The openGion Project. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 013 * either express or implied. See the License for the specific language 014 * governing permissions and limitations under the License. 015 */ 016 package org.opengion.plugin.io; 017 018 import java.io.PrintWriter; 019 020 import org.opengion.hayabusa.common.HybsSystemException; 021 import org.opengion.hayabusa.db.DBTableModel; 022 023 /** 024 * プロパティファイル形?エンジン専用特殊形?の書き?しクラスです? 025 * Ver4 では、?ロパティファイル形式をサポ?トして?せん? 026 * 027 * DefaultTableWriter を継承して?す?で?ラベル?名前,データの出力部のみ 028 * オーバ?ライドして??ロパティーファイルの出力機?を実現して?す? 029 * 030 * @og.group ファイル出? 031 * 032 * @version 4.0 033 * @author Kazuhiko Hasegawa 034 * @since JDK5.0, 035 */ 036 public class TableWriter_Properties extends TableWriter_Default { 037 //* こ?プログラ??VERSION??を設定します? {@value} */ 038 private static final String VERSION = "4.0.0.0 (2005/08/31)" ; 039 040 private static final String headerSequence = "NL-D"; // ヘッ???の並び? 041 042 // /** 043 // * ?ォルトコンストラクター 044 // * 045 // */ 046 // public TableWriter_Properties() { 047 // super(); 048 // } 049 050 /** 051 * DBTableModel から ??タを作?して,PrintWriter に書き?します? 052 * 053 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する? 054 * @og.rev 3.5.4.3 (2004/01/05) 引数に PrintWriter を受け取るよ?変更します? 055 * 056 * @param writer PrintWriterオブジェク? 057 */ 058 @Override 059 public void writeDBTable( final PrintWriter writer ) { 060 setHeaderSequence( headerSequence ); 061 super.writeDBTable( writer ); 062 } 063 064 /** 065 * PrintWriter に DBTableModelの??ブル??を書き込みます? 066 * こ?クラスでは?データ??ルコー??ション(")で囲みます? 067 * PrintWriter に DBTableModelの??ブル??を書き込みます? 068 * 069 * @og.rev 2.3.1.2 (2003/01/28) ??タ出力時に、改行が余?に出される?を修正? 070 * @og.rev 3.1.1.0 (2003/03/28) 同期メソ?(synchronized付き)を非同期に変更する? 071 * 072 * @param table DBTableModelオブジェク? 073 * @param writer PrintWriterオブジェク? 074 */ 075 @Override 076 protected void writeData( final DBTableModel table,final PrintWriter writer ) { 077 if( numberOfColumns < 2 ) { 078 String errMsg = "Properties では、最低?キーと値の?つ以上?カラ??です?" 079 + " numberOfColumns=[" + numberOfColumns + "]" ; 080 throw new HybsSystemException( errMsg ); 081 } 082 083 int numberOfRows = table.getRowCount(); 084 String separator = getSeparator(); 085 086 for( int row=0; row<numberOfRows; row++ ) { 087 writer.print( table.getValue(row,clmNo[0]) ); 088 writer.print( "=" ); 089 writer.print( table.getValue(row,clmNo[1]) ); 090 091 for( int i=2; i<numberOfColumns; i++ ) { 092 int clm = clmNo[i]; 093 writer.print( separator ); 094 writer.print( table.getValue(row,clm) ); 095 } 096 writer.println(); 097 } 098 } 099 }