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