Thread Rating:
  • 488 Vote(s) - 2.85 Average
  • 1
  • 2
  • 3
  • 4
  • 5
int型→string型のキャストについて
09-09-2013, 04:44 PM,
#8
RE: int型→string型のキャストについて
to-*** メソッド、 from-*** コンストラクタ が利用できるなら、下記のようなコードも使えるかも。

Code:
{define-proc public {data-to-data-with-type-change
                          to-val:any,
                          from-val:any
                      }:any
    {if-non-null
        to-val, from-val then

        def to-type = {type-of to-val} asa ClassType
        def to-type-name = to-type.name
        def from-type = {type-of from-val} asa ClassType
        def from-type-name = from-type.name


        {if-non-null mtd = {from-type.get-method "to-" & to-type-name} then
            {return {mtd.invoke from-val}}
        }

        {if-non-null cns = {to-type.get-constructor "from-" & from-type-name} then
            {return {cns.new}}
        }
    }
    {return null}
  }

グリッドに入力されたセルの内容を形式チェックする機能を用意していて、
チェックエラー時には、エラーの内容を表示したいので、domain はString にせざるを得ないのですが、
ORB で、送受信するためのDTOの型はBigDecimal なので、
値を詰め替えるときに自動で型を変換できるようにしています。




Messages In This Thread
RE: int型→string型のキャストについて - by umemura - 09-09-2013, 04:44 PM
Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('203')