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.hayabusa.db.AbstractDBType;
020 import org.opengion.hayabusa.db.DBTypeCheckUtil;
021
022 /**
023 * å�Šè§’英数大æ–?—ã?ã�¿ã�®æ–?—å?を扱ã�?‚ºã�®ã€�カラãƒ?±žæ?を定義ã�—ã�¾ã�™ã?
024 *
025 * 使用å�¯èƒ½æ–?—ã?ã€?-9,A-Z ã�§ã�™ã?(,ã�¯å�«ã�¿ã�¾ã�›ã‚“)
026 * å°�数点ã€�カンマã?å�Šè§’スペã?ス ã�ªã�©ã‚’å�«ã�¿ã�¾ã�›ã‚“ã€?
027 *
028 * タイプãƒ�ã‚§ãƒ?‚¯ã�¨ã�—ã�¦ã€�以下ã?æ�¡ä»¶ã‚’判定ã�—ã�¾ã�™ã?
029 * ・æ–?—å?é•·ã�¯ã€�直接計算ã�§æ–?—æ•°ã�¨ã�®æ¯”è¼?
030 * ・å�Šè§’æ–‡å—ãƒ�ã‚§ãƒ?‚¯ã€?-9,A-Zã€�ã?ç¯?›²
031 * ・æ–?—パラメータã�® æ£è¦�表ç�¾ãƒ�ã‚§ãƒ?‚¯
032 *
033 * @og.rev 3.8.0.2 (2005/07/11) æ–°è¦�作æ?
034 * @og.group ãƒ??タ属æ?
035 *
036 * @version 4.0
037 * @author Kazuhiko Hasegawa
038 * @since JDK5.0,
039 */
040 public class DBType_XU9 extends AbstractDBType {
041 //* ã�“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã�—ã�¾ã�™ã? {@value} */
042 private static final String VERSION = "5.2.2.0 (2010/11/01)" ;
043
044 /**
045 * ãƒ??ã‚¿ã�Œç™»éŒ²å�¯èƒ½ã�‹ã�©ã�?�‹ã‚’ãƒ�ã‚§ãƒ?‚¯ã�—ã�¾ã�™ã?
046 * ãƒ??ã‚¿ã�Œã‚¨ãƒ©ãƒ¼ã�®å ´å�ˆã?ã€�ã��ã�®ã‚¨ãƒ©ãƒ¼å†?®¹ã‚’è¿”ã�—ã�¾ã�™ã?
047 *
048 * @og.rev 5.2.2.0 (2010/11/01) 厳å¯?�«ãƒ�ã‚§ãƒ?‚¯(isStrict=true)ã�™ã‚‹ãƒ•ラグを追åŠ?
049 *
050 * @param key ã‚ー
051 * @param value 値
052 * @param sizeX 整数部åˆ??æ–?—å?ã�®é•·ã�?
053 * @param sizeY 少数部åˆ??æ–?—å?ã�®é•·ã�?
054 * @param typeParam dbType パラメータ
055 * @param isStrict 厳å¯?�«ãƒ�ã‚§ãƒ?‚¯ã�™ã‚‹ã�‹ã�©ã�?�‹[true:ã�™ã‚‹/false:標準的]
056 *
057 * @return エラーå†?®¹
058 */
059 // public ErrorMessage valueCheck( final String key ,final String value ,
060 // final int sizeX ,final int sizeY ,final String param ) {
061 @Override
062 public ErrorMessage valueCheck( final String key ,final String value ,
063 final int sizeX ,final int sizeY ,final String typeParam ,final boolean isStrict) {
064
065 ErrorMessage msg = new ErrorMessage();
066 if( value == null || value.length() == 0 ) { return msg; }
067
068 int len = (sizeY == 0) ? sizeX : sizeX + sizeY + 1;
069 if( value.length() > len ) {
070 // æ–?—å?ã�®é•·ã�•ã�ŒæŒ?®šã?é•·ã�•よりも長ã�?�§ã�™ã?
071 msg.addMessage( 0,ErrorMessage.NG,"ERR0006", key,value, String.valueOf( value.length() ), String.valueOf( len ) );
072 }
073
074 StringBuilder val = new StringBuilder();
075 boolean isError = false;
076 for( int i=0; i<value.length(); i++ ) {
077 char ch = value.charAt( i );
078 boolean okFlag = ( (ch >= '0' && ch <= '9' ) || (ch >= 'A' && ch <= 'Z' ) );
079
080 if( okFlag ) {
081 val.append( ch );
082 }
083 else {
084 val.append( "<span class=\"NG\">" ).append( ch ).append( "</span>" );
085 isError = true;
086 }
087 }
088 if( isError ) {
089 // æŒ?®šã?æ–?—以外ã?æ–?—ã�Œä½¿ã‚�れã�¦ã�?�¾ã�™ã?
090 msg.addMessage( 0,ErrorMessage.NG,"ERR0009", key,val.toString() );
091 }
092
093 // 3.6.0.0 (2004/09/22) dbType パラメータを使用ã�—ã�Ÿãƒžãƒƒãƒ�ãƒ�ã‚§ãƒ?‚¯
094 String check = DBTypeCheckUtil.matcheCheck( value,typeParam );
095 if( check != null ) {
096 // æŒ?®šã?æ–?—以外ã?æ–?—ã�Œä½¿ã‚�れã�¦ã�?�¾ã�™ã?
097 msg.addMessage( 0,ErrorMessage.NG,"ERR0009", key,check );
098 }
099
100 return msg;
101 }
102 }