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.fukurou.transfer;
017
018 import java.io.File;
019 import java.io.PrintWriter;
020
021 import org.opengion.fukurou.db.Transaction;
022 import org.opengion.fukurou.util.FileUtil;
023 import org.opengion.fukurou.util.StringUtil;
024
025 /**
026 * ä¼é?è¦æ±‚ã«å¯¾ã—ã¦ã®ãƒ??ã‚¿ã‚’ãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸è¾¼ã¿ã—ã¾ã™ã?
027 * ä½?—ã€æ›¸ãè¾¼ã¾ã‚Œã‚‹ãƒ??ã‚¿ã«ã¤ã?¦ã¯ã€æ—§ä¼é?シスãƒ?ƒ ã®å½¢å¼ã¨äº’æ›æ€§ã‚’æŒãŸã›ã‚‹ãŸã‚ã?
028 * ãƒ??ã‚¿ã®å‰?0Byteã«ç©ºç™½ã§åŸ‹ã‚ã€ã•らã«å…¨ä½“ã§500Byteã«ãªã‚‹ã‚ˆã?«è¡Œæœ«ã«ã‚‚空白埋ã‚ã‚’ã—ã¾ã™ã?
029 *
030 * 書込ã¿ã™ã‚‹ãƒ•ァイルåã?ã€å®Ÿè¡Œå¯¾è±¡ã§æŒ?®šã—ã¾ã™ã?ファイルåã?çµ¶å¯¾ãƒ‘ã‚¹ã§æŒ?®šã—ã¦ä¸‹ã•ã??
031 * ã¾ãŸã?書込ã™ã‚‹ãƒ?‚ストファイルã®ã‚¨ãƒ³ã‚³ãƒ¼ãƒ‰ã?æ›¸è¾¼ãƒ‘ãƒ©ãƒ¡ãƒ¼ã‚¿ãƒ¼ãŒæŒ‡å®šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã?
032 * æŒ?®šã—ãªã??åˆã?シスãƒ?ƒ リソースã®"DB_ENCODE"ã§æŒ?®šã•れãŸå€¤ãŒé©ç”¨ã•れã¾ã™ã?
033 *
034 * @og.group ä¼é?シスãƒ?ƒ
035 *
036 * @version 5.0
037 * @author Hiroki.Nakamura
038 * @since JDK1.6
039 */
040 public class TransferExec_SAMCB implements TransferExec {
041
042 // 書込ファイルオブジェク�
043 // private File fileWrite = null; // 5.5.2.4 (2012/05/16) ãƒãƒ¼ã‚«ãƒ«å¤‰æ•°åŒ?
044
045 // 書込ファイルã®ã‚¨ãƒ³ã‚³ãƒ¼ãƒ?
046 // private String fileEncode = null; // 5.5.2.4 (2012/05/16) ãƒãƒ¼ã‚«ãƒ«å¤‰æ•°åŒ?
047
048 /**
049 * ãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸è¾¼ã¿ã—ã¾ã™ã?
050 *
051 * @param vals ä¼é?ãƒ??ã‚¿(é…å?)
052 * @param config ä¼é?è¨å®šã‚ªãƒ–ジェクãƒ?
053 * @param tran トランザクションオブジェク�
054 *
055 * @og.rev 5.5.3.3 (2012/06/15) close処ç?
056 */
057 @Override
058 public void execute( final String[] vals, final TransferConfig config, final Transaction tran ) {
059 File fileWrite = new File( config.getExecObj() );
060
061 String fileEncode = config.getExecPrm();
062 if( fileEncode == null || fileEncode.length() == 0 ) {
063 fileEncode = "UTF-8";
064 }
065
066 PrintWriter writer = FileUtil.getPrintWriter( fileWrite,fileEncode );
067 String line = null;
068 for( String s : vals ) {
069 // å‰?0Byteを空白埋ã‚
070 String preSpace = StringUtil.stringFill( "", 30, fileEncode );
071 // 全体ã§500Byteã«ãªã‚‹ã‚ˆã?«å¾Œã‚ã«ç©ºç™½åŸ‹ã‚
072 line = StringUtil.stringFill( preSpace + s, 500, fileEncode );
073 writer.println( line );
074 }
075 writer.close(); // 5.5.3.3 (2012/06/15)
076 }
077 }