JP2004252708A - Object value setting method and program - Google Patents

Object value setting method and program Download PDF

Info

Publication number
JP2004252708A
JP2004252708A JP2003042290A JP2003042290A JP2004252708A JP 2004252708 A JP2004252708 A JP 2004252708A JP 2003042290 A JP2003042290 A JP 2003042290A JP 2003042290 A JP2003042290 A JP 2003042290A JP 2004252708 A JP2004252708 A JP 2004252708A
Authority
JP
Japan
Prior art keywords
value
field
setting
attribute
attribute value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2003042290A
Other languages
Japanese (ja)
Inventor
Kei Ishii
圭 石井
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Software Engineering Co Ltd
Original Assignee
Hitachi Software Engineering Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Software Engineering Co Ltd filed Critical Hitachi Software Engineering Co Ltd
Priority to JP2003042290A priority Critical patent/JP2004252708A/en
Publication of JP2004252708A publication Critical patent/JP2004252708A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide an object value setting method and program capable of integrally setting values to objects without depending on classes for which values are to be set and the numbers and types of their fields, for application development based on the techniques of Java (R). <P>SOLUTION: The method includes a first step for creating attribute values to be set for each field of an object for which an attribute value is to be set and for storing the attribute values in a storage means, and a second step for implementing a public accessor method set for each object, using a reflection function provided by JavaAPI, and for setting the attribute value of the object stored in the storage means. <P>COPYRIGHT: (C)2004,JPO&NCIPI

Description

