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.ErrorMessage;
019 import org.opengion.fukurou.util.StringUtil;
020 import org.opengion.hayabusa.db.AbstractDBType;
021 import org.opengion.hayabusa.db.DBTypeCheckUtil;
022
023 /**
024 * å…¨è§?改行C(CR,LF)ã�®ã�¿ã�§æ§‹æ?ã�•れる文å—å?を扱ã�?‚ºã�®ã€�カラãƒ?±žæ?を定義ã�—ã�¾ã�™ã?
025 *
026 * 全角文å—ã�¨ã�¯ã€�ã?c < 0x7f || ( 0xff65 <= c && c < 0xffa0 ) 以外ã?
027 * ã�®æ–?—ã�§æ§‹æ?ã�•れる文å—å?ã�®ã�“ã�¨ã�§ã�™ã?
028 *
029 * タイプãƒ�ã‚§ãƒ?‚¯ã�¨ã�—ã�¦ã€�以下ã?æ�¡ä»¶ã‚’判定ã�—ã�¾ã�™ã?
030 * ・全角文å—ãƒ�ã‚§ãƒ?‚¯ã€Œc < 0x7f || ( 0xff65 <= c && c < 0xffa0 ) 以外ã?ã�‹ã�¤æ”¹è¡ŒC以外ã?c != 0x0a && c != 0x0d以外ã?エラー
031 * ・æ–?—å?é•·ã�¯ã€�Byteæ�›ç®—ã�§ã�®æ–?—æ•°ã�¨ã�®æ¯”è¼?
032 * ・æ–?—パラメータã�® æ£è¦�表ç�¾ãƒ�ã‚§ãƒ?‚¯
033 *
034 * @og.group ãƒ??タ属æ?
035 *
036 * @version 4.0
037 * @author Hiroki Nakamura
038 * @since JDK5.0,
039 */
040 public class DBType_KCL extends AbstractDBType {
041 //* ã�“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã�—ã�¾ã�™ã? {@value} */
042 private static final String VERSION = "5.2.2.0 (2010/11/01)" ;
043
044 /**
045 * å�Šè§’スペã?スã�§å›ºå®šé•·(å�Šè§’æ�›ç®—ã?æ•°)ã�«å¤‰æ�›ã�—ã�Ÿæ–?—å?ã‚’è¿”ã�—ã�¾ã�™ã?
046 * å�Šè§’スペã?ス埋ã‚�ã�¯ã€�æ–‡å—ã�Œå�Šè§’ã?全角混在ã�§ã‚‚ã�‹ã�¾ã�?�¾ã�›ã‚“ã€?
047 * ã�ªã�Šã?エラーãƒ�ã‚§ãƒ?‚¯ã�¯è¡Œã‚�れã�¾ã�›ã‚“ã€?
048 * 実行å‰�ã�«ã€�å¿?�š valueCheck( String value ,int len ) ã�Œè¡Œã‚�れるå¿?¦�ã�Œã�‚りã�¾ã�™ã?
049 *
050 * @param value ?¦?©?¬?¬åŸ‹ã‚�ã�™ã‚‹æ–?—å?
051 * @param sizeX 整数部åˆ??æ–?—å?ã�®é•·ã�?
052 * @param sizeY 少数部åˆ??æ–?—å?ã�®é•·ã�?
053 * @param encode 固定長ã�§å¤‰æ�›ã�™ã‚‹æ–?—エンコーãƒ?
054 *
055 * @return ?¦?©?¬?¬åŸ‹ã‚�ã�—ã�Ÿæ–°ã�—ã�„æ–?—å?
056 */
057 @Override
058 public String valueFill( final String value ,final int sizeX ,final int sizeY,final String encode ) {
059 int len = (sizeY == 0) ? sizeX : sizeX + sizeY + 1;
060
061 return StringUtil.stringKFill( value,len,encode );
062 }
063
064 /**
065 * ãƒ??ã‚¿ã�Œç™»éŒ²å�¯èƒ½ã�‹ã�©ã�?�‹ã‚’ãƒ�ã‚§ãƒ?‚¯ã�—ã�¾ã�™ã?
066 * ãƒ??ã‚¿ã�Œã‚¨ãƒ©ãƒ¼ã�®å ´å�ˆã?ã€�ã��ã�®ã‚¨ãƒ©ãƒ¼å†?®¹ã‚’è¿”ã�—ã�¾ã�™ã?
067 *
068 * @og.rev 5.2.2.0 (2010/11/01) 厳å¯?�«ãƒ�ã‚§ãƒ?‚¯(isStrict=true)ã�™ã‚‹ãƒ•ラグを追åŠ?
069 *
070 * @param key ã‚ー
071 * @param value 値
072 * @param sizeX 整数部åˆ??æ–?—å?ã�®é•·ã�?
073 * @param sizeY 少数部åˆ??æ–?—å?ã�®é•·ã�?
074 * @param typeParam dbType パラメータ
075 * @param isStrict 厳å¯?�«ãƒ�ã‚§ãƒ?‚¯ã�™ã‚‹ã�‹ã�©ã�?�‹[true:ã�™ã‚‹/false:標準的]
076 *
077 * @return エラーå†?®¹
078 */
079 // public ErrorMessage valueCheck( final String key ,final String value ,
080 // final int sizeX ,final int sizeY ,final String param ) {
081 @Override
082 public ErrorMessage valueCheck( final String key ,final String value ,
083 final int sizeX ,final int sizeY ,final String typeParam ,final boolean isStrict) {
084
085 ErrorMessage msg = new ErrorMessage();
086 if( value == null || value.length() == 0 ) { return msg; }
087
088 int len = (sizeY == 0) ? sizeX : sizeX + sizeY + 1;
089 String check = DBTypeCheckUtil.byteLengthCheck( value,len );
090 if( check != null ) {
091 // æ–?—å?ã�®é•·ã�•ã�ŒæŒ?®šã?é•·ã�•よりも長ã�?�§ã�™ã?
092 msg.addMessage( 0,ErrorMessage.NG,"ERR0006",key,value,check,String.valueOf( len ) );
093 }
094
095 char[] chs = value.toCharArray() ;
096 for( int i=0; i<chs.length; i++ ) {
097 if( chs[i] < 0x7f || ( 0xff65 <= chs[i] && chs[i] < 0xffa0 ) ) {
098 if( chs[i] != 0x0a && chs[i] != 0x0d ) {
099 // å…¨ã�¦ã�Œå?è§’æ–‡å—ã�§ã�¯ã�‚りã�¾ã�›ã‚“ã€?
100 msg.addMessage( 0,ErrorMessage.NG,"ERR0007",key,value );
101 break;
102 }
103 }
104 }
105
106 // 3.6.0.0 (2004/09/22) dbType パラメータを使用ã�—ã�Ÿãƒžãƒƒãƒ�ãƒ�ã‚§ãƒ?‚¯
107 check = DBTypeCheckUtil.matcheCheck( value,typeParam );
108 if( check != null ) {
109 // æŒ?®šã?æ–?—以外ã?æ–?—ã�Œä½¿ã‚�れã�¦ã�?�¾ã�™ã?
110 msg.addMessage( 0,ErrorMessage.NG,"ERR0009", key,check );
111 }
112
113 return msg;
114 }
115 }