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.fukurou.model;
017
018/**
019 * [PN],[OYA] などの [] で指定されたカラムで表されたフォーマットデータに対して、
020 * DBTableModelオブジェクトを適用して 各カラムに実データを割り当てるオブジェクトです。
021 *
022 * @og.group 画面表示
023 *
024 * @version  4.0
025 * @author   Kazuhiko Hasegawa
026 * @since    JDK5.0,
027 */
028public interface DataModel<T> {
029
030        /**
031         * row にあるセルのオブジェクト値を置き換えます。
032         *
033         * @param   vals  新しい配列値。
034         * @param   row   値が変更される行(無視されます)
035         */
036        void setValues( final T[] vals,final int row ) ;
037
038        /**
039         * カラム名に対応する カラム番号を返します。
040         *
041         * 特殊なカラムが指定された場合は、負の値を返します。
042         * 例えば、[KEY.カラム名]、[I]、[ROW.ID] など、特定の負の値を返します。
043         * また、カラム名が元のデータモデルに存在しない場合も、負の値か、
044         * Exception を返します。負の値なのか、Exception なのかは、
045         * 実装に依存します。
046         *
047         * @param   columnName  値が参照されるカラム番号
048         *
049         * @return  指定されたセルのカラム番号
050         */
051        int getColumnNo( final String columnName ) ;
052
053        /**
054         * カラム名配列を返します。
055         * 配列オブジェクトは、clone されたコピーを返します。
056         *
057         * @return      カラム名配列
058         */
059        String[] getNames();
060
061        /**
062         * row にあるセルの属性値を配列で返します。
063         *
064         * @param   row     値が参照される行
065         *
066         * @return  指定されたセルの属性値
067         */
068        T[] getValues( int row ) ;
069
070        /**
071         * row および clm にあるセルの属性値を返します。
072         *
073         * @param   row     値が参照される行
074         * @param   clm     値が参照される列
075         *
076         * @return  指定されたセルの値 T
077         */
078        T getValue(int row, int clm) ;
079
080        /**
081         * clm のNativeタイプを返します。
082         * Nativeタイプはorg.opengion.fukurou.model.NativeTypeで定義されています。
083         *
084         * @og.rev 4.1.1.2 (2008/02/28) 新規追加
085         *
086         * @param  clm      値が参照される列
087         *
088         * @return Nativeタイプ
089         * @see org.opengion.fukurou.model.NativeType
090         */
091        NativeType getNativeType( int clm );
092}