【0001】
【発明の属する技術分野】
本発明は、オブジェクト指向のプログラム言語であるJava(Java及びJava関連の商標及びロゴは、米国SUN Microsystems,inc.の商標または登録商標)の技術を使用してアプリケーションプログラムを開発する方法及び開発用のプログラムに係り、特に、Web画面の入力データやDBレコード等の情報(属性値)をオブジェクトへ設定する際の処理方法及び処理プログラムに関するものである。
【0002】
【従来の技術】
従来、Javaの技術によるアプリケーションプログラムの開発作業では、当該アプリケーションプログラムの構成要素である各オブジェクト(具体的にはオブジェクトのインスタンスであるクラス)への値の設定を行うために、値設定対象クオブジェクトの各フィールド(属性)にそれぞれ対応して同オブジェクト内に組み込んだsetメソッドを使用してフィールド値(属性値)を設定する方法が採られている。例えば、name、ageというフィールドを持つクラスに対してはsetName()、setAge()というメソッドを同クラス内に組み込み、これらのメソッドを使用することにより名前、年令といった値の設定を行うようにしている。
また、JSP(Java Server Pages)によるWebアプリケーションシステム開発では、拡張構文<jsp:setProperty>を用いることにより、HTMLフォームのパラメータ名と値設定対象オブジェクトのフィールド名が一致したフィールドへ値を一括して設定することが可能である。具体的には、HTMLのフォーム部品の名前に値設定対象オブジェクトのフィールド名を設定し、<jsp:useBean>タグによる値設定対象オブジェクトの指定を行った後、<jsp:setProperty>タグのproperty属性に”*”を設定することでオブジェクトへの値設定を行うようにしている。
ここで、オブジェクトの属性値を設定する方法として次の特許文献1に開示されたものがある。
【0003】
【特許文献1】
特開2001−282537号公報
また、JSP(Java Server Pages)の拡張構文については、次の非特許文献1で紹介されている。
【0004】
【非特許文献1】
JavaSeverPagesTMv1.2Syntax Reference・June 2002
【0005】
【発明が解決しようとする課題】
しかしながら、各オブジェクトに対し上記setメソッドを用いて属性値を設定する場合、属性値を設定する各フィールドに対しsetメソッドを個々に実行させる手続が必要になるため、クラス数あるいはフィールド数(属性項目数)の多いアプリケーションプログラムを開発する場合には、setメソッドを個々に実行させるためのコーディング量が多くなり、開発およびテスト作業において開発者に対する負担が大きいという問題があった。
また、JSP拡張構文<jsp:setProperty>を使用し、各オブジェクトの属性値を設定する場合、Java基本型以外のフィールドに対する属性値が設定できないという問題がある。Java基本型のフィールドとは、上記の非特許文献1の「TABLE1」に示されているものである。
また、配列フィールドに対する属性値を自動で設定することができないという問題があった。例えば「趣味」という属性があった場合に、「映画鑑賞」、「釣り」などの複数の属性値を自動で設定することができず、手動で設定しなければならないという問題があった。
さらに、設定した属性値に矛盾がないかなどのチェック機能について考慮していないため、設定した属性値の矛盾等を発見できないという問題があった。
さらに、属性値の型を例えば文字型から数値型に変換する機能について考慮していないため、フィールドの型に合わせて型変換を行う事ができないという問題があった。
要約すれば、従来の技術にあっては、オブジェクトへの属性値を設定するためのコーディング量が多くなり、また型変換や属性値のチェックを行う必要が生じた場合に柔軟に対応できないといった問題があった。
【0006】
本発明の目的は、オブジェクトに対する属性値を少ないコーディング量で設定することができるオブジェクト値設定方法及びプログラムを提供することにある。
また、上記目的に加え、Java基本型以外のフィールドに対する属性値、配列フィールドに対する属性値についても自動で設定することができるオブジェクト値設定方法及びプログラムを提供することにある。
さらに、型変換や属性値の矛盾チェックも行うことができるオブジェクト値設定方法及びプログラムを提供することにある。
【0007】
【課題を解決するための手段】
上記目的を達成するために、本発明に係るオブジェクト値設定方法は、属性値設定対象オブジェクトの各フィールドに設定する属性値を作成して記憶手段に格納する第1のステップと、JavaAPIで提供されるリフレクション機能を用いて各オブジェクトに設定されたパブリックなアクセサメソッドを実行し、前記記憶手段に格納された当該オブジェクトの属性値を設定する第2のステップとを備えることを特徴とする。
また、前記第2のステップにおいて、型変換を行う変換メソッドが設定された属性フィールドに対し当該変換メソッドを実行し、前記記憶手段に記憶された属性値の型を変換して当該属性フィールドに設定するステップをさらに備えることを特徴とする。
また、前記第2のステップにおいて、属性値のチェックを行うチェックメソッドが設定された属性フィールドに対し当該チェックを実行し、当該チェックメソッドで指定されている属性値のチェックを行うステップをさらに備えることを特徴とする。
さらに、前記第2のステップにおいて、配列識別子が設定された属性値に対し、前記記憶手段に記憶された同一配列の属性値を取得し、各配列の属性値として設定するステップをさらに備えることを特徴とする。
【0008】
本発明に係るJavaアプリケーションプログラムにおけるオブジェクト値を設定するプログラムは、属性値設定対象オブジェクトの各フィールドに設定する属性値を作成して記憶手段に格納する第1の処理ステップと、JavaAPIで提供されるリフレクション機能を用いて各オブジェクトに設定されたパブリックなアクセサメソッドを実行し、前記記憶手段に格納された当該オブジェクトの属性値を設定する第2の処理ステップとを備えることを特徴とする。
また、前記第2の処理ステップにおいて、型変換を行う変換メソッドが設定された属性フィールドに対し当該変換メソッドを実行し、前記記憶手段に記憶された属性値の型を変換して当該属性フィールドに設定する処理ステップをさらに備えることを特徴とする。
また、前記第2の処理ステップにおいて、属性値のチェックを行うチェックメソッドが設定された属性フィールドに対し当該チェックを実行し、当該チェックメソッドで指定されている属性値のチェックを行う処理ステップをさらに備えることを特徴とする。
また、前記第2の処理ステップにおいて、配列識別子が設定された属性値に対し、前記記憶手段に記憶された同一配列の属性値を取得し、各配列の属性値として設定する処理ステップをさらに備えることを特徴とする。
【0009】
【発明の実施の形態】
以下、本発明を実施する場合の一形態を図面を参照して具体的に説明する。
図1は、本発明の実施の一形態を示す図である。本実施形態におけるシステムは、図1に示すように、設定情報データ101と値設定対象オブジェクト102を入力として受け取り、値設定対象オブジェクト102への属性値(フィールド値)の設定を行うオブジェクト値設定プログラム103と、値設定対象オブジェクト102のインスタンスである値設定対象クラス104からなっている。
設定情報データ101、値設定対象オブジェクト102、オブジェクト値設定プログラム103、値設定対象クラス104は、コンピュータの記憶装置(図示せず)に格納されている。
【0010】
値設定対象クラス104はgetメソッド105、setメソッド106、変換メソッド107、チェックメソッド108を有している。
オブジェクト値設定プログラム103は、Java言語によるプログラムが実行可能なコンピュータによって実行されるものであり、詳細設定情報作成処理109、フィールド値設定処理110、フィールド値チェック処理111、詳細設定情報112、リフレクション機能113を有している。
【0011】
詳細設定情報作成処理109は、後述の図4に示すような設定情報データ101を基に、後述の図6に示すような詳細設定情報112を作成するものであり、オブジェクト値設定プログラム103の前処理として使用する。
フィールド値設定処理110、フィールド値チェック処理111は、オブジェクト値設定プログラム103のサブルーチンとして機能する。
リフレクション機能113はJavaAPIにより提供されるもので、値設定対象クラス104の各メソッドを実行するために使用する。リフレクション機能113とは、Javaのオブジェクトやクラスが公開するフィールドにアクセスし、そのJavaオブジェクトの属性を変更したり、メソッドを呼び出して実行する機能である。
【0012】
図2は、Web画面の入力内容201を値設定対象オブジェクト102に格納する例を示したものである。
オブジェクト値設定プログラム103は、設定情報データ101から値設定対象オブジェクト102に設定可能な設定値および設定フィールドを検索し設定する。この際、prefCodeフィールド202のように設定値の型またはデータ変換が必要な場合には、値設定対象クラスの変換メソッドを使用して設定値を変換する。入力内容に誤りがある場合にはチェック例外203を検出する。
【0013】
図2の例における値設定対象オブジェクトはオブジェクト名がUserInfoのUserObjであり、その属性値としては氏名(漢字)=name、氏名(カナ)=name_kana、メールアドレス=email、性別=sex、生年月日=birthdate、自宅情報=address、趣味=hobbyが設定対象となっている。
本発明は、このUserObjオブジェクトのインスタンスである値設定対象クラスに対して属性値を設定するものである。なお、生年月日と自宅情報については独立したクラスbirthdateObjとaddressObjが作成され、これらのクラスに属性値が設定されるようになっている。なお、独立したクラスを作成するのは属性の内容を識別し易くするために便宜的に分けただけのものであり、特別な意味はない。
図2の例では、UserObjクラス(204)とbirthdateObjクラス(205)およびaddressObjクラス(206)が属性値設定対象オブジェクト、すなわち図1の値設定対象クラス104となる。
【0014】
UserObjクラス(204)は、氏名(漢字)=name、氏名(カナ)=name_kana、メールアドレス=email、性別=sex、趣味=hobbyが設定対象となっている。このうち趣味=hobbyが配列フィールドになっており、例えば競馬、麻雀といった趣味の内容が設定される。
birthdateObjクラス(205)は年(year)、月(month)、日(day)の属性値が設定対象となり、addressObjクラス(206)は郵便番号(zipcode)、都道府県(prefCode)、市区町村(city)、番地(houseNo)、アパート・ビル(building)、電話番号(telephone)、FAX番号(fax)が設定対象となっている。
【0015】
設定情報データ101は、図4に示すようなフィールド識別子401をキーとしフィールド設定値402を値としたハッシュテーブルであり、値設定対象オブジェクト102への値設定情報を格納している。
例えば、図2のUserObjクラス(204)とbirthdateObjクラス(205)およびaddressObjクラス(206)については、フィールド識別子401としてname,name_kana,…、hobby_1,hobby_2,hobby_3といった識別子と、その設定値である「山田太郎」、「ヤマダタロウ」、…、「null」といった情報が予め格納されている。
【0016】
JSPまたはServletを使用するWebアプリケーションシステムの場合、図111で後述するように、Web画面HTMLのフォーム部品の名前にフィールド識別子401(図11の1102,1104,1106,1108)を設定する事でWeb画面の入力データを設定情報データ101と同じ形式のハッシュテーブルとして取得する事が容易である。
【0017】
フィールド識別子401は、図5に示すように、値設定対象クラス104のフィールド名、またはフィールド名501と配列識別子505、またはフィールド識別子401とフィールド結合子502から構成されるものであり、値設定対象クラス104の値設定対象フィールドを一意に特定するために使用する。
フィールド名501は、クラスのフィールド名の文字列で表現される。フィールド結合子502は、フィールド名を繋ぐドット記号「.」で表現される。配列結合子503は、アンダースコア「_」で表現される。配列識別子505は、配列結合子503と配列番号504で構成され、配列番号504は「1」以上の整数値で表現される。
例えばbirthdateObjクラス(205)における属性yearについては、「birthdate」と「year」とを「.」で結合した「birthdate.year」で表現される。
同様に、hobbyについては「hobby_1」、zipicodeについては「addoress.zipCode」で表現される。
【0018】
値設定対象クラス104を構成するUserObjクラス(204)とbirthdateObjクラス(205)およびaddressObjクラス(206)は、図3に示すように、privateなフィールドとフィールドに対するpublicなアクセサメソッドおよび変換メソッド、チェックメソッドからなる。privateなフィールドとは、先頭に「−」記号が付いたフィールドである。例えば「−name」、「name_kana」、「−zipcode」といったフィールドである。
publicなアクセサメソッドはsetメソッド、getメソッドおよび変換メソッド、チェックメソッドからなる。publicなアクセサメソッドについては、先頭に「+」記号を付けて示している。
【0019】
それぞれの値設定対象クラスのgetメソッド105は、各フィールドの値を取得するために使用するもので、全てのフィールドに対して用意する。リフレクション機能113によるメソッドの検出を可能とするため、メソッド名を「get + 先頭大文字のフィールド名」としている。例えばnameについては「+getName()」という具合にしている。
setメソッド106は、各フィールドへの値の設定を行うために使用するもので、全てのフィールドに対して用意する。リフレクション機能113によるメソッドの検出を可能とするため、メソッド名を「set + 先頭大文字のフィールド名」としている。
【0020】
変換メソッド107はフィールドへの値の設定を行う際、設定情報データ101のフィールド設定値を変換して設定するために使用するもので、変換を行う任意のフィールドに対して用意するものである。リフレクション機能113による変換メソッド107の検出および汎用的な使用を可能とするため、メソッド名を「convert + 先頭大文字のフィールド名」とし、引数の型をObject型としている。
チェックメソッド108は、各クラスに設定した値のチェックを行うために使用するもので、任意のフィールドのチェックを行うチェックメソッド301と、フィールド間のチェックを行うためのチェックメソッド302を任意に用意する。リフレクション機能113によるチェックメソッド301,302の検出および汎用的な使用を可能とするため、メソッド名を「check(+ 先頭大文字のフィールド名)」とし、戻り値をvoid型としている。チェックエラーはメソッド内で例外を発生することにより検出する。
【0021】
詳細設定情報112は、図6に示すように、setメソッド106を実行する対象のクラスである親フィールド601と、親フィールド601に対するフィールド名602と、これら親フィールドとフィールド名で特定されるフィールドに対する設定値603を1レコードとした配列データであり、リフレクション機能113を使用することにより値設定対象オブジェクト102への値設定を容易に行うことが可能な形で必要な情報を全て格納している。
例えば、フィールド名602の「name」については親フィールド601として「userObj」、その設定値623として「山田太郎」を設定している。
次に、オブジェクト値設定プログラム103について説明する。
【0022】
図7はオブジェクト値設定プログラム103における制御の処理の流れを示すフローチャートである。
まず、詳細設定情報作成処理109を実行し(ステップ701)、以降の処理で必要となる詳細設定情報112を作成する。
次に、詳細設定情報112の1つのレコードを読み込み(ステップ702)、フィールド値設定処理110を実行し(ステップ703)、値設定対象オブジェクト102のフィールド識別子401によって特定されるフィールドに値を設定する。
次に、全レコードに対する処理が完了したかどうかを判定し(ステップ704)、完了していたならばフィールド値チェック処理111を実行し(ステップ705)、値設定対象オブジェクト102の設定値のチェックを行う。全レコードに対する処理が完了していない場合は、次のレコードを読み込む。
チェックエラーがある場合は(ステップ706)エラー内容を含む例外を発生し(ステップ707)終了する。チェックエラーがなければそのまま終了する。
【0023】
次に、詳細設定情報作成処理(図7のステップ701)、フィールド値設定処理(図7のステップ703)、フィールド値チェック処理(図7のステップ705)について、図8〜図10を用いて説明する。各処理では、値設定対象オブジェクトおよびそのフィールドのgetメソッド、newInstanceメソッド、setメソッド、変換メソッド、チェックメソッドの取得および実行と、フィールドの型の取得を行うためにリフレクション機能113を使用している。
なお、newInstanceメソッドは、図面には示していないが、Javaのクラスが全て持っているものである。
図8は、詳細設定情報作成処理109における制御の流れを示すフローチャートである。
まず、変数nに「0」を設定する(ステップ801)。次に、設定情報データ101の全レコードについて処理を行ったかどうかチェックし(ステップ802)、全レコードについて処理を行った場合はプログラムを終了する。
全レコードについて処理を行っていない場合は、設定情報データ101のフィールド識別子401に結合子(フィールド結合子または配列結合子)がn個のレコードがあるかどうかのチェックを行う(ステップ803)。該当レコードがない場合には、nを「+1」だけ更新して(ステップ804)、フローの初めに戻る。
【0024】
該当レコードがある場合、結合子がn個のレコードを1レコード読み込み(ステップ805)、フィールド識別子401から結合子より後でかつ配列識別子より前の文字列を取得することによりフィールド名を取得する(ステップ806)。
次に、レコードのフィールド識別子に配列識別子があるかどうかのチェックを行う(ステップ807)。配列識別子がない場合はレコードからフィールド設定値を設定値として読み込む(ステップ808)。
【0025】
「hobby_1」のように配列識別子がある場合は、設定情報データ101から同一フィールドを表す設定値を全て合わせた配列オブジェクトを作成し、設定値として読み込む(ステップ809)。この処理により、Java基本型以外の配列型のフィールドに対する値が設定可能になる。
次に、値設定対象オブジェクトもしくはそのフィールドのgetメソッドを実行する事により、設定値に対する親フィールドを取得する(ステップ810)。ここで、取得した親フィールドのチェックを行い(ステップ811)、親フィールドがnullの場合、親フィールドクラスのnewInstanceメソッドを実行する事により親フィールドを生成し、その親フィールドのsetメソッドを実行する事により生成した親フィールドを設定する(ステップ812)。
これにより、同じ親フィールドを取得しようとした場合にはここで生成した親フィールドを参照することになる。
【0026】
次に、ここまでの処理で取得した親フィールド、フィールド名、設定値を1レコードとして、詳細設定情報112に追加する(ステップ813)。更に、ここまで使用した設定情報データ101のレコードを処理済みとし、設定情報データ101のフィールド識別子に結合子がn個あるかどうかのチェック処理(ステップ803)に戻り、処理を継続する。
【0027】
図9はフィールド値設定処理110における制御の流れを示すフローチャートである。
まず、詳細設定情報112のレコードを読み込み(ステップ901)、親フィールドのフィールド名に対する変換メソッドを取得する(ステップ902)。ここで、変換メソッドを取得できたかどうかのチェックを行い(ステップ903)、取得できた場合はレコードの設定値603を引数として変換メソッドの実行を行い(ステップ904)、変換後の値を設定値として読み込む(ステップ905)。
【0028】
変換メソッドを取得できなかった場合は値設定対象フィールドの型を取得し(ステップ906)、フィールドの型とレコードの設定値の型が同じかどうかのチェックを行う(ステップ907)。ここで、型が異なる場合には、設定値の型をフィールドの型に変換し、設定値として読み込む(ステップ908)。
型が同じ場合には、レコードの設定値603をそのまま設定値として読み込む(ステップ909)。
これにより、フィールドの型に依存する事なく値設定を行うことが可能となる。
【0029】
次に、親フィールドのフィールド名に対するsetメソッドを取得し(ステップ910)、実行する(ステップ911)。これで、詳細設定情報112における1レコード分の値設定対象オブジェクトへの値設定処理が完了する。
図10はフィールド値チェック処理111における制御の流れを示すフローチャートである。
まず、全ての詳細設定情報レコード112に対する処理を実行したかどうかの判定を行い(ステップ1001)、全ての詳細設定情報レコード112の処理が終わっていればプログラムを終了する。全ての詳細設定情報レコードの処理が終わっていなければ、詳細設定情報112を1レコード読み込み(ステップ1002)、親フィールドのフィールド名に対するチェックメソッド301を取得する(ステップ1003)。ここで、チェックメソッドを取得できたかどうかのチェックを行い(ステップ1004)、取得できた場合はチェックメソッドの実行を行う(ステップ1005)。
これにより、フィールドに設定された値に対するチェック処理を行うことができる。チェックメソッド内で例外が発生した場合(ステップ1006)、チェックエラーとしてプログラムを終了する。例外が発生しなかった場合は処理を継続する。
チェックメソッドを取得できなかった場合はフィールドのチェック処理を行わない。
【0030】
次に、親フィールドのチェックメソッドを実行したかどうかを判定する(ステップ1007)。既に親フィールドのチェックメソッドを実行している場合、フローの初めに戻り次のレコード処理を開始する。まだ親フィールドのチェックメソッドの実行を行っていない場合は、親フィールドのチェックメソッド302(図3)を取得する(ステップ1008)。ここで、チェックメソッドを取得できたかどうかのチェックを行い(ステップ1009)、取得できた場合はチェックメソッドの実行を行う(ステップ1010)。
これにより、親フィールドのフィールド間のチェックを行うことができる。チェックメソッド内で例外が発生した場合(ステップ1011)、チェックエラーとしてプログラムを終了する。例外が発生しなかった場合、または親フィールドのチェックメソッドを取得できなかった場合には、フローの初めに戻り次のレコード処理を開始する。
【0031】
次に図11〜図14を通じて、Web画面の入力内容をオブジェクト値設定プログラム103を使用して値設定対象オブジェクト(図3のUserInfoクラスのインスタンス)に設定する例を説明する。
図11はWeb画面のHTML記述例を示すものである。
テキストボックス氏名(漢字)1101の値を値設定対象オブジェクトのnameフィールドに設定するため、INPUTタグのname属性1102に”name”を設定している。次に、テキストボックス西暦1103の値を値設定対象オブジェクトのbirthdateフィールドのyearフィールドに設定するため、INPUTタグのname属性1104に”birthdate.year”を設定している。また、テキストボックス郵便番号1105の値を値設定対象オブジェクトのaddressフィールドのzipCodeフィールドに設定するため、INPUTタグのname属性1106に”address.zipCode”を設定している。最後に、テキストボックス趣味1107の趣味1〜趣味3の値を値設定対象オブジェクトのhobbyフィールドに配列として設定するため、INPUTタグのname属性1108に”hobby_1”〜”hobby_3”を設定している。
【0032】
図12はオブジェクト値設定プログラム103をJavaクラスのメソッドとして実装した例を示すクラス図である。オブジェクト値設定プログラム103は、ValueSetterクラス1201のstaticメソッドload1202として実装されており、設定情報データであるMapと値設定対象オブジェクトであるObjectを引数として受け取り、値を設定したオブジェクトを戻り値として返すインタフェースとなっている。
【0033】
図13は変換メソッドの作成例を示している。
Addressクラス1301(図3のクラス206に相当)のprefCodeフィールドに対する変換メソッドとしてconvertPrefCodeメソッド1302を作成しており、設定情報データ101の文字列型設定値が”東京都”の場合は数値「13」、”北海道”の場合は数値「1」に変換するような処理となっている。
【0034】
図14はチェックメソッドの作成例を示している。
BirthDateクラス1401(図3のクラス205に相当)のyearフィールドに対するチェックメソッドとしてcheckYearメソッド1402を作成しており、yearフィールドの値が「0」以下の場合には「yearに0以下の数値が設定されました」というチェック例外1403を発生させるような処理となっている。
またフィールド間のチェックを行うチェックメソッドとしてcheckメソッド1404を作成しており、{month=2、day=30}などの不正な値が設定された場合には「年月日が不正です」といったチェック例外1405を発生させるような処理となっている。
【0035】
図15はオブジェクト値設定プログラム103を実行するServletの作成例を示している。図11の画面から送信された内容で設定情報データであるHashMap1501を作成し、値設定対象オブジェクト1502を作成し、これらを引数としてオブジェクト値設定プログラム1503を実行している。チェックエラーが発生した場合には例外1504を発生するような処理となっている。
【0036】
【発明の効果】
以上説明したように、本発明によれば、属性値設定対象オブジェクトの各フィールドに設定する属性値を作成して記憶手段に格納しておき、その属性値をJavaAPIで提供されるリフレクション機能を用いて各オブジェクトのパブリックなアクセサメソッドを呼び出して実行し、各属性値を一括して設定するようにしたため、各オブジェクトのsetメソッドを個々に呼び出して実行させるためのコーディングを行う必要がなくなり、Javaの技術によるアプリケーション開発において、画面の入力データ、データベースのレコード値、ファイルデータのレコード値等のオブジェクトへの設定、オブジェクトへの値設定に係るコーディング量を減少することができ、開発効率が向上する。
また、属性値設定対象オブジェクトにチェックメソッドを組み込み、このチェックメソッドを使用して属性値のチェックを行うようにしたため、設定した属性値の矛盾を容易に発見することができる。
また、型変換メソッドを組み込んでおくことにより、例えば数値型の属性値を文字型の属性値に変換して設定することができる。
また、配列型などのJava基本型以外のフィールドを含むオブジェクトへも属性値を設定することが可能となる。
【図面の簡単な説明】
【図1】本発明の一実施の形態であるオブジェクト値設定プログラムの概略構成を示す図である。
【図2】オブジェクト値設定プログラムの動作例を示す図である。
【図3】値設定対象クラスの構成を示すクラス図である。
【図4】設定情報データの構成を示す図である。
【図5】フィールド識別子の構成を示す図である。
【図6】詳細設定情報の構成を示す図である。
【図7】オブジェクト値設定プログラムの処理の概要を示すフロ−チャ−トである。
【図8】詳細設定情報作成処理を示すフローチャートである。
【図9】フィールド値設定処理を示すフローチャートである。
【図10】フィールド値チェック処理を示すフローチャートである。
【図11】画面HTMLの作成例を示す図である。
【図12】オブジェクト値設定プログラムの実装例を示すクラス図である。
【図13】変換メソッド実装クラスの例を示す図である。
【図14】チェックメソッド実装クラスの例を示す図である。
【図15】オブジェクト値設定プログラムを使用するServletの例を示す図である。
【符号の説明】
101…設定情報データ、102…値設定対象オブジェクト、103…オブジェクト値設定プログラム、104…値設定対象クラス、105…getメソッド、106…setメソッド、107…変換メソッド、108…チェックメソッド、109…詳細設定情報作成処理、110…フィールド値設定処理、111…フィールド値チェック処理、112…詳細設定情報、113…リフレクション機能。
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a method and a method for developing an application program using Java, which is an object-oriented programming language (Java and Java-related trademarks and logos are trademarks or registered trademarks of US SUN Microsystems, Inc.). In particular, the present invention relates to a processing method and a processing program for setting information (attribute value) such as input data of a Web screen and DB records to an object.
[0002]
[Prior art]
2. Description of the Related Art Conventionally, in the development work of an application program using Java technology, in order to set a value to each object (specifically, a class that is an instance of the object) which is a component of the application program, a value setting target object is set. A method of setting a field value (attribute value) using a set method incorporated in the object corresponding to each of the fields (attributes) is adopted. For example, for a class having the fields “name” and “age”, methods “setName ()” and “setAge ()” are incorporated in the class, and values such as name and age are set by using these methods. ing.
Also, in the Web application system development by JSP (Java Server Pages), by using the extended syntax <jsp: setProperty>, the values are collectively stored in the field where the parameter name of the HTML form and the field name of the value setting object coincide with each other. It is possible to set. Specifically, the field name of the value setting target object is set to the name of the HTML form part, the value setting target object is specified by the <jsp: useBean> tag, and then the property attribute of the <jsp: setProperty> tag is specified. By setting “*” in the field, the value is set to the object.
Here, there is a method disclosed in the following Patent Document 1 as a method for setting the attribute value of an object.
[0003]
[Patent Document 1]
JP 2001-282537 A
The extended syntax of JSP (Java Server Pages) is introduced in the following Non-Patent Document 1.
[0004]
[Non-patent document 1]
JavaServerPagesTMv1.2Syntax Reference / June 2002
[0005]
[Problems to be solved by the invention]
However, when an attribute value is set for each object using the above set method, a procedure for individually executing the set method for each field for setting the attribute value is required. Therefore, the number of classes or the number of fields (attribute items) In the case of developing an application program having many (number), there is a problem that the amount of coding for individually executing the set methods increases, and the load on the developer in the development and test work is large.
In addition, when the attribute value of each object is set using the JSP extension syntax <jsp: setProperty>, there is a problem that an attribute value for a field other than the Java basic type cannot be set. The Java basic type field is the one shown in “TABLE1” of Non-Patent Document 1 described above.
Further, there is a problem that the attribute value for the array field cannot be automatically set. For example, when there is an attribute of “hobby”, there is a problem that a plurality of attribute values such as “watching a movie” and “fishing” cannot be automatically set, and must be set manually.
Furthermore, since a check function for checking whether or not the set attribute values are inconsistent is not considered, there is a problem that inconsistencies in the set attribute values cannot be found.
Furthermore, since the function of converting the type of the attribute value from, for example, a character type to a numeric type is not considered, there is a problem that the type conversion cannot be performed according to the field type.
In summary, the conventional technology requires a large amount of coding for setting an attribute value to an object, and cannot flexibly cope with a need to perform type conversion and attribute value checking. was there.
[0006]
An object of the present invention is to provide an object value setting method and a program that can set an attribute value for an object with a small coding amount.
It is another object of the present invention to provide an object value setting method and a program capable of automatically setting attribute values for fields other than the Java basic type and attribute values for array fields.
It is another object of the present invention to provide an object value setting method and a program capable of performing type conversion and attribute value inconsistency check.
[0007]
[Means for Solving the Problems]
In order to achieve the above object, an object value setting method according to the present invention is provided by a first step of creating an attribute value to be set in each field of an attribute value setting target object and storing the attribute value in a storage unit, and a Java API. Executing a public accessor method set for each object using a reflection function, and setting an attribute value of the object stored in the storage means.
Further, in the second step, the conversion method is executed on the attribute field in which the conversion method for performing the type conversion is set, and the type of the attribute value stored in the storage means is converted and set in the attribute field. The method further comprises the step of:
In the second step, the method further comprises the step of executing the check on an attribute field in which a check method for checking the attribute value is set, and checking the attribute value specified by the check method. It is characterized by.
Further, in the second step, the method further comprises a step of acquiring an attribute value of the same array stored in the storage means for the attribute value for which an array identifier is set, and setting the attribute value as an attribute value of each array. Features.
[0008]
A program for setting an object value in a Java application program according to the present invention is provided by a first processing step of creating an attribute value to be set in each field of an attribute value setting target object and storing the attribute value in a storage unit, and a Java API. A second processing step of executing a public accessor method set for each object by using a reflection function and setting an attribute value of the object stored in the storage unit.
Further, in the second processing step, the conversion method is executed for the attribute field in which the conversion method for performing the type conversion is set, and the type of the attribute value stored in the storage unit is converted to the attribute field. The method further comprises a setting step.
Further, in the second processing step, a processing step of executing the check on an attribute field in which a check method for checking the attribute value is set and checking the attribute value specified by the check method is further included. It is characterized by having.
Further, the second processing step further includes a processing step of acquiring an attribute value of the same array stored in the storage unit with respect to the attribute value for which an array identifier is set, and setting the attribute value as an attribute value of each array. It is characterized by the following.
[0009]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, an embodiment of the present invention will be specifically described with reference to the drawings.
FIG. 1 is a diagram showing an embodiment of the present invention. As shown in FIG. 1, the system according to the present embodiment receives a setting information data 101 and a value setting target object 102 as inputs, and sets an attribute value (field value) to the value setting target object 102. 103, and a value setting target class 104 which is an instance of the value setting target object 102.
The setting information data 101, the value setting target object 102, the object value setting program 103, and the value setting target class 104 are stored in a storage device (not shown) of the computer.
[0010]
The value setting target class 104 has a get method 105, a set method 106, a conversion method 107, and a check method 108.
The object value setting program 103 is executed by a computer capable of executing a program in Java language, and includes a detailed setting information creating process 109, a field value setting process 110, a field value checking process 111, a detailed setting information 112, a reflection function 113.
[0011]
The detailed setting information creating process 109 is for creating detailed setting information 112 as shown in FIG. 6 described later based on the setting information data 101 as shown in FIG. Used as processing.
The field value setting processing 110 and the field value checking processing 111 function as subroutines of the object value setting program 103.
The reflection function 113 is provided by the Java API, and is used to execute each method of the value setting target class 104. The reflection function 113 is a function for accessing a field published by a Java object or class, changing an attribute of the Java object, or executing a method by calling a method.
[0012]
FIG. 2 shows an example in which the input content 201 of the Web screen is stored in the value setting target object 102.
The object value setting program 103 searches for setting values and setting fields that can be set in the value setting target object 102 from the setting information data 101 and sets them. At this time, when the type of the setting value or data conversion is necessary as in the prefCode field 202, the setting value is converted using the conversion method of the value setting target class. If there is an error in the input content, a check exception 203 is detected.
[0013]
The value setting target object in the example of FIG. 2 is a UserObj whose object name is UserInfo, and its attribute values are name (kanji) = name, name (kana) = name_kana, mail address = email, gender = sex, date of birth. = Birthdate, home information = address, hobby = hobby.
In the present invention, an attribute value is set for a value setting target class which is an instance of the UserObj object. In addition, independent classes “birthdateObj” and “addressObj” are created for the date of birth and home information, and attribute values are set for these classes. The creation of an independent class is merely performed for convenience in order to easily identify the contents of attributes, and has no special meaning.
In the example of FIG. 2, the UserObj class (204), the birthdayObj class (205), and the addressObj class (206) are the attribute value setting target objects, that is, the value setting target class 104 of FIG.
[0014]
The UserObj class (204) is set with a name (kanji) = name, a name (kana) = name_kana, an email address = email, gender = sex, and a hobby = hobby. Of these, hobby = hobby is an array field, in which hobby contents such as horse racing and mahjong are set.
The secondDateObj class (205) sets attribute values of year, month, and day, and the addressObj class (206) sets postal code (zipcode), prefecture (prefCode), municipalities ( city, an address (houseNo), an apartment building (building), a telephone number (telephone), and a FAX number (fax).
[0015]
The setting information data 101 is a hash table using a field identifier 401 as a key and a field setting value 402 as a value as shown in FIG. 4, and stores value setting information for the value setting object 102.
For example, in the case of the UserObj class (204), the secondDateObj class (205), and the addressObj class (206) in FIG. 2, identifiers such as name, name_kana,..., Hobby_1, hobby_1, and hobby_3 are set as the field identifier 401, and their setting values are “1”. Information such as “Taro Yamada”, “Taro Yamada”,..., “Null” is stored in advance.
[0016]
In the case of a Web application system using JSP or Servlet, as will be described later with reference to FIG. 111, the field identifier 401 (1102, 1104, 1106, and 1108 in FIG. 11) is set in the name of the form component of the Web screen HTML, so that the Web It is easy to obtain the input data on the screen as a hash table in the same format as the setting information data 101.
[0017]
As shown in FIG. 5, the field identifier 401 is composed of a field name of the value setting target class 104, or a field name 501 and an array identifier 505, or a field identifier 401 and a field connector 502. It is used to uniquely specify a value setting target field of the class 104.
The field name 501 is represented by a character string of the field name of the class. The field connector 502 is represented by a dot symbol “.” Connecting the field names. The array connector 503 is represented by an underscore “_”. The sequence identifier 505 is composed of a sequence connector 503 and a sequence number 504, and the sequence number 504 is represented by an integer value of “1” or more.
For example, the attribute “ear” in the “birthdateObj” class (205) is represented by “birthdate.year” in which “birthdate” and “year” are combined with “.”.
Similarly, hobby is represented by “hobby — 1”, and zipcode is represented by “addresses.zipCode”.
[0018]
As shown in FIG. 3, the UserObj class (204), the secondDateObj class (205), and the addressObj class (206) that constitute the value setting target class 104 are private fields, and public accessor methods, conversion methods, and check methods for the fields. Consists of A private field is a field preceded by a "-" symbol. For example, fields such as "-name", "name_kana", and "-zipcode" are used.
The public accessor method includes a set method, a get method, a conversion method, and a check method. Public accessor methods are shown with a “+” sign at the beginning.
[0019]
The get method 105 of each value setting target class is used to acquire the value of each field, and is prepared for all fields. In order to enable the reflection function 113 to detect a method, the method name is "get + field name in upper case". For example, the name is “+ getName ()”.
The set method 106 is used to set a value in each field, and is prepared for all fields. In order to enable detection of the method by the reflection function 113, the method name is “set + field name in upper case”.
[0020]
The conversion method 107 is used to convert and set a field setting value of the setting information data 101 when setting a value in a field, and is provided for an arbitrary field to be converted. In order to enable the reflection function 113 to detect the conversion method 107 and to use the conversion method 107 for general purposes, the method name is “convert + the field name in the first uppercase letter”, and the argument type is the Object type.
The check method 108 is used to check a value set in each class, and a check method 301 for checking an arbitrary field and a check method 302 for checking between fields are arbitrarily prepared. . In order to allow the reflection function 113 to detect the check methods 301 and 302 and to use them for general use, the method name is “check (+ the first uppercase field name)” and the return value is a void type. Check errors are detected by raising an exception in the method.
[0021]
As shown in FIG. 6, the detailed setting information 112 includes a parent field 601 which is a target class for executing the set method 106, a field name 602 corresponding to the parent field 601, and a field specified by the parent field and the field name. This is array data having the set value 603 as one record, and stores all necessary information in such a manner that the value setting to the value set object 102 can be easily performed by using the reflection function 113.
For example, for “name” of the field name 602, “userObj” is set as the parent field 601 and “Taro Yamada” is set as the set value 623 thereof.
Next, the object value setting program 103 will be described.
[0022]
FIG. 7 is a flowchart showing the flow of control processing in the object value setting program 103.
First, the detailed setting information creation processing 109 is executed (step 701), and the detailed setting information 112 required in the subsequent processing is created.
Next, one record of the detailed setting information 112 is read (step 702), the field value setting processing 110 is executed (step 703), and a value is set in the field specified by the field identifier 401 of the value setting target object 102. .
Next, it is determined whether or not the processing for all the records has been completed (step 704). If the processing has been completed, the field value check processing 111 is executed (step 705), and the setting value of the value setting object 102 is checked. Do. If processing has not been completed for all records, the next record is read.
If there is a check error (step 706), an exception including the error content is generated (step 707), and the process ends. If there is no check error, the process ends.
[0023]
Next, detailed setting information creation processing (step 701 in FIG. 7), field value setting processing (step 703 in FIG. 7), and field value check processing (step 705 in FIG. 7) will be described with reference to FIGS. I do. In each process, the reflection function 113 is used to acquire and execute the get method, newInstance method, set method, conversion method, and check method of the value setting target object and its field, and to acquire the type of the field.
Although the newInstance method is not shown in the drawing, all the Java classes have the newInstance method.
FIG. 8 is a flowchart showing the flow of control in the detailed setting information creation processing 109.
First, “0” is set to a variable n (step 801). Next, it is checked whether or not processing has been performed on all records of the setting information data 101 (step 802). If processing has been performed on all records, the program ends.
If processing has not been performed for all records, it is checked whether or not the field identifier 401 of the setting information data 101 has n records of connectors (field connectors or array connectors) (step 803). If there is no corresponding record, n is updated by "+1" (step 804), and the process returns to the beginning of the flow.
[0024]
If there is a corresponding record, the connector reads one record of n records (step 805), and obtains a field name from the field identifier 401 by obtaining a character string after the connector and before the array identifier from the field identifier 401 (step 805). Step 806).
Next, it is checked whether or not there is an array identifier in the field identifier of the record (step 807). If there is no array identifier, the field setting value is read from the record as the setting value (step 808).
[0025]
If there is an array identifier such as "hobby_1", an array object is created from the setting information data 101 by combining all the setting values representing the same field, and is read as the setting value (step 809). By this processing, a value can be set for an array type field other than the Java basic type.
Next, the parent field for the set value is obtained by executing the get method of the value set object or its field (step 810). Here, the obtained parent field is checked (step 811). If the parent field is null, the parent field is generated by executing the newInstance method of the parent field class, and the set method of the parent field is executed. Is set (step 812).
Thus, when trying to acquire the same parent field, the parent field generated here is referred to.
[0026]
Next, the parent field, the field name, and the setting value acquired by the processing up to this point are added to the detailed setting information 112 as one record (step 813). Further, it is determined that the record of the setting information data 101 used so far has been processed, and the process returns to the check processing (step 803) for checking whether the field identifier of the setting information data 101 has n connectors (step 803).
[0027]
FIG. 9 is a flowchart showing the flow of control in the field value setting processing 110.
First, the record of the detailed setting information 112 is read (step 901), and a conversion method for the field name of the parent field is obtained (step 902). Here, it is checked whether or not the conversion method has been acquired (step 903). If the conversion method has been acquired, the conversion method is executed using the record set value 603 as an argument (step 904), and the converted value is set to the set value. (Step 905).
[0028]
If the conversion method cannot be obtained, the type of the value setting target field is obtained (step 906), and it is checked whether the field type is the same as the record set value type (step 907). Here, if the types are different, the setting value type is converted to the field type and read as the setting value (step 908).
If the types are the same, the set value 603 of the record is read as it is as a set value (step 909).
This makes it possible to set a value without depending on the field type.
[0029]
Next, a set method for the field name of the parent field is obtained (step 910) and executed (step 911). Thus, the value setting processing for the value setting target object for one record in the detailed setting information 112 is completed.
FIG. 10 is a flowchart showing the flow of control in the field value check processing 111.
First, it is determined whether or not the processing has been performed on all the detailed setting information records 112 (step 1001). If the processing on all the detailed setting information records 112 has been completed, the program ends. If the processing of all the detailed setting information records is not completed, one record of the detailed setting information 112 is read (step 1002), and the check method 301 for the field name of the parent field is obtained (step 1003). Here, it is checked whether or not the check method has been acquired (step 1004). If the check method has been acquired, the check method is executed (step 1005).
As a result, a check process can be performed on the value set in the field. If an exception occurs in the check method (step 1006), the program ends as a check error. If no exception has occurred, processing continues.
If the check method cannot be fetched, field check processing is not performed.
[0030]
Next, it is determined whether the parent field check method has been executed (step 1007). If the parent field check method has already been executed, return to the beginning of the flow and start the next record processing. If the parent field check method has not been executed yet, the parent field check method 302 (FIG. 3) is obtained (step 1008). Here, it is checked whether or not the check method has been acquired (step 1009). If the check method has been acquired, the check method is executed (step 1010).
Thereby, it is possible to check between the fields of the parent field. If an exception occurs in the check method (step 1011), the program ends as a check error. If no exception has occurred, or if the check method of the parent field could not be obtained, return to the beginning of the flow and start the next record processing.
[0031]
Next, an example in which the input content of the Web screen is set to a value setting target object (an instance of the UserInfo class in FIG. 3) using the object value setting program 103 will be described with reference to FIGS.
FIG. 11 shows an example of HTML description of a Web screen.
In order to set the value of the text box name (kanji) 1101 in the name field of the value setting target object, “name” is set in the name attribute 1102 of the INPUT tag. Next, in order to set the value of the text box 1101 in the year field of the “birthdate” field of the value setting target object, “birthdate.year” is set in the name attribute 1104 of the INPUT tag. Further, in order to set the value of the text box zip code 1105 in the zipCode field of the address field of the value setting target object, “address.zipCode” is set in the name attribute 1106 of the INPUT tag. Finally, in order to set the values of the hobbies 1 to 3 of the text box hobby 1107 as an array in the hobby field of the value setting target object, “hobby_1” to “hobby_3” are set in the name attribute 1108 of the INPUT tag.
[0032]
FIG. 12 is a class diagram showing an example in which the object value setting program 103 is implemented as a method of the Java class. The object value setting program 103 is implemented as a static method load 1202 of the ValueSetter class 1201, receives Map as setting information data and Object as a value setting target object as arguments, and returns an object for which a value is set as a return value. It has become.
[0033]
FIG. 13 shows an example of creating a conversion method.
A convertPrefCode method 1302 is created as a conversion method for the prefCode field of the Address class 1301 (corresponding to the class 206 in FIG. 3). When the character string type setting value of the setting information data 101 is “Tokyo”, the numerical value “13” , "Hokkaido" is converted to a numerical value "1".
[0034]
FIG. 14 shows an example of creating a check method.
A checkYear method 1402 is created as a check method for the year field of the ByteDate class 1401 (corresponding to the class 205 in FIG. 3), and when the value of the year field is “0” or less, “year is set to a numerical value of 0 or less”. The check exception 1403 is generated.
In addition, a check method 1404 is created as a check method for checking between fields, and when an invalid value such as {month = 2, day = 30} is set, a check such as "The date is invalid" is performed. The processing is such that an exception 1405 is generated.
[0035]
FIG. 15 shows an example of creating a Servlet that executes the object value setting program 103. A HashMap 1501, which is setting information data, is created based on the contents transmitted from the screen of FIG. 11, a value setting target object 1502 is created, and the object value setting program 1503 is executed using these as arguments. When a check error occurs, an exception 1504 is generated.
[0036]
【The invention's effect】
As described above, according to the present invention, an attribute value to be set in each field of an attribute value setting target object is created and stored in the storage unit, and the attribute value is set using the reflection function provided by the Java API. Since the public accessor method of each object is called and executed, and the attribute values are set collectively, there is no need to perform coding for individually calling and executing the set method of each object. In application development using technology, it is possible to reduce the amount of coding related to setting of input data on a screen, record values of a database, record values of file data, etc. to an object, and setting of a value to an object, thereby improving development efficiency.
In addition, since a check method is incorporated in the attribute value setting target object and the attribute value is checked using this check method, inconsistencies in the set attribute values can be easily found.
Further, by incorporating a type conversion method, for example, a numeric attribute value can be converted into a character attribute value and set.
Also, it is possible to set an attribute value to an object including a field other than the Java basic type such as an array type.
[Brief description of the drawings]
FIG. 1 is a diagram showing a schematic configuration of an object value setting program according to an embodiment of the present invention.
FIG. 2 is a diagram illustrating an operation example of an object value setting program.
FIG. 3 is a class diagram showing a configuration of a value setting target class.
FIG. 4 is a diagram showing a configuration of setting information data.
FIG. 5 is a diagram showing a configuration of a field identifier.
FIG. 6 is a diagram showing a configuration of detailed setting information.
FIG. 7 is a flowchart showing an outline of processing of an object value setting program.
FIG. 8 is a flowchart illustrating detailed setting information creation processing.
FIG. 9 is a flowchart illustrating a field value setting process.
FIG. 10 is a flowchart showing a field value check process.
FIG. 11 is a diagram showing an example of creating a screen HTML.
FIG. 12 is a class diagram illustrating an implementation example of an object value setting program.
FIG. 13 is a diagram illustrating an example of a conversion method implementation class.
FIG. 14 is a diagram illustrating an example of a check method implementation class.
FIG. 15 is a diagram illustrating an example of a Servlet using an object value setting program.
[Explanation of symbols]
101: setting information data, 102: value setting object, 103: object value setting program, 104: value setting class, 105: get method, 106: set method, 107: conversion method, 108: check method, 109: details Setting information creation processing, 110: field value setting processing, 111: field value check processing, 112: detailed setting information, 113: reflection function.

