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.plugin.column; 017 018 import org.opengion.hayabusa.db.AbstractRenderer; 019 import org.opengion.hayabusa.db.CellRenderer; 020 import org.opengion.hayabusa.db.DBColumn; 021 022 /** 023 * YMD レンãƒ?ƒ©ãƒ¼ã¯ã€ã‚«ãƒ©ãƒ??ãƒ??ã‚¿ã‚’æ—¥ä»?æœ?æ—¥)表示ã™ã‚‹å ´åˆã«ä½¿ç”¨ã™ã‚‹ã‚¯ãƒ©ã‚¹ã§ã™ã? 024 * å…??æ–?—å?ã®5,6æ¡ç›®ã‚’月ã¨ã—ã¦ã€?,8æ¡ç›®ã‚’æ—¥ã¨ã—ã¦è¡¨ç¤ºã—ã¾ã™ã? 025 * 026 * ã“ã?クラスã¯ã€ä¸å¤‰ã‚ªãƒ–ジェクトã¨ã—ã¦ã€å?有ã•れã¾ã™ã? 027 * 028 * @og.group ãƒ??タ表示 029 * 030 * @og.rev 4.3.7.1 (2009/06/08) æ–°è¦ä½œæ? 031 * 032 * @version 4.0 033 * @author Takahashi Masakazu 034 * @since JDK5.0, 035 */ 036 public class Renderer_MD extends AbstractRenderer { 037 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */ 038 private static final String VERSION = "5.5.8.1 (2012/11/05)" ; 039 040 private static final CellRenderer dbCell = new Renderer_MD() ; 041 042 /** 043 * å?‚ªãƒ–ジェクトã‹ã‚‰è?åˆ??インスタンスを返ã—ã¾ã™ã? 044 * 自åˆ??身をã‚ャãƒ?‚·ãƒ¥ã™ã‚‹ã®ã‹ã?æ–°ãŸã«ä½œæ?ã™ã‚‹ã®ã‹ã?ã€å„サブクラスã®å®Ÿè£?« 045 * ã¾ã‹ã•れã¾ã™ã? 046 * 047 * @param clm DBColumnオブジェクãƒ? 048 * 049 * @return CellRendererオブジェクãƒ? 050 */ 051 public CellRenderer newInstance( final DBColumn clm ) { 052 return dbCell; 053 } 054 055 /** 056 * ãƒ??ã‚¿ã®è¡¨ç¤ºç”¨æ–?—å?ã‚’è¿”ã—ã¾ã™ã? 057 * ã“ã“ã§ã¯ã€null ã?ã‚¼ãƒæ–?—å?ã®å ´åˆã?ã€ã‚¼ãƒæ–?—å?ã‚’è¿”ã—ã¾ã™ã? 058 * ?”ケタ以外ã??˜ã‚±ã‚¿ä»¥ä¸‹ã?ãƒ??ã‚¿ãªã©ã€æ£å¸¸ã«å‡¦ç?§ããªã‹ã£ãŸå?åˆã?ã€ã‚¨ãƒ©ãƒ¼è¡¨ç¤ºã‚’行ã„ã¾ã™ã? 059 * å…?Œ?˜ã‚±ã‚¿ä»¥ä¸Šã?å ´åˆã?å…ˆé?ã‹ã‚‰8æ–?—ã‚’YYYYMMDD ã¨ã—ã¦ã€MM/DD ã‚’è¿”ã—ã¾ã™ã? 060 * ?”ケタã®å ´åˆã?ã€MMDD ã‚’ã?MM/DD ã¨ã—ã¦è¿”ã—ã¾ã™ã? 061 * 062 * @og.rev 5.5.7.2 (2012/10/09) 処ç?ƒã‚¸ãƒ?‚¯ã®è¦‹ç›´ã? 063 * @og.rev 5.5.8.1 (2012/11/05) コãƒãƒ³ã‚’スラãƒ?‚·ãƒ¥ã«ä¿®æ£ã€?æ–?—以上ã?処ç? 064 * 065 * @param value 入力å? 066 * 067 * @return ãƒ??ã‚¿ã®è¡¨ç¤ºç”¨æ–?—å? 068 */ 069 @Override 070 public String getValue( final String value ) { 071 if( value == null || value.length() == 0 ) { return ""; } 072 073 String rtn = value; 074 075 char[] ch1 = new char[5]; 076 if( rtn.length() == 4 ) { 077 ch1[0] = rtn.charAt(0); 078 ch1[1] = rtn.charAt(1); 079 ch1[2] = '/' ; // 5.5.8.1 (2012/11/05) 080 ch1[3] = rtn.charAt(2); 081 ch1[4] = rtn.charAt(3); 082 083 rtn = new String( ch1 ); 084 } 085 else if( rtn.length() >= 8 ) { 086 ch1[0] = rtn.charAt(4); 087 ch1[1] = rtn.charAt(5); 088 ch1[2] = '/' ; // 5.5.8.1 (2012/11/05) 089 ch1[3] = rtn.charAt(6); 090 ch1[4] = rtn.charAt(7); 091 092 rtn = new String( ch1 ); 093 } 094 else { 095 rtn = "<span class=\"error\">" + value + "</span>"; 096 } 097 return rtn; 098 099 // final String rtn; 100 // if( value == null || value.length() == 0 ) { 101 // rtn = ""; 102 // } 103 // else if( value.length() >= 8 ) { 104 // StringBuilder buf = new StringBuilder(); 105 // buf.append( value.substring(4,6) ); 106 // buf.append( "/" ); 107 // buf.append( value.substring(6,8) ); 108 // rtn = buf.toString(); 109 // } 110 // else { 111 // rtn = "<span class=\"error\">" + value + "</span>"; 112 // } 113 // return rtn; 114 } 115 }