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.hayabusa.taglib; 017 018import org.opengion.hayabusa.common.HybsSystemException; 019import org.opengion.hayabusa.html.TableFormatter; 020import org.opengion.fukurou.util.ToString; // 6.1.1.0 (2015/01/17) 021 022/** 023 * ガントチャート(タスク配置型)用の繰り返しタグのフォーマットに使用します。 024 * 025 * itd タグは、ガントヘッダー部の TDタグの繰返しに使用されます。 026 * この繰返しは、ganttParam タグの minDuration で指定された間隔で行われます。 027 * (例えば、0.5 を指定すれば、半日単位で処理されます。) 028 * itd タグの colspan 属性を指定した場合は、itd 自身が、td タグに colspan を 029 * 追加すると共に、繰返し自身を、その指定数だけに抑制します。 030 * 具体的には、colspan="2" とすると、2回に一回しか、itd タグが呼び出されなく 031 * なります。 032 * 033 * @og.formSample 034 * ●形式:<og:itd> ... Body ... </og:itd> 035 * ●body:あり(EVAL_BODY_BUFFERED:BODYを評価し、{@XXXX} を解析します) 036 * 037 * ●Tag定義: 038 * <og:itd 039 * debug 【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false) 040 * > ... Body ... 041 * </og:itd> 042 * 043 * ●使用例 044 * <og:thead rowspan="1"> 045 * <tr> 046 * <og:itd>M/d</og:itd> 047 * </tr> 048 * </og:thead> 049 * <og:tbody rowspan="1" > 050 * <tr> 051 * <og:itd> 052 * <span class="cGntBar[!FGTASK]" 053 * title="[NMMCN]&amp;#13;&amp;#10;[NMKT]" 054 * val1 ="[GVZOOM]" 055 * val2 ="[CDJGS]" 056 * val3 ="[WC]" 057 * val4 ="[NOMCN]" 058 * val5 ="[CDKT]" 059 * val6 ="[FGTASK]" 060 * val7 ="[DYSTART]" 061 * val8 ="[DYDELAY]" 062 * val9 ="[DURATION]" >&nbsp;</span> 063 * </og:itd> 064 * </tr> 065 * </og:tbody> 066 * 067 * @og.rev 3.5.4.8 (2004/02/23) 新規作成 068 * @og.group 画面部品 069 * 070 * @version 4.0 071 * @author Kazuhiko Hasegawa 072 * @since JDK5.0, 073 */ 074public class ItdTag extends CommonTagSupport { 075 /** このプログラムのVERSION文字列を設定します。 {@value} */ 076 private static final String VERSION = "6.4.2.0 (2016/01/29)" ; 077 private static final long serialVersionUID = 642020160129L ; 078 079 private String itdBody ; 080 081 /** 082 * デフォルトコンストラクター 083 * 084 * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor. 085 */ 086 public ItdTag() { super(); } // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。 087 088 /** 089 * Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。 090 * 091 * @return 後続処理の指示( EVAL_BODY_BUFFERED ) 092 */ 093 @Override 094 public int doStartTag() { 095 return EVAL_BODY_BUFFERED ; // Body を評価する。( extends BodyTagSupport 時) 096 } 097 098 /** 099 * Taglibのタグ本体を処理する doAfterBody() を オーバーライドします。 100 * 101 * @return 後続処理の指示(SKIP_BODY) 102 */ 103 @Override 104 public int doAfterBody() { 105 itdBody = getBodyString(); 106 107 return SKIP_BODY ; // Body を評価しない 108 } 109 110 /** 111 * Taglibの終了タグが見つかったときに処理する doEndTag() を オーバーライドします。 112 * 113 * @og.rev 6.3.4.0 (2015/08/01) TFormatTag.java → TFormatImpl.java 114 * 115 * @return 後続処理の指示 116 */ 117 @Override 118 public int doEndTag() { 119 debugPrint(); // 4.0.0 (2005/02/28) 120 final TFormatImpl tFormat = (TFormatImpl)findAncestorWithClass( this, TFormatImpl.class ); 121 // 6.4.1.1 (2016/01/16) PMD refactoring. Avoid if (x != y) ..; else ..; 122 if( tFormat == null ) { 123 final String errMsg = "<b><b>" + getTagName() + "タグは、TheadTag か、TBodyTagの内側(要素)に記述してください。</b>"; 124 throw new HybsSystemException( errMsg ); 125 } 126 127 tFormat.setItdBody( itdBody ); 128 jspPrint( TableFormatter.HYBS_ITD_MARKER ); 129 130 return EVAL_PAGE ; // ページの残りを評価する。 131 } 132 133 /** 134 * タグリブオブジェクトをリリースします。 135 * キャッシュされて再利用されるので、フィールドの初期設定を行います。 136 * 137 */ 138 @Override 139 protected void release2() { 140 super.release2(); 141 itdBody = null; 142 } 143 144 /** 145 * このオブジェクトの文字列表現を返します。 146 * 基本的にデバッグ目的に使用します。 147 * 148 * @return このクラスの文字列表現 149 * @og.rtnNotNull 150 */ 151 @Override 152 public String toString() { 153 return ToString.title( this.getClass().getName() ) 154 .println( "VERSION" ,VERSION ) 155 .println( "itdBody" ,itdBody ) 156 .println( "Other..." ,getAttributes().getAttribute() ) 157 .fixForm().toString() ; 158 } 159}