Claims (8)

Javaアプリケーションプログラムにおけるオブジェクト値設定方法であって、属性値設定対象オブジェクトの各フィールドに設定する属性値を作成して記憶手段に格納する第1のステップと、
JavaAPIで提供されるリフレクション機能を用いて各オブジェクトに設定されたパブリックなアクセサメソッドを実行し、前記記憶手段に格納された当該オブジェクトの属性値を設定する第2のステップとを備えることを特徴とするオブジェクト値設定方法。
An object value setting method in a Java application program, comprising: a first step of creating an attribute value to be set in each field of an attribute value setting target object and storing the attribute value in a storage unit;
Executing a public accessor method set for each object using a reflection function provided by a Java API, and setting an attribute value of the object stored in the storage means. Object value setting method to be used.
前記第2のステップにおいて、型変換を行う変換メソッドが設定された属性フィールドに対し当該変換メソッドを実行し、前記記憶手段に記憶された属性値の型を変換して当該属性フィールドに設定するステップをさらに備えることを特徴とする請求項1に記載のオブジェクト値設定方法。Executing the conversion method on the attribute field in which the conversion method for performing the type conversion is set in the second step, converting the type of the attribute value stored in the storage unit and setting the attribute value in the attribute field The object value setting method according to claim 1, further comprising: 前記第2のステップにおいて、属性値のチェックを行うチェックメソッドが設定された属性フィールドに対し当該チェックを実行し、当該チェックメソッドで指定されている属性値のチェックを行うステップをさらに備えることを特徴とする請求項1または2に記載のオブジェクト値設定方法。In the second step, the method further comprises the step of executing the check on an attribute field in which a check method for checking the attribute value is set, and checking the attribute value specified by the check method. 3. The object value setting method according to claim 1, wherein: 前記第2のステップにおいて、配列識別子が設定された属性値に対し、前記記憶手段に記憶された同一配列の属性値を取得し、各配列の属性値として設定するステップをさらに備えることを特徴とする請求項1〜3のいずれか一項に記載のオブジェクト値設定方法。In the second step, the method further includes a step of acquiring an attribute value of the same array stored in the storage unit for the attribute value for which the array identifier is set, and setting the attribute value as an attribute value of each array. The object value setting method according to claim 1. Javaアプリケーションプログラムにおけるオブジェクト値を設定するプログラムであって、
属性値設定対象オブジェクトの各フィールドに設定する属性値を作成して記憶手段に格納する第1の処理ステップと、
JavaAPIで提供されるリフレクション機能を用いて各オブジェクトに設定されたパブリックなアクセサメソッドを実行し、前記記憶手段に格納された当該オブジェクトの属性値を設定する第2の処理ステップとを備えることを特徴とするオブジェクト値設定プログラム。
A program for setting an object value in a Java application program,
A first processing step of creating an attribute value to be set in each field of the attribute value setting object and storing the attribute value in a storage unit;
A second processing step of executing a public accessor method set for each object using a reflection function provided by a Java API, and setting an attribute value of the object stored in the storage unit. Object value setting program.
前記第2の処理ステップにおいて、型変換を行う変換メソッドが設定された属性フィールドに対し当該変換メソッドを実行し、前記記憶手段に記憶された属性値の型を変換して当該属性フィールドに設定する処理ステップをさらに備えることを特徴とする請求項5に記載のオブジェクト値設定プログラム。In the second processing step, the conversion method is executed on the attribute field in which the conversion method for performing the type conversion is set, and the type of the attribute value stored in the storage unit is converted and set in the attribute field. The object value setting program according to claim 5, further comprising a processing step. 前記第2の処理ステップにおいて、属性値のチェックを行うチェックメソッドが設定された属性フィールドに対し当該チェックを実行し、当該チェックメソッドで指定されている属性値のチェックを行う処理ステップをさらに備えることを特徴とする請求項5または6に記載のオブジェクト値設定プログラム。The second processing step further includes a processing step of executing the check on an attribute field in which a check method for checking the attribute value is set, and checking the attribute value specified by the check method. 7. The object value setting program according to claim 5, wherein: 前記第2の処理ステップにおいて、配列識別子が設定された属性値に対し、前記記憶手段に記憶された同一配列の属性値を取得し、各配列の属性値として設定する処理ステップをさらに備えることを特徴とする請求項5〜7のいずれか一項に記載のオブジェクト値設定プログラム。In the second processing step, further comprising a processing step of acquiring an attribute value of the same array stored in the storage unit for the attribute value for which an array identifier is set, and setting the attribute value as an attribute value of each array. An object value setting program according to any one of claims 5 to 7, characterized in that:
JP2003042290A 2003-02-20 2003-02-20 Object value setting method and program Pending JP2004252708A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003042290A JP2004252708A (en) 2003-02-20 2003-02-20 Object value setting method and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003042290A JP2004252708A (en) 2003-02-20 2003-02-20 Object value setting method and program

