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 */ 016package org.opengion.fukurou.util; 017 018/** 019 * ConnectIF.java は、サーバーアクセス関連のクラスを共通的に使用するためのインターフェースです。 020 * 021 * connect()、action( String command, String localFile, String remoteFile )、disconnect() の 022 * 一連処理のメソッドと、setHostUserPass( String host , String user , String pass ) 、getErrMsg() の 023 * 簡易的な共通メソッドを用意しています。 024 * 025 * @og.rev 5.1.6.0 (2010/05/01) 新規追加 026 * 027 * @version 5.0 028 * @author Kazuhiko Hasegawa 029 * @since JDK5.0, 030 */ 031public interface ConnectIF { 032 033 /** 034 * サーバーへの接続、ログインを行います。 035 * 036 * このメソッドは、初期化メソッドです。 037 * 接続先を変更する場合は、もう一度このメソッドをコールする必要があります。 038 * (そのような場合は、通常、オブジェクトを構築しなおす方がよいと思います。) 039 */ 040 public void connect() ; 041 042 /** 043 * command , localFile , remoteFile を元に、処理を行います。 044 * 045 * このメソッドは、connect()メソッド実行後に、呼び出す必要があります。 046 * 047 * @param command GET/PUT/DEL など 048 * @param localFile ローカルのファイル名 049 * @param remoteFile 接続先のファイル名 050 */ 051 public void action( final String command, final String localFile, final String remoteFile ); 052 053 /** 054 * サーバーとの接続をクローズします。 055 * 056 * ログインされている場合は、ログアウトも行います。 057 * コネクトされている場合は、ディスコネクトします。 058 */ 059 public void disconnect(); 060 061 /** 062 * サーバーの、ホスト、ユーザー、パスワードを設定します。 063 * 064 * @param host サーバー 065 * @param user ユーザー 066 * @param pass パスワード 067 */ 068 public void setHostUserPass( final String host , final String user , final String pass ); 069 070 /** 071 * 接続に利用するポート番号を設定します。 072 * 073 * @param port 接続に利用するポート番号 074 */ 075 public void setPort( final String port ) ; 076 077 /** 078 * それぞれの受け側ファイルにディレクトリを作成するかどうか(初期値:true:作成する)。 079 * 080 * -mkdirs=[true/false] は、受け側のファイル(GET時:LOCAL、PUT時:サーバー)に取り込むファイルのディレクトリが 081 * 存在しない場合に、作成するかどうかを指定します(初期値:true)。 082 * 通常、サーバーに、フォルダ階層を作成してPUTする場合、動的にフォルダ階層を作成したいケースで便利です。 083 * 逆に、フォルダは確定しており、指定フォルダ以外に PUT するのはバグっていると事が分かっている場合には 084 * false に設定して、存在しないフォルダにPUT しようとすると、エラーになるようにします。 085 * 086 * @param isMkdirs 受け側ファイルにディレクトリを作成するかどうか。true:作成する 087 */ 088 public void setMkdirs( final boolean isMkdirs ) ; 089 090 /** 091 * Dataタイムアウトを秒で指定します(初期値:600 [秒])。 092 * 093 * オリジナルの FTPClient#setDataTimeout( int ) は、ミリ秒でセット 094 * しますが、ここのメソッドでは、秒でセットします。 095 * 096 * @param timeout タイムアウト[秒] 097 */ 098 public void setTimeout( final int timeout ) ; 099 100 /** 101 * 実行状況の表示可否 を設定します(初期値:false:表示しない)。 102 * 103 * @param isDisplay 実行状況の表示可否 104 */ 105 public void setDisplay( final boolean isDisplay ) ; 106 107 /** 108 * デバッグ情報の表示可否 を設定します(初期値:false:表示しない)。 109 * 110 * @param isDebug デバッグ情報の表示可否 111 */ 112 public void setDebug( final boolean isDebug ) ; 113 114 /** 115 * 処理中に発生したエラーメッセージを取り出します。 116 * 117 * @return エラーメッセージ 118 */ 119 public String getErrMsg(); 120}