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.fukurou.util.StringUtil; 019 import org.opengion.hayabusa.db.AbstractDBType; 020 021 /** 022 * DATA_DEFAULT カラãƒ?§ã€å?å®¹ã®æ•´åˆæ?ã‚’æ•´ãˆã¾ã™ã? 023 * 024 * DATA_DEFAULT(åˆæœŸå€¤)カラãƒ??ã€ãƒ‡ãƒ¼ã‚¿ãƒ™ã?ス上ã«è¨å®šã•れã¦ã?¾ã™ãŒã€? 025 * DB定義スクリプトã‚??ãƒ??タベã?スã®ç¨®é¡žã«ã‚ˆã£ã¦ã€æœ¬æ¥å¿?¦ãªå½¢å¼ã§ 026 * å–å¾—ã§ããªã?¨ããŒã‚りã¾ã™ã? 027 * ã“ã“ã§ã¯ã€å?期å?ã®å¾Œã‚㫠コメントãŒã‚ã‚‹å ´åˆã?ã€å‰Šé™¤ã—ã? 028 * ãƒ??ã‚¿ãã?ã‚‚ã?ã«ã€ã‚·ãƒ³ã‚°ãƒ«ã‚¯ã‚ªãƒ¼ãƒˆã‚’ã¯ãšã—ã¾ã™ã? 029 * 定義æƒ??出力時ã«ã¯ã€ã‚«ãƒ©ãƒ??属æ?(æ•°å—åž‹ã€æ–‡å—åž‹) 030 * ã¾ãŸã?postgreSQL 対応ã¨ã—ã¦ã€?:属æ?æƒ??ãŒå?ã‚‹ã?ã§ã€å‰Šé™¤ã—ã¾ã™ã? 031 * シーケンス使用時ã«ã‚‚ã?nextval ãŒè?å‹•çš„ã«ã‚»ãƒ?ƒˆã•れã¾ã™ãŒã€? 032 * 削除ã—ã¾ã™ã? 033 * 034 * ã“ã?クラスã¯ã€valueAction メソãƒ?ƒ‰ã§ã€action="VALSET" ã§ã®ã¿ 035 * 動作ã—ã¾ã™ã? 036 * 037 * @og.group ãƒ??タ属æ? 038 * @og.rev 5.1.3.0 (2010/02/01) æ–°è¦ä½œæ? 039 * 040 * @version 4.0 041 * @author Kazuhiko Hasegawa 042 * @since JDK5.0, 043 */ 044 public class DBType_DD extends AbstractDBType { 045 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */ 046 private static final String VERSION = "5.7.6.3 (2014/05/23)" ; 047 048 /** 049 * action ã§æŒ?®šã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ã€å?ã®å¤‰æ›ã‚’行ã„ã¾ã™ã? 050 * oldValue(æ—§ãƒ??ã‚¿)ã¯ã€å?ã®DBTableModelã«è¨å®šã•れã¦ã?Ÿå€¤ã§ã™ã?通常ã¯ã€? 051 * ã“ã?値を使用ã—ã¦ã‚«ãƒ©ãƒ?¯Žã«å¤‰æ›ã‚’行ã„ã¾ã™ã?newValue(æ–°ãƒ??ã‚¿)ã¯ã€å¼•æ•°ã§ 052 * æŒ?®šã•ã‚ŒãŸæ–°ã—ã„値ã§ã™ã?ã“ã?値ã«ã¯ã€ãƒ‘ラメータを指定ã—ã¦å¤‰æ›æ–¹æ³•ã‚’ 053 * 制御ã™ã‚‹ã“ã¨ã‚‚å¯èƒ½ã§ã™ã? 054 * æŒ?®šã?アクションãŒã‚«ãƒ©ãƒ?§å‡¦ç?§ããªã??åˆã?ã€ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã? 055 * 056 * @og.rev 5.1.3.0 (2010/02/01) æ–°è¦è¿½åŠ? 057 * @og.rev 5.7.6.2 (2014/05/16) -- コメント対応ã?処ç??å…¨é¢è¦‹ç›´ã? 058 * @og.rev 5.7.6.3 (2014/05/23) 処ç?¯¾è±¡ä»¥å¤–ã?ã€newValue ã‚’è¿”ã™ã?‘ã€? 059 * 060 * @param action アクションコマンãƒ? 061 * @param oldValue 入力データ(æ—§ãƒ??ã‚¿) 062 * @param newValue 入力データ(æ–°ãƒ??ã‚¿) 063 * 064 * @return 実行後ã?ãƒ??ã‚¿ 065 */ 066 @Override 067 public String valueAction( final String action,final String oldValue,final String newValue ) { 068 // if( "VALSET".equals( action ) ) { 069 if( "VALSET".equals( action ) && oldValue != null ) { 070 // String val = StringUtil.rTrim( oldValue ) ; 071 String val = oldValue.trim() ; 072 073 // if( val != null && val.length() > 0 ) { 074 if( val.length() > 0 ) { 075 // 共通:å?期å?ã« /* */ コメントãŒå…¥ã‚‹ã“ã¨ãŒã‚ã‚‹ã?ã§ã€å‰Šé™¤ 076 int pos = val.indexOf( "/*" ); 077 if( pos > 0 ) { val = val.substring( 0,pos ); } 078 079 // 共通:å?期å?ã« -- コメントãŒå…¥ã‚‹ã“ã¨ãŒã‚ã‚‹ã?ã§ã€å‰Šé™¤ 080 pos = val.indexOf( "--" ); 081 if( pos > 0 ) { val = val.substring( 0,pos ); } 082 083 // postgreSQL 対応:属æ?æƒ??ãŒå?ã‚‹ã?ã§ã€å‰Šé™¤ 084 pos = val.indexOf( "::" ); 085 if( pos > 0 ) { val = val.substring( 0,pos ); } 086 087 // postgreSQL 対応:シーケンス使用時ã«ã‚‚ã?nextval ãŒè?å‹•çš„ã«ã‚»ãƒ?ƒˆã•れるã?ã§ã€å‰Šé™¤ 088 pos = val.indexOf( "nextval" ); 089 if( pos > 0 ) { val = val.substring( 0,pos ); } 090 091 val = val.trim(); // ä¸?—¦ã€trim ã—ã¾ã™ã? 092 093 // 共通ï¼?.7.6.3 (2014/05/23) シングルクオートã?ãšã—(å…ˆé?ã‹ã?末尾ã«ä»˜ã„ã¦ã?‚‹å ´åˆã?ã€ã™ã¹ã¦ã®ã‚·ãƒ³ã‚°ãƒ«ã‚¯ã‚ªãƒ¼ãƒˆã‚’外ã—ã¾ã™ã?) 094 if( val.startsWith("'") || val.endsWith("'") ) { 095 val = StringUtil.replace( val,"'","" ); 096 } 097 098 // 共通:シングルクオートã?ãšã—(å…ˆé?ã«ä»˜ã„ã¦ã?‚‹å ´åˆã?次ã®ä½ç½®ã‚’発見ã—ã¦ã€ä»¥é™ã‚’削除) 099 // if( val.indexOf( "'" ) == 0 ) { 100 // pos = val.indexOf( "'",1 ); 101 // if( pos > 1 ) { val = val.substring( 1,pos ); } 102 // } 103 } 104 105 return val ; 106 } 107 else { 108 // 5.7.6.3 (2014/05/23) 処ç?¯¾è±¡ä»¥å¤–ã?ã€newValue ã‚’è¿”ã™ã?‘ã€? 109 // return super.valueAction( action,oldValue,newValue ) ; 110 return newValue; 111 } 112 } 113 }