Publications (1)

Publication Number Publication Date
JP2004252708A true JP2004252708A (en) 2004-09-09

Family

ID=33025605

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003042290A Pending JP2004252708A (en) 2003-02-20 2003-02-20 Object value setting method and program

Country Status (1)

Country Link
JP (1) JP2004252708A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488512A (en) * 2013-09-29 2014-01-01 广州创维平面显示科技有限公司 Program interface display processing method and device
JP2017016479A (en) * 2015-07-02 2017-01-19 富士通株式会社 Information processing program, device, and method
CN109873831A (en) * 2019-03-14 2019-06-11 珠海天燕科技有限公司 A kind of method and system of data transmission

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488512A (en) * 2013-09-29 2014-01-01 广州创维平面显示科技有限公司 Program interface display processing method and device
JP2017016479A (en) * 2015-07-02 2017-01-19 富士通株式会社 Information processing program, device, and method
CN109873831A (en) * 2019-03-14 2019-06-11 珠海天燕科技有限公司 A kind of method and system of data transmission
CN109873831B (en) * 2019-03-14 2021-07-23 珠海天燕科技有限公司 Data transmission method and system

Similar Documents

Publication Publication Date Title
US7793260B2 (en) System for defining and activating pluggable user interface components for a deployed application
US7739691B2 (en) Framework for declarative expression of data processing
US9830341B2 (en) Resource name generation and derivation utilizing attribute space monikers and their associated context
US9164998B2 (en) Archive-system-independent archive-type objects
US8418142B2 (en) Architecture for data validation
US6832220B1 (en) Method and apparatus for file searching, accessing file identifiers from reference page
US8595259B2 (en) Web data usage platform
US9229971B2 (en) Matching data based on numeric difference
US7831614B2 (en) System and method for generating SQL using templates
US7606836B2 (en) Methods for efficient data version verification
CN112765023B (en) Test case generation method and device
US7685114B2 (en) Systems and methods for mapping text
US8214799B2 (en) Providing information to an isolated hosted object via system-created variable objects
CN109710220B (en) Relational database query method, relational database query device, relational database query equipment and storage medium
CN111443901B (en) Java reflection-based service expansion method and device
EP3974960B1 (en) Method and system for automated testing of web service apis
US7539687B2 (en) Priority binding
US20080133587A1 (en) Extending Existing Data within a Directory Service
US20200057617A1 (en) Software code optimizer and method
US20190294418A1 (en) Multi-platform interface framework
JP2004252708A (en) Object value setting method and program
US10908924B2 (en) System and methods for loading objects from hash chains
CN112347794A (en) Data translation method, device, equipment and computer storage medium
CN108334621B (en) Database operation method, device, equipment and computer readable storage medium
CN112052234A (en) Service data processing method and device, storage medium and electronic device