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.1.3.0 (2010/02/01)" ;
047
048 /**
049 * action ã§æŒ?®šã•れãŸã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã—ã¦ã€å?ã®å¤‰æ›ã‚’行ã„ã¾ã™ã?
050 * oldValue(æ—§ãƒ??ã‚¿)ã¯ã€å?ã®DBTableModelã«è¨å®šã•れã¦ã?Ÿå€¤ã§ã™ã?通常ã¯ã€?
051 * ã“ã?値を使用ã—ã¦ã‚«ãƒ©ãƒ?¯Žã«å¤‰æ›ã‚’行ã„ã¾ã™ã?newValue(æ–°ãƒ??ã‚¿)ã¯ã€å¼•æ•°ã§
052 * æŒ?®šã•ã‚ŒãŸæ–°ã—ã„値ã§ã™ã?ã“ã?値ã«ã¯ã€ãƒ‘ラメータを指定ã—ã¦å¤‰æ›æ–¹æ³•ã‚’
053 * 制御ã™ã‚‹ã“ã¨ã‚‚å¯èƒ½ã§ã™ã?
054 * æŒ?®šã?アクションãŒã‚«ãƒ©ãƒ?§å‡¦ç?§ããªã??åˆã?ã€ã‚¨ãƒ©ãƒ¼ã«ãªã‚Šã¾ã™ã?
055 *
056 * @og.rev 5.1.3.0 (2010/02/01) æ–°è¦è¿½åŠ?
057 *
058 * @param action アクションコマン�
059 * @param oldValue 入力データ(旧�?タ)
060 * @param newValue 入力データ(新�?タ)
061 *
062 * @return 実行後ã?ãƒ??ã‚¿
063 */
064 @Override
065 public String valueAction( final String action,final String oldValue,final String newValue ) {
066 if( "VALSET".equals( action ) ) {
067 String val = StringUtil.rTrim( oldValue ) ;
068
069 if( val != null && val.length() > 0 ) {
070 // 共通:シングルクオートã?ãšã—
071 int pos1 = val.indexOf( "'",1 );
072 if( pos1 > 1 ) { val = val.substring( 1,pos1 ); }
073 // 共通:å?期å?ã« /* */ コメントãŒå…¥ã‚‹ã“ã¨ãŒã‚ã‚‹ã?ã§ã€å‰Šé™¤
074 int pos2 = val.indexOf( "/*" );
075 if( pos2 > 0 ) { val = val.substring( 0,pos2 ); }
076
077 // postgreSQL 対応:属æ?æƒ??ãŒå?ã‚‹ã?ã§ã€å‰Šé™¤
078 int pos3 = val.indexOf( "::" );
079 if( pos3 > 0 ) { val = val.substring( 0,pos3 ); }
080 // postgreSQL 対応:属æ?æƒ??ãŒå?ã‚‹ã?ã§ã€å‰Šé™¤
081 // ??oldValue ã§åˆ¤æ–ã—ã¦ã?‚‹ã®ã¯ã€val ã¯ã€å?ã«è‰²ã€?¨åŠ?·¥ã—ã¦ã?‚‹ç‚º
082 if( oldValue.startsWith( "nextval" ) ) { val = ""; }
083 }
084
085 return val ;
086 }
087 else {
088 return super.valueAction( action,oldValue,newValue ) ;
089 }
090 }
091 }