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.process;
017
018 import org.opengion.fukurou.util.Argument;
019
020 import java.util.Map;
021
022 /**
023 * AbstractProcess は、ChainProcess インターフェースを実è£?�—たã?Abstract クラスですã?
024 * ChainProcess を用ã�?�¦ã€??次、バãƒ?ƒ�プロセスを実行することができますã?
025 *
026 * @version 4.0
027 * @author Kazuhiko Hasegawa
028 * @since JDK5.0,
029 */
030 abstract public class AbstractProcess implements HybsProcess {
031 /** リターンコーãƒ? System.getProperty("line.separator") */
032 public static final String CR = System.getProperty("line.separator");
033
034 /** タブセパレータ */
035 public static final String TAB = "\t"; // タブ区åˆ?‚Šæ–??
036
037 private final Argument argments ;
038 private LoggerProcess logger = null;
039
040 /**
041 * コンストラクター
042 *
043 * @param name こã?クラス(サブクラス)のクラス名称
044 * @param mustProparty å¿??チェãƒ?‚¯Map
045 * @param usableProparty 整合æ?チェãƒ?‚¯Map
046 */
047 public AbstractProcess( final String name , final Map<String,String> mustProparty ,final Map<String,String> usableProparty ) {
048 argments = new Argument( name ) ;
049 argments.setMustProparty( mustProparty );
050 argments.setUsableProparty( usableProparty );
051 }
052
053 /**
054 * 引数形式を解析すã‚?引数オブジェクトに、引数を設定しますã?
055 * Argument のæ–?—å?から、引数かã?ロパティをセãƒ?ƒˆしますã?
056 * ?»プロパティ?½のキー部の大æ–?—・小文字ã?、厳格に判定してã�?�¾すã?
057 * Argument のæ–?—å?には、タイプがありますã?
058 *
059 * ?»コメント] ??# で始まる引数で、使用されませんã€?登録もされませんã€?
060 * ?»引数?½ ??#,-,= 以外で始まるé?常のæ–?—å?。登録のé ?•ªが指定されますã?
061 * ?»プロパティ?½??- で始まりã?キーと値ã‚?で区åˆ?�£てã�?‚‹パラメータですã?é ?º�ã?無関係ã?
062 *
063 * @param arg 引数
064 */
065 public void putArgument( final String arg ) {
066 argments.putArgument( arg ) ;
067 }
068
069 /**
070 * Argument のæ–?—å?から、ã?ロパティをセãƒ?ƒˆしますã?
071 * ?»プロパティ?½のキー部の大æ–?—・小文字ã?、厳格に判定してã�?�¾すã?
072 * こã?メソãƒ?ƒ‰は、引数 ã‚?コメントã?判断を行いません。ã?ロパティ のみ
073 * 設定されるもã?として、å?ç�?�—ますã?
074 * プロパティの key=val がå?めからå?割されてã�?‚‹場合ã?簡易メソãƒ?ƒ‰ですã?
075 *
076 * @param key キー
077 * @param val 値
078 */
079 public void putArgument( final String key,final String val ) {
080 argments.putArgument( key,val ) ;
081 }
082
083 /**
084 * 引数形式を解析すã‚?引数オブジェクトを返しますã?
085 *
086 * @return 引数オブジェクãƒ?
087 */
088 public Argument getArgument() {
089 return argments ;
090 }
091
092 /**
093 * ãƒ?‚£スプレイにメãƒ?‚»ージを表示しますã?
094 *
095 * @param msg 表示するメãƒ?‚»ージ
096 */
097 public void println( final String msg ) {
098 if( logger != null ) {
099 logger.println( msg ) ;
100 }
101 }
102
103 /**
104 * ãƒ?‚£スプレイにメãƒ?‚»ージを表示しますã?
105 *
106 * @param msg 表示するメãƒ?‚»ージ
107 */
108 public void logging( final String msg ) {
109 if( logger != null ) {
110 logger.logging( msg ) ;
111 }
112 }
113
114 /**
115 * ãƒ?‚£スプレイ出力すã‚?LoggerProcess オブジェクトをセãƒ?ƒˆしますã?
116 *
117 * @param logger LoggerProcessオブジェクãƒ?
118 */
119 public final void setLoggerProcess( final LoggerProcess logger ) {
120 this.logger = logger ;
121 }
122
123 /**
124 * プロセスのå†?®¹表示を行いますã?
125 * Argument#toString() を呼び出してã�?�¾すã?
126 *
127 * @return å†?®¹表示
128 */
129 @Override
130 public String toString() {
131 return argments.toString();
132 }
133 }