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.hayabusa.html;
017    
018    import org.opengion.hayabusa.common.HybsSystem;
019    import org.opengion.hayabusa.common.HybsSystemException;
020    import org.opengion.hayabusa.db.DBTableModel;
021    import org.opengion.fukurou.util.StringUtil;
022    import org.opengion.fukurou.model.Formatter;
023    
024    import java.util.regex.Pattern;
025    import java.util.regex.Matcher;
026    
027    /**
028     * [PN],[OYA] ãªã©ã® [] ã§æŒ?®šã•れãŸã‚«ãƒ©ãƒ?§è¡¨ã•れãŸãƒ•ォーマットデータã«å¯¾ã—ã¦ã€?
029     * DBTableModelオブジェクトをé©ç”¨ã—㦠å?‚«ãƒ©ãƒ?«å®Ÿãƒ‡ãƒ¼ã‚¿ã‚’割り当ã¦ã‚‹ã‚ªãƒ–ジェクトã§ã™ã?
030     *
031     * 特ã«ã€[XXXX]ã«å¯¾ã—ã¦ã€[#XXXX]ã€[$XXXX]ã€[$XXXX]ãªã©ã®ç‰¹æ®Šè¨˜å·ãŒä½¿ç”¨ã§ãã¾ã™ã?
032     * 特殊記å·ã®è§£é‡ˆã?ã€HTMLFormatTextFieldç³»ã¨HTMLFormatTableç³»ã§ç•°ãªã‚Šã¾ã™ã?ã§
033     * ã”æ³¨æ„ãã?•ã??
034     *
035     * @og.rev 3.5.4.0 (2003/11/25) æ–°è¦è¿½åŠ?
036     * @og.group ç”»é¢è¡¨ç¤º
037     *
038     * @version  4.0
039     * @author   Kazuhiko Hasegawa
040     * @since    JDK5.0,
041     */
042    public class TableFormatter {
043            /** フォーマットタイプã?æŒ?®? ヘッãƒ??タイãƒ?{@value}  */
044    //      public static final String TYPE_HEAD  = "head" ;
045            /** フォーマットタイプã?æŒ?®? ボディタイãƒ?{@value}  */
046    //      public static final String TYPE_BODY  = "body" ;
047            /** フォーマットタイプã?æŒ?®? フッタータイãƒ?{@value}  */
048    //      public static final String TYPE_FOOT = "foot";
049    
050            /** フォーマットタイプã?æŒ?®šã?特殊ãªãƒžã?ク {@value} */
051            public static final String HYBS_ITD_MARKER = "h_itd_marker";
052            private static final Pattern ptnKey = Pattern.compile( "[ \t]+</td" ); // 4.3.2.0 (2008/09/10)
053    
054            // 3.5.5.2 (2004/04/02) 定数化ã—ã¦ãŠãã¾ã™ã?
055    //      private static final int SYSFORM_KEY_CLM = -1;          // [KEY.カラ�]
056    //      private static final int SYSFORM_ROWNUM  = -2;          // [I]
057    //      private static final int SYSFORM_ROW_ID  = -3;          // [ROW.ID]  3.6.0.0 (2004/09/17)
058    
059    //      private String                  formatType      = null;
060            private FormatterType   formatType      = null;
061            private int[]                   location        = null;
062            private String[]                format          = null;
063    //      private String[]                systemFormat= null;             // 3.5.5.0 (2004/03/12) [KEY.カラãƒ?] 機è?追åŠ?
064            private String                  formatTag       = null;
065            private String                  rowspan         = " rowspan=\"2\"";
066            private String                  trTag           = null;
067            private boolean                 noClass         = false;
068            // 3.5.6.0 (2004/06/18) '!' 値ã®ã¿ 追åŠ?既存ã? '$' ã¯ã€ãƒ¬ãƒ³ãƒ?ƒ©ãƒ¼
069            private char[]                  type            = null;         // '#':ラベルã®ã¿  '$':レンãƒ?ƒ©ãƒ¼ '!':値ã®ã¿  ãã?ä»?通常
070            private String                  usableKey       = null;         // キーæƒ??ã®ã‚«ãƒ©ãƒ?–‡å­—å?
071            private int                             usableKeyNo     = -1;           // キーæƒ??ã®ã‚«ãƒ©ãƒ?•ªå·
072            private String                  usableList      = "1" ;
073    
074            private String                  itdBody         = "";           // 3.5.6.0 (2004/06/18) 追�
075            private Formatter               formatter       = null;
076    
077            /**
078             * フォーマットをセãƒ?ƒˆã—ã¾ã™ã?
079             * フォーマットã«ã€?lt;table&gt;ã‚’å«ã‚??åˆã?TextField扱ã?ªã®ã§ã€ãƒ•ォーマットå?割
080             * ã—ã¾ã›ã‚“。table ã‚’å«ã¾ãšã?tr ã‚’å«ã‚??åˆã?ã€?¼‘行å?ã®ãƒ??ã‚¿ã¨ã—ã¦æ‰±ã?‚ºã€?
081             * trTag を求ã‚ã¾ã™ã?
082             * trTag 㨠format ã¨ã®é–“ã«ã€è¡Œã?ãƒ?ƒ€ãƒ¼ãŒå?りã¾ã™ã?
083             * Tomcat6ã§ã¯ã€JSPã®ãƒ‘ã?ス時ã«ã€tabã‚„spaceã¯ãã?ã¾ã¾ãƒ‘ã?スã•れるãŸã‚ã?</td>å‰?
084             * ã®ã‚¹ãƒšã?ス削除処ç?‚‚行ã„ã¾ã™ã?
085             *
086             * @og.rev 4.3.2.0 (2008/09/10) </td>å‰ã?スペã?スをå–り消ã—ã¾ã™ã?
087             * @og.rev 5.5.0.3 (2012/03/13) <tr>ã‚’å–らãªã?ƒ•ラグ追åŠ?
088             *
089             * @param       fmt  [カラãƒ?] å½¢å¼ã?フォーマットデータ
090             * @param   flg  falseã«ã™ã‚‹ã¨å…ˆé?ã®trã‚¿ã‚°ã‚’å–ã‚‹å?ç?‚’行ã„ã¾ã›ã‚“(5.5.0.3)
091             */
092            public void setFormat( final String fmt , final boolean flg ) {
093                    int tbl = fmt.indexOf( "<table" );
094                    int str = fmt.indexOf( "<tr" );
095    
096                    // tr ã‚’å«ã¿ã€ã‹ã¤ã€tableã‚’å«ã¾ãªã?‹ã€å«ã‚“ã§ã‚?tr ã®å¾Œã‚ã«tableãŒã‚ã‚‹å?åˆã?
097    //              if( str >= 0 && ( tbl < 0 || str < tbl ) ) {
098                    if( str >= 0 && ( tbl < 0 || str < tbl ) && flg ) { // 5.5.0.3(2012/03/13)
099                            int end = fmt.indexOf( '>',str );
100                            formatTag = fmt.substring(end+1);
101                            trTag = fmt.substring(0,end+1) ;
102                    }
103                    else {
104                            formatTag = fmt;
105                            trTag     = null;
106                    }
107                    // 4.3.2.0 (2008/09/10) </td>å‰ã?スペã?スをå–り消ã™ã€?
108                    Matcher matcher = ptnKey.matcher( formatTag );
109                    formatTag = matcher.replaceAll( "</td" );
110    
111            }
112    
113            /**
114             * フォーマットをセãƒ?ƒˆã—ã¾ã™ã?
115             * フォーマットã«ã€?lt;table&gt;ã‚’å«ã‚??åˆã?TextField扱ã?ªã®ã§ã€ãƒ•ォーマットå?割
116             * ã—ã¾ã›ã‚“。table ã‚’å«ã¾ãšã?tr ã‚’å«ã‚??åˆã?ã€?¼‘行å?ã®ãƒ??ã‚¿ã¨ã—ã¦æ‰±ã?‚ºã€?
117             * trTag を求ã‚ã¾ã™ã?
118             * trTag 㨠format ã¨ã®é–“ã«ã€è¡Œã?ãƒ?ƒ€ãƒ¼ãŒå?りã¾ã™ã?
119             * Tomcat6ã§ã¯ã€JSPã®ãƒ‘ã?ス時ã«ã€tabã‚„spaceã¯ãã?ã¾ã¾ãƒ‘ã?スã•れるãŸã‚ã?</td>å‰?
120             * ã®ã‚¹ãƒšã?ス削除処ç?‚‚行ã„ã¾ã™ã?
121             *
122             * @og.rev 5.5.0.3 (2012/03/13) 引数追åŠ?«ã¤ãã?
123             *
124             * @param       fmt  [カラãƒ?] å½¢å¼ã?フォーマットデータ
125             */
126            public void setFormat( final String fmt  ) {
127                    setFormat( fmt , true );
128            }
129    
130            /**
131             * フォーマットをå–å¾—ã—ã¾ã™ã?
132             *
133             * @og.rev 3.5.5.8 (2004/05/20) æ–°è¦è¿½åŠ?
134             * @og.rev 5.1.7.0 (2010/06/01) サニタイズ戻ã—å?ç?"\\]\\"ã‹ã‚‰"["ã«æˆ»ã?を追åŠ?
135             *
136             * @return      フォーマットデータ
137             */
138            public String getFormat() {
139                    if( trTag != null ) {
140    //                      return trTag + formatTag ;
141                            return decodeSanitizedStr( trTag + formatTag );
142                    }
143                    else {
144    //                      return formatTag ;
145                            return decodeSanitizedStr( formatTag );
146                    }
147            }
148    
149            /**
150             * DBTableModelを利用ã—ã¦ã€ãƒ•ォーマットデータをå?期化ã—ã¾ã™ã?
151             *
152             * @og.rev 3.5.5.0 (2004/03/12) [KEY.カラãƒ?] 機è?追åŠ?
153             * @og.rev 3.5.5.2 (2004/04/02) [I] ã§ã€è¡Œç•ªå·ã‚’作æ?ã—ã¾ã™ã?
154             * @og.rev 3.5.6.0 (2004/06/18) '!' 値ã®ã¿ 追åŠ?既存ã? '$' ã¯ã€ãƒ¬ãƒ³ãƒ?ƒ©ãƒ¼
155             * @og.rev 3.6.0.0 (2004/09/17) [ROW.ID] ã§ã€è¡Œæ¯Žã?ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®IDã‚’è¿”ã—ã¾ã™ã?
156             * @og.rev 5.1.7.0 (2010/06/01) サニタイズ戻ã—å?ç?"\\]\\"ã‹ã‚‰"["ã«æˆ»ã?を追åŠ?
157             *
158             * @param       table   DBTableModelオブジェク�
159             */
160            public void makeFormat( final DBTableModel table ) {
161    //              String fmt2 = formatTag.replace( '[',']' );
162    //              CSVTokenizer token = new CSVTokenizer( fmt2,']',false );
163    //              int count = token.countTokens() / 2 ;
164    //              format   = new String[ count+1 ];
165    //              location = new int[ count ];
166    //              systemFormat = new String[ count ];     // 3.5.5.0 (2004/03/12)
167    //              type     = new char[ count ];
168    //              for( int i=0; i<count; i++ ) {
169    //                      format[i]  = token.nextToken();
170    //                      String clm = token.nextToken();
171    //                      type[i] = clm.charAt(0);
172    //                      if( type[i] == '#' || type[i] == '$' || type[i] == '!' ) {
173    //                              location[i] = table.getColumnNo( clm.substring(1) );
174    //                      }
175    //                      // 3.5.5.0 (2004/03/12) [KEY.カラãƒ?] 機è?追åŠ?
176    //                      else if( clm.startsWith( "KEY." ) ) {
177    //                              location[i] = SYSFORM_KEY_CLM ;
178    //                              systemFormat[i] = clm.substring(4) ;
179    //                      }
180    //                      // 3.5.5.0 (2004/03/12) [I] 機è?追åŠ?
181    //                      else if("I".equals( clm ) ) {
182    //                              location[i] = SYSFORM_ROWNUM;
183    //                              systemFormat[i] = null ;
184    //                      }
185    //                      // 3.6.0.0 (2004/09/17) [ROW.ID] 機è?追åŠ?
186    //                      else if( "ROW.ID".equals( clm ) ) {
187    //                              location[i] = SYSFORM_ROW_ID;
188    //                              systemFormat[i] = null ;
189    //                      }
190    //                      else {
191    //                              location[i] = table.getColumnNo( clm );
192    //                      }
193    //              }
194    //              format[count] = token.nextToken();
195    
196                    formatter = new Formatter( table );
197                    formatter.setFormat( formatTag );
198                    location = formatter.getClmNos();
199                    format   = formatter.getFormat();
200    
201                    // 5.1.7.0 (2010/06/01) サニタイズ戻ã—å?ç?"\\]\\"ã‹ã‚‰"["ã«æˆ»ã?を追åŠ?
202                    if( format != null ) {
203                            for( int i=0; i<format.length; i++ ) {
204                                    format[i] = decodeSanitizedStr( format[i] );
205                            }
206                    }
207    
208                    type     = formatter.getType();
209    
210                    // ã“ã?フォーマットを使用ã™ã‚‹ã‹ã©ã?‹ã‚’指定ã™ã‚‹åˆ¤å®šæ¡ä»¶ã®åˆæœŸè¨­å®šã§ã™ã?
211                    if( usableKey != null ) {
212                            usableKeyNo = table.getColumnNo( usableKey );
213                    }
214            }
215    
216            /**
217             * ãƒ??ブルフォーマットã?タイプをæŒ?®šã—ã¾ã™ã?
218             * enum FormatterType ã§ã€æŒ‡å®šã—ã¾ã™ã?
219             *
220             * @og.rev 4.0.0.0 (2007/05/02) enum 定義ã«å¤‰æ›´
221             *
222             * @param  ftype フォーマットã?タイãƒ?
223             */
224            public void setFormatType( final FormatterType ftype ) {
225                    formatType = ftype;
226            }
227    
228            /**
229             * ãƒ??ブルフォーマットã?タイプをæŒ?®šã—ã¾ã™ã?
230             * head/body/foot/<del>ith/itd</del> ã§ã€æŒ‡å®šã—ã¾ã™ã?
231             *
232             * @og.rev 3.5.4.8 (2004/02/23) フォーマットã?タイプã«ã€ith/itd を追åŠ?
233             * @og.rev 3.5.6.0 (2004/06/18) フォーマットã?タイプã?ã€ith/itd を削除
234             *
235             * @param  ftype フォーマットã?タイãƒ?head/body/foot/<del>ith/itd</del>)
236             */
237    //      public void setFormatType( final String ftype ) {
238    //              if( ftype == null || "head/body/foot/".indexOf( ftype ) < 0 ) {
239    //                      String errMsg = "ãƒ??ブルフォーマットã?タイプã?ã€head/body/foot 以外指定ã§ãã¾ã›ã‚“ã€?;
240    //                      errMsg = errMsg + "[" + ftype + "]";
241    //                      throw new HybsSystemException( errMsg );
242    //              }
243    //              formatType = ftype;
244    //      }
245    
246            /**
247             * ã“ã?フォーマットã?タイプを返ã—ã¾ã™ã?
248             *
249             * ã“ã?フォーマットã?タイプを返ã—ã¾ã™ã?
250             *
251             * @og.rev 4.0.0.0 (2007/05/02) enum 定義ã«å¤‰æ›´
252             *
253             * @return      ã“ã?フォーマットã?タイプを返ã—ã¾ã™ã?
254             */
255            public FormatterType getFormatType() {
256                    return formatType;
257            }
258    
259            /**
260             * ã“ã?フォーマットã?タイプを返ã—ã¾ã™ã?
261             *
262             * タイプã?ã€?head/body/foot/<del>ith/itd</del>" ã®ä¸­ã‹ã‚‰ã€æŒ‡å®šã—ã¾ã™ã?
263             *
264             * @return      ã“ã?フォーマットã?タイプを返ã—ã¾ã™ã?
265             */
266    //      public String getFormatType() {
267    //              return formatType;
268    //      }
269    
270            /**
271             * ãƒ??ブル㮠rowspan 属æ?ã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?
272             * rowspan ã¯ã€ã?ãƒ?ƒ€ãƒ¼éƒ¨ã®ãƒ•ォーマットã?行数ã§ã™ã?åˆæœŸå€¤ã¯ ?’è¡?ã§ã™ã?
273             * 設定ã?ã€?2" ãªã©ã®ã€æ•°å­—部ã®ã¿ã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?
274             *
275             * @param  rowspan 属æ?
276             */
277            public void setRowspan( final String rowspan ) {
278                    if( rowspan == null || rowspan.length() == 0 || rowspan.equals( "1" ) ) {
279                            this.rowspan = "";
280                    }
281                    else {
282                            this.rowspan = " rowspan=\"" + rowspan + "\"";
283                    }
284            }
285    
286            /**
287             * 設定ã•れ㟠rowspan ã‚’è¿”ã—ã¾ã™ã?
288             * ã“れã¯ã€ãƒ•ォーマットã?段çµ??æ•°ã‚’å–りå?ã—ã¾ã™ã?
289             * æ–?­—å?ã¨ã—ã¦ã¯ã€rowspan="2" ã¨ã?†å½¢ã§å–り出ã—ã¾ã™ã?
290             *
291             * @return フォーマット文字å?
292             */
293            public String getRowspan() {
294                    return rowspan;
295            }
296    
297            /**
298             * ロケーション番å·ã®ã‚µã‚¤ã‚ºã‚’è¿”ã—ã¾ã™ã?
299             * フォーãƒ?½ç½®ç•ªå·ã¯ã€? ã‹ã‚‰ getLocationSize()-1 ã¾ã§ã®æ•°å­—ã‚’æŒ?®šã—ã¾ã™ã?
300             * ロケーションサイズã¯ã€aaa[ABC]bbb[DEF]ccc[GHI]ddd ã¨ãªã£ã¦ã?‚‹å ´åˆã?
301             * aaa , bbb , ccc , ddd ã¯ã€ãƒ•ォーマットã§ã€ã‚µã‚¤ã‚ºã¯?”ã?
302             * ABC , DEF , GHI ã«å¯¾å¿œã™ã‚‹ã‚«ãƒ©ãƒ?•ªå·ãŒãƒ­ã‚±ãƒ¼ã‚·ãƒ§ãƒ³ã§ã€ã‚µã‚¤ã‚ºã¯?“ã?
303             * ã“ã?メソãƒ?ƒ‰ã§è¿”ã™ã®ã¯ã€ãƒ­ã‚±ãƒ¼ã‚·ãƒ§ãƒ³ç•ªå·(??ã®æ–¹ã§ã™ã?
304             *
305             * @return  ロケーション番å·ã®ã‚µã‚¤ã‚º
306             */
307            public int getLocationSize() {
308                    return location.length;
309            }
310    
311            /**
312             * カラãƒ??ロケーション番å·ã‚’è¿”ã—ã¾ã™ã?
313             * 引数ã¯ã€? ã‹ã‚‰ã€getLocationSize()-1 ã¾ã§ã®æ•°ã§æŒ?®šã—ã¾ã™ã?
314             * æŒ?®šã?ä½ç½®ã®ã€ãƒ•ォーマットã?カラãƒ?ã«å¯¾å¿œã™ã‚‹ãƒ­ã‚±ãƒ¼ã‚·ãƒ§ãƒ³ç•ªå·
315             * ã‚’è¿”ã—ã¾ã™ã?
316             *
317             * @param no フォーãƒ?½ç½®ç•ªå·
318             *
319             * @return ロケーション番å·
320             */
321            public int getLocation( final int no ) {
322                    return location[no];
323            }
324    
325            /**
326             * フォーマット文字å?ã‚’è¿”ã—ã¾ã™ã?
327             * 引数ã¯ã€? ã‹ã‚‰ã€getLocationSize() ã¾ã§ã®æ•°ã§æŒ?®šã—ã¾ã™ã?
328             * æŒ?®šã?フォーマットãŒã€aaa[ABC]bbb[DEF]ccc[GHI]ddd ã¨ãªã£ã¦ã?‚‹å ´åˆã?
329             * aaa , bbb , ccc , ddd を引数 0 , 1 , 2 , 3 ã§è¿”ã—ã¾ã™ã?
330             *
331             * @param no フォーãƒ?½ç½®ç•ªå·
332             *
333             * @return フォーマット文字å?
334             */
335            public String getFormat( final int no ) {
336                    return format[no];
337            }
338    
339            /**
340             * シスãƒ?ƒ ãƒ•ォーマット文字å?ã‚’è¿”ã—ã¾ã™ã?
341             * シスãƒ?ƒ ãƒ•ォーマット文字å?ã¯ã€[KEY.カラãƒ?] ãªã©ã®ç‰¹æ®Šè¨˜å·ã§æŒ?®šã•れãŸ
342             * カラãƒ?ã®äº‹ã§ã€location ã«ã¯ã€ã?イナスã®å€¤ãŒè¨­å®šã•れã¾ã™ã?
343             * マイナスã®å€¤ã«å¿œã˜ã¦ã€å?ç?‚’変ãˆã‚‹ã“ã¨ãŒå?æ¥ã¾ã™ã?
344             *
345             * [KEY.カラãƒ?] : 行番å·ä»˜ãカラãƒ?
346             * [I]            : 行番å·
347             * [ROW.ID]       : 行毎ã?ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®ID
348             * [ROW.JSON]     : 行毎ã?å…¨ãƒ??ã‚¿ã®JavaScriptオブジェクト形å¼?
349             *
350             * @og.rev 3.5.5.0 (2004/03/12) [KEY.カラãƒ?] 機è?追åŠ?
351             * @og.rev 3.5.5.2 (2004/04/02) [I] ã§ã€è¡Œç•ªå·ã‚’作æ?ã—ã¾ã™ã?
352             * @og.rev 3.6.0.0 (2004/09/17) [ROW.ID] ã§ã€è¡Œæ¯Žã?ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®IDã‚’è¿”ã—ã¾ã™ã?
353             * @og.rev 4.0.0.0 (2007/05/02) Formatter を使用ã™ã‚‹ã‚ˆã†ã«å¤‰æ›´
354             *
355             * @param       row     行番å·
356             * @param       loc     ä½ç½®ç•ªå·
357             *
358             * @return フォーマット文字å?
359             */
360            public String getSystemFormat( final int row,final int loc ) {
361                    if( loc == Formatter.SYS_ROWNUM ) {
362                            return String.valueOf( row );
363                    }
364                    else if( loc == Formatter.SYS_JSON ) {
365                            return formatter.getJson( row );
366                    }
367    
368                    String errMsg = "シスãƒ?ƒ ãƒ•ォーマットã?ã€ä¸‹è¨˜ã?å½¢å¼ã—ã‹ä½¿ç”¨ã§ãã¾ã›ã‚“ã€?" + loc + "]" + HybsSystem.CR
369                                    + "  : [KEY.カラãƒ?] : 行番å·ä»˜ãカラãƒ?" + HybsSystem.CR
370                                    + "  : [I]            : 行番å·" + HybsSystem.CR
371                                    + "  : [ROW.ID]       : 行毎ã?ãƒã‚§ãƒ?‚¯ãƒœãƒƒã‚¯ã‚¹ã®ID" + HybsSystem.CR
372                                    + "  : [ROW.JSON]     : 行毎ã?å…¨ãƒ??ã‚¿ã®JavaScriptオブジェクト形å¼? ;
373                    throw new HybsSystemException( errMsg );
374            }
375    
376    //      public String getSystemFormat( final int row,final int no ) {
377    //              if( location[no] == SYSFORM_KEY_CLM ) {
378    //                      return systemFormat[no] + HybsSystem.JOINT_STRING + row ;
379    //              }
380    //              else if( location[no] == SYSFORM_ROWNUM ) {
381    //                      return String.valueOf( row );
382    //              }
383    //              else if( location[no] == SYSFORM_ROW_ID ) {
384    //                      return HybsSystem.ROW_ID_KEY + row;
385    //              }
386    //
387    //              String errMsg = "シスãƒ?ƒ ãƒ•ォーマットã?ã€ä¸‹è¨˜ã?å½¢å¼ã—ã‹ä½¿ç”¨ã§ãã¾ã›ã‚“ã€?" + location[no] + "]" + HybsSystem.CR
388    //                              + "  " + SYSFORM_KEY_CLM + ": [KEY.カラãƒ?] カラãƒ?D(接続記å·)è¡Œç•ªå· ã¨ã?†ãƒ•ィールドキーを作æ?"
389    //                              + "  " + SYSFORM_ROWNUM  + ": [I] 行番å·ã‚’作æ?" ;
390    //              throw new HybsSystemException( errMsg );
391    //      }
392    
393            /**
394             * タイプ文字å?ã‚’è¿”ã—ã¾ã™ã?
395             * タイプã¨ã¯ã€[XXX] ã®è¨˜è¿°ã§ã€[#XXX] ã¯ã€XXXカラãƒ??ラベルをã?[$XXX]ã¯ã€XXXカラãƒ??
396             * レンãƒ?ƒ©ãƒ¼ã‚’ã?[!XXX} ã¯ã€å?ã®ã¿å–ã‚Šå‡ºã™æŒ‡å®šã‚’行ã„ã¾ã™ã?
397             * 主ã«ã€TextFieldç³»ã®ãƒ•ォーマットã¨Tableç³»ã§ã¯ã€æ„味åˆã„ãŒç•°ãªã‚Šã¾ã™ã?ã§ã€?
398             * ã”æ³¨æ„ãã?•ã??
399             *
400             * @param no フォーãƒ?½ç½®ç•ªå·
401             *
402             * @return タイプ文字å? '#':ラベルã®ã¿  '$':レンãƒ?ƒ©ãƒ¼ '!':値ã®ã¿  ãã?ä»?通常
403             */
404            public char getType( final int no ) {
405                    return type[no];
406            }
407    
408            /**
409             * 設定ã•れ㟠フォーマットã? trã‚¿ã‚°ã‚’è¿”ã—ã¾ã™ã?
410             * ã“れã¯ã€trã‚¿ã‚°ã«class属æ?ä»–ã?設定ãŒã•れã¦ã?Ÿå ´åˆã«ã€å¤‰æ›å¾Œã?
411             * æ–?­—å?ã«ã‚‚åæ˜?•ã›ã‚‹ç‚ºã«å¿?¦ã§ã™ã?
412             *
413             * @og.rev 5.1.7.0 (2010/06/01) サニタイズ戻ã—å?ç?"\\]\\"ã‹ã‚‰"["ã«æˆ»ã?を追åŠ?
414             *
415             * @return フォーマットã? trã‚¿ã‚°
416             */
417            public String getTrTag() {
418                    if( trTag == null ) { return ""; }
419    
420    //              return trTag ;
421                    return decodeSanitizedStr( trTag ) ;
422            }
423    
424            /**
425             * カラãƒ??クラスå?<de>VERCHAR2 , NUMBER</del>X,S9 ãªã©)ã®ã‚»ãƒ?ƒˆã‚’行ã†ã‹ã©ã?‹æŒ?®šã—ã¾ã™ã?
426             *
427             * "true" ã§ã€ã‚¯ãƒ©ã‚¹å±žæ?を設定ã—ã¾ã›ã‚“。ã“れã?ã€?¼£?³?³ãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸ã‹ã‚Œã¦ã?‚‹å±žæ?ã‚?
428             * 使用ã—ãªã?“ã¨ã‚’æ„味ã—ã¾ã™ã?
429             * åˆæœŸå€¤ã¯ã€?false" ã§ã™ã?
430             *
431             * @param       flag クラスåä½¿ç”¨ã®æœ‰ç„¡(true:使用ã—ãªã?false:使用ã™ã‚‹ã€?
432             */
433            public void setNoClass( final String flag ) {
434                    noClass = StringUtil.nval( flag,noClass );
435            }
436    
437            /**
438             * カラãƒ??クラスå?<de>VERCHAR2 , NUMBER</del>X,S9 ãªã©)ã®ã‚»ãƒ?ƒˆã‚’行ã†ã‹ã©ã?‹å–å¾—ã—ã¾ã™ã?
439             *
440             * "true" ã§ã€ã‚¯ãƒ©ã‚¹å±žæ?を設定ã—ã¾ã›ã‚“。ã“れã?ã€?¼£?³?³ãƒ•ã‚¡ã‚¤ãƒ«ã«æ›¸ã‹ã‚Œã¦ã?‚‹å±žæ?ã‚?
441             * 使用ã—ãªã?“ã¨ã‚’æ„味ã—ã¾ã™ã?
442             * åˆæœŸå€¤ã¯ã€?false" ã§ã™ã?
443             *
444             * @return      クラスåä½¿ç”¨ã®æœ‰ç„¡(true:使用ã—ãªã?false:使用ã™ã‚‹ã€?
445             */
446            public boolean isNoClass() {
447                    return noClass;
448            }
449    
450            /**
451             * フォーマットã?使用å¯å¦ã‚’判断ã™ã‚‹ã‚­ãƒ¼ã¨ãªã‚‹ã‚«ãƒ©ãƒ?を指定ã—ã¾ã™ã?
452             *
453             * キーãŒã?usableList ã«å«ã¾ã‚Œã‚‹å ´åˆã?ã€ã“ã®ãƒ•ォーãƒ?‚’使用ã§ãã¾ã™ã?
454             * キー(カラãƒ?)ãŒæŒ‡å®šã•れãªã??åˆã?ã€å¸¸ã«ä½¿ç”¨ã•れã¾ã™ã?
455             * ※ ç¾æ™‚点ã§ã¯ã€BODYタイプã?ã¿ä½¿ç”¨ã—ã¦ã?¾ã™ã?
456             *
457             * @param  key フォーマットã?使用å¯å¦ã‚’判断ã™ã‚‹ã‚«ãƒ©ãƒ?
458             */
459            public void setUsableKey( final String key ) {
460                    usableKey = key;
461            }
462    
463            /**
464             *  フォーマットã?使用å¯å¦ã‚’判断ã™ã‚‹æ–?­—å?リストをæŒ?®šã—ã¾ã™ã?
465             *
466             * キーãŒã?ã“ã?æ–?­—å?リスト中ã«å­˜åœ¨ã™ã‚‹å ´åˆã?ã€ã“ã®ãƒ•ォーãƒ?‚’使用ã§ãã¾ã™ã?
467             * ã“ã?æ–?­—å?リストã?ã€å›ºå®šãªæ–?­—å?ã§ã™ã?{&64;XXXX}ã¯ä½¿ç”¨ã§ãã¾ã™ãŒã€[XXXX]ã¯
468             * 使用ã§ãã¾ã›ã‚“ã€?
469             * åˆæœŸå€¤ã¯ã€?1" ã§ã™ã?
470             * ※ ç¾æ™‚点ã§ã¯ã€BODYタイプã?ã¿ä½¿ç”¨ã—ã¦ã?¾ã™ã?
471             *
472             * @param  list フォーマットã?使用å¯å¦ã‚’判断ã™ã‚‹æ–?­—å?リスãƒ?
473             * @see TableFormatter#isUse( int,DBTableModel )
474             */
475            public void setUsableList( final String list ) {
476                    if( list != null ) {
477                            usableList = list;
478                    }
479            }
480    
481            /**
482             * ã“ã?フォーマットを使用ã™ã‚‹ã‹ã©ã?‹ã®å•ã„åˆã‚ã›ã‚’è¿”ã—ã¾ã™ã?
483             *
484             * "true" ã§ã€ä½¿ç”¨ã—ã¾ã™ã?setUsableKey( String ) ã§ã€æŒ‡å®šã•れãŸ
485             * カラãƒ?ã®å€¤ãŒã?setUsableList( String ) ã§æŒ?®šã•ã‚ŒãŸæ–?­—å?ã«å«ã¾ã‚Œã¦ã?‚Œã°ã€?
486             * 使用ã—ã¾ã™ã?カラãƒ?ãŒã‚»ãƒ?ƒˆã•れãªã??åˆã?ã€ãƒ‡ãƒ•ォルトå?("true")ãŒä½¿ç”¨ã•れã¾ã™ã?
487             * ※ ç¾æ™‚点ã§ã¯ã€BODYタイプã?ã¿ä½¿ç”¨ã—ã¦ã?¾ã™ã?
488             * カラãƒ??ãƒ??ã‚¿ã«ã€ä¸æ­£ãªã‚¹ãƒšã?スãŒå?ã‚‹å?åˆã‚’想定ã—ã¦ã€trim() ã—ã¦ã?¾ã™ã?
489             * よã£ã¦ã€usableList ã®å€¤ã«ã‚¹ãƒšã?スã¯ä½¿ç”¨ã§ãã¾ã›ã‚“ã€?
490             *
491             * @og.rev 3.5.6.2 (2004/07/05) 判定評価用カラãƒ??値ã‚?trim() ã—ã¾ã™ã?
492             *
493             * @param  row 行番å·
494             * @param       table   DBTableModelオブジェク�
495             *
496             * @return      ã“ã?フォーãƒ?‚’使用ã™ã‚‹ã‹ã©ã?‹(true:使用ã™ã‚‹/false:使用ã—ãªã?
497             * @see TableFormatter#setUsableKey( String )
498             * @see TableFormatter#setUsableList( String )
499             */
500            public boolean isUse( final int row, final DBTableModel table ) {
501                    if( usableKeyNo < 0 ) { return true; }
502                    String val = table.getValue( row,usableKeyNo ).trim();
503                    return ( val.length() == 0 ? false : usableList.indexOf( val ) >= 0 );
504            }
505    
506            /**
507             *  itdフォーマット文字å?を設定ã—ã¾ã™ã?
508             *
509             * itd ãƒœãƒ‡ã‚£éƒ¨ã®æ–?­—å?を指定ã—ã¾ã™ã?
510             * itd ボディã¯ã€ç¹°ã‚Šè¿”ã—処ç?‚’行ã„ã¾ã™ã?ã“れをã?上ä½ã?ボディæ–?­—å?ã®ä¸­ã®
511             * HYBS_ITD_MARKER æ–?­—å? ã¨ç½®ãæ›ãˆã¾ã™ã?
512             *
513             * @og.rev 3.5.6.0 (2004/06/18) itdフォーマット文字å?ã®å–り込ã¿
514             *
515             * @param  itd itdフォーマットã?æ–?­—å?
516             */
517            public void setItdBody( final String itd ) {
518                    if( itd != null ) {
519                            itdBody = itd;
520                    }
521            }
522    
523            /**
524             *  itdフォーマット文字å?ã‚’å–å¾—ã—ã¾ã™ã?
525             *
526             * itd ãƒœãƒ‡ã‚£éƒ¨ã®æ–?­—å?ã‚’å–å¾—ã—ã¾ã™ã?
527             * itd ボディã¯ã€ç¹°ã‚Šè¿”ã—処ç?‚’行ã„ã¾ã™ã?ã“れをã?上ä½ã?ボディæ–?­—å?ã®ä¸­ã®
528             * HYBS_ITD_MARKER æ–?­—å? ã¨ç½®ãæ›ãˆã¾ã™ã?
529             *
530             * @og.rev 3.5.6.0 (2004/06/18) itdフォーマット文字å?ã®å–り込ã¿
531             *
532             * @return      itdフォーマットã?æ–?­—å?
533             */
534            public String getItdBody() {
535                    return itdBody;
536            }
537    
538            /**
539             * ã‚µãƒ‹ã‚¿ã‚¤ã‚ºã®æˆ»ã?"\\]\\"ã‹ã‚‰"["ã«æˆ»ã?を行ã„ã¾ã™ã?
540             *
541             * @og.rev 5.1.7.0 (2010/06/01) æ–°è¦ä½œæ?
542             *
543             * @param str サニタイズã•ã‚ŒãŸæ–‡å­—å?
544             *
545             * @return サニタイズ戻ã—å?ç?¾Œã?æ–?­—å?
546             */
547            private String decodeSanitizedStr( final String str ) {
548                    if( str != null && str.indexOf( "\\]\\" ) >= 0 ) {
549                            return str.replace( "\\]\\", "[" );
550                    }
551                    else {
552                            return str;
553                    }
554            }
555    }