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 */ 016package org.opengion.hayabusa.resource; 017 018import static org.opengion.fukurou.util.StringUtil.nval2; 019 020/** 021 * systemId に対応したカラムデータを作成します。 022 * 023 * カラムデータは、項目(CLM)に対して、各種カラム情報を持っています。 024 * エンジン内部で使用している DBColumn オブジェクトは、RENDERER や EDITOR など 025 * 実際にはオブジェクトで管理していますが、この ColumnData では、それらのキーとなる 026 * 文字列を持っています。実際に DBColumn オブジェクトの構築時に、各属性オブジェクトを 027 * 生成(または、キャッシュから取り出し)ます。 028 * 029 * カラムデータを作成する場合は、同一カラムで、作成区分(KBSAKU)違いの場合は、 030 * 最も大きな作成区分を持つコードを使用します。 031 * 作成区分(KBSAKU)は、0:システム予約、1:アプリ設定、2:ユーザー設定 という具合に 032 * カスタマイズの度合いに応じて大きな数字を割り当てることで、キー情報を上書き修正 033 * することが可能になります。(削除することは出来ません。) 034 * 035 * @og.rev 4.0.0.0 (2004/12/31) 新規作成 036 * @og.group リソース管理 037 * 038 * @version 4.0 039 * @author Kazuhiko Hasegawa 040 * @since JDK5.0, 041 */ 042public final class ColumnData { 043 044 /** 内部データのカラム番号 {@value} */ 045 public static final int CLM = 0 ; 046 /** 内部データのカラム番号 {@value} */ 047 public static final int CLS_NAME = 1 ; 048 /** 内部データのカラム番号 {@value} */ 049 public static final int USE_LENGTH = 2 ; 050 /** 内部データのカラム番号 {@value} */ 051 public static final int VIEW_LENGTH = 3 ; 052 /** 内部データのカラム番号 {@value} */ 053 public static final int RENDERER = 4 ; 054 /** 内部データのカラム番号 {@value} */ 055 public static final int EDITOR = 5 ; 056 /** 内部データのカラム番号 {@value} */ 057 public static final int DBTYPE = 6 ; 058 /** 内部データのカラム番号 {@value} */ 059 public static final int DATA_DEFAULT = 7 ; 060 /** 内部データのカラム番号 {@value} */ 061 public static final int LABEL_CLM = 8 ; 062 /** 内部データのカラム番号 {@value} */ 063 public static final int CODE_CLM = 9 ; 064 /** 内部データのカラム番号 {@value} */ 065 public static final int CLM_PARAM = 10 ; 066 /** 内部データのカラム番号 {@value} */ 067 public static final int RENDERER_PARAM = 11 ; 068 /** 内部データのカラム番号 {@value} */ 069 public static final int EDITOR_PARAM = 12 ; 070 /** 内部データのカラム番号 {@value} */ 071 public static final int TYPE_PARAM = 13 ; 072 /** 内部データのカラム番号 {@value} */ 073 public static final int ROLES = 14 ; 074 /** 内部データのカラム番号 {@value} */ 075 public static final int FIELD_SIZE = 15 ; // 6.2.0.0 (2015/02/27) フィールドサイズ 追加 076 077 /** 内部データのカラム数 {@value} */ 078 public static final int DATA_SIZE = 16 ; // 6.2.0.0 (2015/02/27) 件数を増やす 079 080 /** リソース読み込みのために一時利用 4.3.5.7 (2009/03/22) */ 081 /* default */ static final int FG_LOAD = 16 ; // 6.2.0.0 (2015/02/27) 位置をずらす 082 /** FGLOAD の読み込み済み設定用のUNIQ 6.3.1.1 (2015/07/10) */ 083 /* default */ static final int UNIQ = 17 ; 084 /** FGLOAD の読み込み済み設定用のSYSTEM_ID 6.3.1.1 (2015/07/10) */ 085 /* default */ static final int SYSTEM_ID = 18 ; 086 087 /** 内部データのカラム番号 {@value} */ 088 public static final int KBSAKU = 19 ; // 7.4.2.0 (2021/05/18) 内部的に使ってないが定義しておく 089 public static final int SNO = 20 ; // 7.2.6.1 (2020/07/17) 内部的に使ってないが定義しておく 090 091 private final String name ; // カラム名 092 private final String className ; // データの属性(VARCHAR2,NUMBER...) 093 private final String maxlength ; // 最大桁数 094 private final String viewLength ; // 表示桁数 095 private final String fieldSize ; // 6.2.0.0 (2015/02/27) 入力枠サイズ 096 private final String renderer ; // 表示種別 097 private final String editor ; // 編集種別 098 private final String dbType ; // 文字種別(S9,X...) 099 private final String dataDef ; // データのデフォルト値 100 private final String labelClm ; // ラベルカラム 101 private final String codeClm ; // コードカラム 102 private final String columnPrm ; // カラムパラメータ 103 private final String rendererPrm ; // 表示パラメータ 104 private final String editorPrm ; // 編集パラメータ 105 private final String dbTypePrm ; // 文字パラメータ 106 private final String roles ; // カラムロール 107 private final RoleMode roleMode ; // 4.3.0.0 (2008/07/04) ロールズとモードを管理するオブジェクト 108 109 private final int totalSize ; // 総桁数(小数点も含む) 110 private final int sizeX ; // カラムの文字桁数(整数部) 111 private final int sizeY ; // カラムの文字桁数(小数部) 112 private final boolean official ; // リソースDBから作成されたかどうか 113 114 /** 115 * 配列文字列のデータを元に、ColumnDataオブジェクトを構築します。 116 * このコンストラクタは、他のパッケージから呼び出せないように、 117 * パッケージプライベートにしておきます。 118 * このコンストラクタは、DBリソースファイルを想定しています。 119 * 120 * @og.rev 4.3.0.0 (2008/07/04) ロールモードマルチ対応 121 * @og.rev 5.1.6.0 (2010/05/01) DBTypeの初期値を "XK" とします。 122 * @og.rev 5.2.2.0 (2010/11/01) パラメーターもVer3互換のためNVAL2で処理します。 123 * @og.rev 5.5.8.5 (2012/11/27) 編集パラメータで、"=" と記述されている場合は、表示パラメータを利用する。 124 * @og.rev 6.1.0.0 (2014/12/26) カラムの表示桁数(小数部)対応 125 * @og.rev 6.2.0.0 (2015/02/27) フィールドサイズ 追加(VIEW_LENGTHと分離して、役割を明確にする) 126 * 127 * @param data CLM,CLS_NAME,USE_LENGTH,VIEW_LENGTH, 128 * RENDERER,EDITOR,DBTYPE,DATA_DEFAULT,LABEL_CLM,CODE_CLM, 129 * CLM_PARAM,RENDERER_PARAM,EDITOR_PARAM,TYPE_PARAM,ROLES,FIELD_SIZE 130 * 131 */ 132 public ColumnData( final String[] data ) { 133 name = data[CLM].intern() ; // カラム名 134 className = data[CLS_NAME].intern() ; // データの属性 135 maxlength = data[USE_LENGTH].replace( '.',',' ).intern(); // 最大桁数 136 renderer = nval2( data[RENDERER] , null ) ; // 表示種別 137 editor = nval2( data[EDITOR] , null ) ; // 編集種別 138 dbType = nval2( data[DBTYPE] , "XK" ) ; // 文字種別 5.1.6.0 (2010/05/01) 139 dataDef = nval2( data[DATA_DEFAULT] , "" ) ; // データのデフォルト値 140 labelClm = nval2( data[LABEL_CLM] , name ) ; // ラベルカラム 141 codeClm = nval2( data[CODE_CLM] , name ) ; // コードカラム 142 columnPrm = nval2( data[CLM_PARAM] , null ) ; // カラムパラメータ 143 rendererPrm = nval2( data[RENDERER_PARAM], null ) ; // 表示パラメータ 144 dbTypePrm = nval2( data[TYPE_PARAM] , null ) ; // 文字パラメータ 145 roles = nval2( data[ROLES] , null ) ; // カラムロール 146 fieldSize = nval2( data[FIELD_SIZE] , null ) ; // 6.2.0.0 (2015/02/27) 入力枠サイズ 147 official = true; // リソースDBから作成されたかどうか 148 149 // 6.1.0.0 (2014/12/26) カラムの表示桁数(小数部)対応と、カンマ置換処理 150 final String viewLen = nval2( data[VIEW_LENGTH] , null ) ; 151 viewLength = viewLen == null ? null : viewLen.replace( '.',',' ).intern(); 152 153 // // 7.2.7.0 (2020/08/07) fieldSize には、viewLength を設定する(昔に戻る)。 154 // if( viewLength != null && viewLength.indexOf( ',' ) > 0 ) { // カンマを含む場合は、10桁固定にします。 155 // fieldSize = "10" ; 156 // } 157 // else { 158 // fieldSize = viewLength; 159 // } 160 161 // 5.5.8.5 (2012/11/27) 編集パラメータで、"=" と記述されている場合は、表示パラメータを利用する。 162 final String tempEditPrm = nval2( data[EDITOR_PARAM], null ) ; 163 if( "=".equals( tempEditPrm ) ) { 164 editorPrm = rendererPrm ; 165 } 166 else { 167 editorPrm = tempEditPrm ; 168 } 169 170 roleMode = RoleMode.newInstance( roles ); // ロールモード 171 172 // x,y 形式の場合、x + 2 桁で表されます。(マイナス記号と小数点記号) 173 // 7,3 は、 xxxx,yyy のフォーマットで、データ長は、9 になります。 174 final int ch = maxlength.indexOf( ',' ) ; 175 if( ch > 0 ) { 176 sizeY = Integer.parseInt( maxlength.substring( ch+1 ) ); 177 sizeX = Integer.parseInt( maxlength.substring( 0,ch ) ) - sizeY; 178 totalSize = sizeX + sizeY+ 2; 179 } 180 else { 181 sizeY = 0; 182 sizeX = Integer.parseInt( maxlength ); 183 if( "S9".equals( dbType ) ) { 184 totalSize = sizeX + 1; // 数字型の場合は、マイナス記号分を加える。 185 } 186 else { 187 totalSize = sizeX ; 188 } 189 } 190 } 191 192 /** 193 * カラム名を返します。 194 * 195 * @return カラム名 196 */ 197 public String getName() { return name; } 198 199 /** 200 * カラムのデータの属性を返します。 201 * 202 * @return カラムのデータの属性 203 */ 204 public String getClassName() { return className; } 205 206 /** 207 * フィールドの使用桁数を返します。 208 * 小数指定の場合は、"7,3" のようなカンマで整数部、小数部を区切った書式になります。 209 * 7,3 は、 xxxx,yyy のフォーマットで、整数部4桁、小数部3桁を意味します。 210 * 211 * @return 使用桁数 212 */ 213 public String getMaxlength() { return maxlength; } 214 215 /** 216 * フィールドのデータ長を返します。 217 * 通常は、整数型の文字列とデータ長は同じですが,小数点を表すデータ長は 218 * x.y 形式の場合、x + 1 桁で表されます。 219 * 6.2 は、 xxxx.yy のフォーマットです。 220 * 221 * @return データ長定義文字列 222 */ 223 public int getTotalSize() { return totalSize; } 224 225 /** 226 * フィールドの整数部のデータ長を返します。 227 * 228 * @return データ長定義文字列 229 */ 230 public int getSizeX() { return sizeX ; } 231 232 /** 233 * フィールドの小数部のデータ長を返します。 234 * 235 * @return データ長定義文字列 236 */ 237 public int getSizeY() { return sizeY ; } 238 239 /** 240 * 文字列の表示文字数を返します。 241 * 242 * これは、テキストフィールドのサイズではなく、Renderer系の表示に使用する 243 * 文字数指定に使われます。 244 * 無指定の場合は、null が返されます。 245 * 246 * @return 表示文字数 247 */ 248 public String getViewLength() { return viewLength; } 249 250 /** 251 * フィールドの入力枠サイズを返します。 252 * 253 * テキストフィールドのサイズに該当します。 254 * 何も指定しない場合は、null が返ります。 255 * その場合の、入力枠サイズは、maxlength が使用されます。 256 * ただし、桁数が大きい場合は、システム定数の HTML_COLUMNS_MAXSIZE や、 257 * HTML_VIEW_COLUMNS_MAXSIZE で指定された値が使われます。 258 * それらの値よりも、ここで取得 した fieldSize が優先されます。 259 * 260 * @og.rev 6.2.0.0 (2015/02/27) フィールドサイズ 追加(VIEW_LENGTHと分離して、役割を明確にする) 261 * 262 * @return 入力枠サイズ 263 */ 264 public String getFieldSize() { return fieldSize; } 265 266 /** 267 * 表示種別を返します。 268 * 269 * @return 表示種別の文字列 270 */ 271 public String getRenderer() { return renderer; } 272 273 /** 274 * 編集種別を返します。 275 * 276 * @return 編集種別 277 */ 278 public String getEditor() { return editor; } 279 280 /** 281 * 文字種別を返します。 282 * 283 * @return 文字種別 284 */ 285 public String getDbType() { return dbType; } 286 287 /** 288 * ラベルカラムを返します。 289 * 290 * @return ラベルカラム 291 */ 292 public String getLabelColumn() { return labelClm; } 293 294 /** 295 * コードカラムを返します。 296 * 297 * @return コードカラム 298 */ 299 public String getCodeColumn() { return codeClm; } 300 301 /** 302 * データのデフォルト値を返します。 303 * 304 * @return データのデフォルト値 305 */ 306 public String getDefault() { return dataDef; } 307 308 /** 309 * カラムのパラメータを取得します。 310 * 311 * @return カラムパラメータ 312 */ 313 public String getColumnParam() { return columnPrm; } 314 315 /** 316 * 表示用レンデラーのパラメータを取得します。 317 * 318 * @return 表示パラメータ 319 */ 320 public String getRendererParam() { return rendererPrm; } 321 322 /** 323 * 編集用エディターのパラメータを取得します。 324 * 325 * @return 編集パラメータ 326 */ 327 public String getEditorParam() { return editorPrm; } 328 329 /** 330 * データタイプのパラメータを取得します。 331 * 332 * @return データタイプのパラメータ 333 */ 334 public String getDbTypeParam() { return dbTypePrm; } 335 336 /** 337 * カラムロールを取得します。 338 * 339 * @return カラムロール 340 */ 341 public String getRoles() { return roles; } 342 343 /** 344 * カラムオブジェクトのロールモードを返します。 345 * 346 * @og.rev 4.3.0.0 (2008/07/04) ロールモードマルチ対応 347 * 348 * @return カラムオブジェクトのロールモード 349 */ 350 public RoleMode getRoleMode() { return roleMode; } 351 352 /** 353 * リソースDBから作成されたかどうかを返します。 354 * 正式な場合は、true / リソースになく、独自に作成された場合は、false になります。 355 * 356 * @return リソースDBから作成されたかどうか 357 * 358 */ 359 public boolean isOfficial() { return official; } 360 361 /** 362 * 内部データの文字列配列を返します。 363 * 364 * @og.rev 6.2.0.0 (2015/02/27) フィールドサイズ 追加(VIEW_LENGTHと分離して、役割を明確にする) 365 * 366 * @return 内部データの文字列配列 367 */ 368 public String[] getColumnData() { 369 String[] data = new String[DATA_SIZE]; 370 371 data[CLM ] = name ; 372 data[CLS_NAME ] = className ; 373 data[USE_LENGTH ] = maxlength ; 374 data[VIEW_LENGTH ] = viewLength ; 375 data[RENDERER ] = renderer ; 376 data[EDITOR ] = editor ; 377 data[DBTYPE ] = dbType ; 378 data[DATA_DEFAULT ] = dataDef ; 379 data[LABEL_CLM ] = labelClm ; 380 data[CODE_CLM ] = codeClm ; 381 data[CLM_PARAM ] = columnPrm ; 382 data[RENDERER_PARAM ] = rendererPrm ; 383 data[EDITOR_PARAM ] = editorPrm ; 384 data[TYPE_PARAM ] = dbTypePrm ; 385 data[ROLES ] = roles ; 386 data[FIELD_SIZE ] = fieldSize ; // 6.2.0.0 (2015/02/27) 387 388 return data ; 389 } 390}