JP2007011586A - Method for managing message resource for software - Google Patents
Method for managing message resource for software Download PDFInfo
- Publication number
- JP2007011586A JP2007011586A JP2005190002A JP2005190002A JP2007011586A JP 2007011586 A JP2007011586 A JP 2007011586A JP 2005190002 A JP2005190002 A JP 2005190002A JP 2005190002 A JP2005190002 A JP 2005190002A JP 2007011586 A JP2007011586 A JP 2007011586A
- Authority
- JP
- Japan
- Prior art keywords
- message
- file
- document
- resource
- program
- 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
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
- Stored Programmes (AREA)
Abstract
Description
本発明は、ソフトウェアのメッセージ資源の管理方法に関する。 The present invention relates to a software message resource management method.
プログラム実行の際、例えばエラー発生時などに表示画面やファイル等の出力装置に出力するメッセージは、プログラム中にそのメッセージ内容を直接記述してしまうと、後からメッセージを変更する場合にプログラムまで書き換える必要があるなどメッセージの管理が難しくなる。すなわち、ソフトウェア製品で使用するメッセージは、通常、機能仕様書やマニュアルに一覧を記載する必要があるため、同一内容のメッセージは同一のIDにより管理する。メッセージ内容を修正する場合には、プログラム中で使用している同一IDのメッセージを全て修正しなければならない。プログラム中にメッセージを直接記述した場合には、修正箇所を検索する手間を要する上に、同一のIDのメッセージの内容が異なっていないかどうかに関するチェックも行う必要がある。特に、大規模なソフトウェアの場合には、プログラム中で使用しているメッセージを全て調査し、ドキュメントに漏れなく記載すると膨大な作業量となる。 When executing a program, for example, if a message is output to an output device such as a display screen or a file when an error occurs, if the message content is described directly in the program, the program will be rewritten if the message is changed later. It becomes difficult to manage messages such as necessity. That is, since messages used in software products usually need to be listed in a functional specification or manual, messages having the same contents are managed by the same ID. When modifying the message contents, all messages with the same ID used in the program must be modified. When the message is directly described in the program, it is necessary to search for a correction location and to check whether the content of the message with the same ID is different. In particular, in the case of large-scale software, if all messages used in the program are investigated and written in the document without omission, a huge amount of work is required.
そこで、メッセージ資源をプログラムの外部に配置するメッセージ資源の外部化ということが考えられている。メッセージ資源の外部化に関する従来例としては、下記特許文献1に記載の技術が知られている。特許文献1には具体的な方法は言及されていないが、一般的には、まず、出力するメッセージを、ファイル名等の可変要素と、可変要素を埋め込む位置に特定の記号を挿入したメッセージテンプレートと、に分解する。ソースファイルとは別のファイルに、一連のメッセージテンプレートとそれに対応するキーを記述しておき、プログラム側でキーを指定してメッセージテンプレートを取り出すようにする。そして、メッセージテンプレートと埋字のリストから、プログラムの実行時にメッセージを組み立てるようにする。
Therefore, it is considered to externalize the message resource in which the message resource is arranged outside the program. As a conventional example relating to externalization of message resources, a technique described in
システムによっては、特にメッセージ資源の国際化という観点から、メッセージ資源の外部化を補助するライブラリが提供されている場合がある。例えば、Java言語の場合、リソースバンドルと呼ぶ機構が用意されている。 Depending on the system, a library for assisting externalization of message resources may be provided, particularly from the viewpoint of internationalization of message resources. For example, in the case of Java language, a mechanism called resource bundle is prepared.
図1はリソースバンドルを使用したメッセージ管理の例を示す図である。「キー = メッセージテンプレート」の形式で、プログラムで使うメッセージファイルであるプロパティファイル100を作成しておき、ソースファイル110でID001などのキーを指定することにより、キーに対応するメッセージテンプレート、例えば、「ID001={0}のファイルでI/Oエラーが発生しました。」などのメッセージを取得する。ドキュメント120は、プロパティファイル100に基づいて手動で生成される(130)。そのため、人為的なミスは避けがたく、例えばドキュメントファイル120にメッセージを追加するのを忘れたり、ドキュメントファイル120とプログラムの出力結果とが異なったりする可能性もある。尚、ドキュメントファイル120とプログラムとの同期については、下記特許文献2に記載されている。
FIG. 1 is a diagram illustrating an example of message management using resource bundles. A
図1に示すように、メッセージ資源をソースファイル110から切離して外部ファイル(プロパティファイル)100に記述した場合に、プログラム中で特定のメッセージを取り出すためには、当該メッセージに対応付けられたキー値(例えば、“ID001”)を矢印で示すように指定する必要がある。前述のリソースバンドルでは、プロパティファイル100に記述したキー値“ID001”を指定してメッセージ資源「{0}のファイルでI/Oエラーが発生しました。」を取得する。C言語にもUNIXのメッセージカタログという機構があるが、同様にプログラム中で文字列を指定してメッセージ資源を取得する。
As shown in FIG. 1, when a message resource is separated from a
ところで、メッセージ資源を取得するためのキー値として誤った値(文字列)、例えば、“ID01”を指定してしまったと仮定する。このような誤りがあった場合でも、文字列としては構文的には間違っていないため、機械語に翻訳する際にコンパイルエラーとはならない。従って、機械語に翻訳した後になって、実際にプログラムを実行して当該メッセージの取得処理に到達した段階においてリソースが取得できない旨のエラーが発生し、初めて指定間違であったことが発見されることになる。 By the way, it is assumed that an incorrect value (character string), for example, “ID01” is specified as a key value for acquiring a message resource. Even if there is such an error, it is not syntactically wrong as a character string, so it does not cause a compile error when translated into machine language. Therefore, after translation into machine language, it was discovered that an error occurred indicating that resources could not be acquired when the program was actually executed and the message acquisition process was reached, and it was the first time that the specification was incorrect. Will be.
また、メッセージテンプレートと埋字リストとからメッセージを作成した場合には、通常、Java言語のMessageFormatやC言語のsprintfなどの標準ライブラリが使用される。 When a message is created from a message template and an embedded list, a standard library such as Java MessageFormat or C language sprintf is usually used.
これらは、メッセージテンプレート中の埋字の数と与えられた引数の数とに関するチェック機能がなく、指定する引数の数や型を間違えた場合には、コンパイルエラーにはならない。従って、意図しないメッセージが作成されることになりかねない。仮にメッセージの組立時に埋字と引数の数とをチェックするルーチンを作成したとしても、プログラムによる処理の実行時にならないとチェックされない。 These do not have a check function for the number of embedded characters in the message template and the number of given arguments, and will not cause a compilation error if the number or type of the specified arguments are incorrect. Therefore, an unintended message may be created. Even if a routine for checking the number of embedded characters and the number of arguments at the time of assembling a message is created, the routine is not checked unless the processing is executed by a program.
異常系のエラーメッセージの場合には、マシンテストによって実行するのが困難な状況もあり、メッセージの不良を作り込んだまま見逃す可能性もある。 In the case of an abnormal error message, there are situations where it is difficult to execute by a machine test, and there is a possibility of overlooking the message with a built-in defect.
上記特許文献1は、プログラムとは別に、動作ごとに定義したメッセージを対話的に追加・変更することを目的としており、メッセージ構築に関する不良をコンパイル時に検出することができない。上記特許文献2は、プログラム資源とドキュメントとを、それぞれリビジョンで管理し、リビジョンのチェックによって同期化する方式を記載しており、本発明の手法とは異なる。
The above-mentioned
本発明は、メッセージ資源の情報を特定のフォーマットのメッセージ資源定義ファイルで管理し、メッセージ構築に関する不良をプログラム実行前(コンパイル時)に検出することを目的とする。 An object of the present invention is to manage message resource information with a message resource definition file of a specific format, and to detect a failure related to message construction before executing a program (during compilation).
また、本発明は、ドキュメントへのメッセージの追加・修正漏れ等による不一致が生じなくなるようにすることを目的とする。 It is another object of the present invention to prevent inconsistency due to a lack of addition / correction of a message to a document.
本発明ではメッセージ資源の情報をメッセージ資源定義ファイルに記述し、このファイルからメッセージ管理クラスを生成する装置およびメッセージドキュメントを自動生成する装置を設ける。 In the present invention, message resource information is described in a message resource definition file, and a device for generating a message management class from this file and a device for automatically generating a message document are provided.
メッセージ管理クラスは、従来手法での、メッセージテンプレートのキーの記述ミスおよび埋字の指定ミスを、コンパイル時に検出できるようにする機構である。メッセージ管理クラスでは、一つのメッセージに対応した一つのメソッドとして作成される。すなわち、メッセージの取得を、「文字列」によるキーではなく、メッセージ毎に自動生成された「メソッド」で行う。文字列の場合は、”xxx”を”xx”とミスしても構文的には正しいが、メソッドxxx()をxx()とミスした場合、「xx()というメソッドは定義されていない」という構文エラーになる。 The message management class is a mechanism that makes it possible to detect a mistake in the description of the key of the message template and a mistake in the designation of the embedded character in the conventional method at the time of compilation. In the message management class, it is created as one method corresponding to one message. In other words, the message is acquired not by the key based on the “character string” but by the “method” automatically generated for each message. In the case of a character string, even if “xxx” is missed as “xx”, it is syntactically correct. However, when the method xxx () is missed as xx (), “the method xx () is not defined” Results in a syntax error.
また、メッセージの埋字はメソッドの引数に対応させる。従来のObject型の配列では、new Object[] {file, name}と指定するべきところを、例えばnew Object[] {file}などとミスしてもエラーにはならないが、メソッドの引数の場合、xxx(file, name)をxxx(file)と誤って指定すると、コンパイルエラーになる。 In addition, the padding of the message corresponds to the method argument. In the conventional Object type array, it is not an error if a place where new Object [] {file, name} should be specified, for example, new Object [] {file}, is not an error. If xxx (file, name) is incorrectly specified as xxx (file), a compilation error occurs.
本発明によれば、プログラムの外部に記述されたメッセージ資源をプログラム中から呼び出す際、メッセージ管理クラスでは、一つのメッセージに対応した一つのメソッドとして作成されるため、メッセージを間違えた場合にはコンパイル時にエラーになる。また、メッセージの埋字をメソッドの引数に対応させることで、メッセージの呼出において、メソッドの名前、引数の数、引数の型のすべてが一致していなければ、コンパイルエラーとなる。 According to the present invention, when a message resource described outside the program is called from within the program, the message management class is created as one method corresponding to one message. Sometimes an error occurs. Also, by matching the message padding to the method arguments, a compile error will occur if the method name, number of arguments, and argument types do not all match in the message call.
そのため、メッセージの不良をプログラムの実行前に検出することができるという利点がある。また、同一のメッセージ資源から、プログラムのメッセージ管理クラスとドキュメントとを自動生成するため、ドキュメントへのメッセージの追加・修正漏れ等による不一致がなくなるという利点がある。 Therefore, there is an advantage that a defective message can be detected before the program is executed. Further, since the message management class of the program and the document are automatically generated from the same message resource, there is an advantage that there is no inconsistency due to the addition or correction omission of the message to the document.
以下、本発明の一実施の形態によるソフトウェアのメッセージ資源管理技術について図面を参照して説明する。図2は、本実施の形態によるメッセージ資源管理システムの一構成例を示す機能ブロック図である。図2に示すように、本実施の形態によるメッセージ資源管理システム200(破線で囲まれた構成)は、メッセージクラス生成装置201と、メッセージドキュメント生成装置202と、を有している。メッセージ資源の情報を格納するファイルとして、後述するメッセージ資源定義ファイル203を有する。本実施の形態では、メッセージ資源定義ファイル203をXML形式で記載し、プログラム言語としてJavaを用いた場合を例にして以下に説明する。
A software message resource management technique according to an embodiment of the present invention will be described below with reference to the drawings. FIG. 2 is a functional block diagram showing a configuration example of the message resource management system according to the present embodiment. As shown in FIG. 2, the message resource management system 200 (configuration surrounded by a broken line) according to the present embodiment includes a message
メッセージクラス生成装置201は、後述する図3に示すメッセージ資源定義ファイル203の情報を読み込み、メッセージを管理する共通部分を雛形(テンプレート)として管理するメッセージ管理クラス204を生成する。メッセージドキュメント生成装置202は、メッセージ資源を定義するメッセージ資源定義ファイル203の情報を読み込み、メッセージドキュメント205を生成する。
The message
本実施の形態によるメッセージ資源管理システム200に関連して、プログラム格納部211と、処理系212と、実行ファイル格納部213と、I/O214と、が設けられ、I/O214から、ファイル215aとして、又はCRTなどの表示部215bに表示されることでプログラムの実行結果が表示・出力される。
In relation to the message
ここで、上記メッセージ資源定義ファイル203をXML形式で記述した内容例について説明する。図3は、作成者が、例えば手書きで作成したメッセージ資源定義ファイル203の記述例を示した図である。図3において、要素301は、IDをキーにした1つのメッセージを表す要素である。1つのメッセージ毎に要素301を記述する。要素301の属性としてメッセージID(ここでは、「ID001」)を指定しておく。要素302には、メッセージテンプレート(ここでは、「{0}のファイルでI/Oエラーが発生しました。{1}」)を記述する。要素303は、上記{0}、{1}のように順番に記載されている埋め字の解説であり、{0}:ファイル名、{1}:エラー内容などの埋字の説明するメッセージが記述されている。要素304には、上記メッセージが発生する発生要因(cause)を記述する。例えば、「ファイルの操作でエラーが発生しました。」などの記述がなされる。要素305には、上記メッセージが発生した場合の対処方法(solution)が必要な場合には、それを記述する。例えば、「ファイルの状態を確認してください。」などの記述がなされる。
Here, an example of contents in which the message
要素306には、メッセージに対応し、呼び出されることで作成したメッセージを返却するメソッドに関する情報を記述する。要素306の属性には、例えば、「ioError」などの、作成するメソッド名が指定されている。要素307には、作成するメソッドの引数に関する情報を記述する。要素307の属性には、引数の型308、引数名309、引数コメント310がそれぞれ指定されている。このように、メッセージ資源定義ファイルには、ID001に関連する情報を全て記載し、かつ、例えばXMLで記述する。
In an element 306, information related to a message and a method for returning a message created by being called is described. In the attribute of the element 306, for example, a method name to be created such as “ioError” is specified. An
図4は、図2に示すメッセージクラス生成装置201が後述するメッセージ管理クラス600を自動作成する手順を示すフローチャート図である。図6は、図4に示す手順で生成されるメッセージ管理クラス600と、ソースファイル610と、後述する手順で作成されるドキュメント620との記述に関する構成例を示す図である。図4の処理を開始すると、メッセージ管理クラスの外枠を自動で作成(ステップS401)した後、メッセージ資源定義ファイル203(図2,3)の内容からメッセージ管理クラス600を作成する(ステップ402〜ステップ404)。
FIG. 4 is a flowchart showing a procedure for automatically creating a
すなわち、ステップ402において図3の符号306で示すメソッドネーム“ioError”を図6に示すメッセージ管理クラス600の“public Message ioError…”に転記する。ステップS403において、図3の符号302の内容を図6のメッセージ管理クラス600のクラスコメント「ID001{0}の処理でI/Oエラーが発生しました。」に転記する。
That is, in step 402, the method name “ioError” indicated by reference numeral 306 in FIG. 3 is transferred to “public Message ioError...” Of the
ステップS404において、上記メソッドのパラメタ情報である要素307から、図6のメッセージ管理クラス600のパラメタ定義「java.io.File file,
Throwable cause」、およびパラメタのコメント「@param fileファイル名」「@param cause エラー内容」を作成する。
In step S404, from the
"Through cause" and parameter comments "@param file file name" and "@param cause error contents" are created.
次いで、符号307の処理が終了したか否かを判断し、終了した場合には(Y)、ステップS405に進み、終了していない場合には(N)ステップS404を繰り返す。ステップS405において、メソッドの実装を作成し、符号310の処理が終了したか否かを判断する。終了していない場合には(N)ステップS402に戻り、終了している場合には(Y)、メッセージ管理クラス600を作成する処理を終了する。
Next, it is determined whether or not the process of
尚、ステップS405において実装するメソッドの内容は、図1で説明した従来の外部メッセージ資源取得の実装方法と同様の方法でよい。メソッドの実装は自動的に行われるため、人為的なミスが生じるおそれはないからである。入力ファイルはメッセージ資源定義ファイル203のみであり定義ファイルにXMLを使用しているため、メッセージクラス生成装置201はXSLスタイルシートなどで実装することができる。
The content of the method implemented in step S405 may be the same method as the conventional external message resource acquisition method described in FIG. This is because method implementation is automatic and there is no risk of human error. Since the input file is only the message
図5は、メッセージドキュメント生成装置202(図2)がメッセージドキュメント620(図6)を自動作成する手順を示すフローチャート図である。処理を開始すると、ステップS501において、図3の要素301と要素302とを図6のドキュメント620の1行目のIDとメッセージに記述する。次いで、ステップS502において、図3の要素303から図6のドキュメント620の2〜3行目の埋字の説明を作成する。次いで、符号307の処理が終了したか否かを判断し、終了した場合には(Y)、ステップS503に進み、終了していない場合には(N)ステップS502に戻る。ステップS503において、要素304から要因の説明を作成し(図6のドキュメントの4行目)、ステップS504において、要素305から対処方法の説明を作成する(図6のドキュメントの5行目)。次いで、符号301の処理が終了したか否かを判断し、終了した場合には(Y)、ドキュメント作成処理を終了し、終了していない場合には(N)ステップS501に戻る。
FIG. 5 is a flowchart showing a procedure in which the message document generating apparatus 202 (FIG. 2) automatically creates the message document 620 (FIG. 6). When the process starts, in step S501, the
この処理における入力ファイルはメッセージ資源定義ファイル203のみであるため、メッセージドキュメント生成装置202は同様にXSLスタイルシートなどで実装することができる。
Since the input file in this process is only the message
このように、図6に示すメッセージ管理クラス600と、ドキュメント620とは、図3のメッセージ資源定義ファイル203に記載されたデータに基づいて自動作成することができるので、ここでの記載ミスは生じない。
As described above, the
メッセージ管理クラス600では、メッセージの取得を、「文字列」によるキーではなく、メッセージ毎に自動生成された「メソッド」で行う。すなわち、メソッドで取得するというだけで構文エラーになる。
In the
一方、メッセージの埋字はメソッドの引数に対応させる。従来のObject型の配列では、new Object[] {file, name}と指定するべきところを、例えばnew Object[] {file}などとミスしてもエラーにはならないが、メソッドの引数の場合、xxx(file, name)をxxx(file)と誤って指定すると、コンパイルエラーになる。 On the other hand, the padding of the message corresponds to the method argument. In the conventional Object type array, it is not an error if a place where new Object [] {file, name} should be specified, for example, new Object [] {file}, is not an error. If xxx (file, name) is incorrectly specified as xxx (file), a compilation error occurs.
以上に説明したように、本実施の形態によるソフトウェアのメッセージ資源管理方法によれば、同一のメッセージ資源から、プログラムのメッセージ管理クラスとドキュメントとを自動生成するため、ドキュメントへのメッセージの追加・修正漏れ等に起因する不一致を防止することができる。また、プログラムの外部に記述されたメッセージ資源をプログラム中から呼び出す際に、メソッドで取得するようにするというだけで構文エラーになる。すなわち、メッセージや引数の指定を間違えた場合にはコンパイル時にエラーになる。従って、メッセージの不良についてプログラムを実行する前に検出できるという利点がある。 As described above, according to the software message resource management method of the present embodiment, the message management class and the document of the program are automatically generated from the same message resource, so that the message is added to or modified from the document. Inconsistency due to leakage or the like can be prevented. In addition, when a message resource described outside the program is called from within the program, a syntax error occurs simply by obtaining it with a method. In other words, if a message or argument is specified incorrectly, an error will occur during compilation. Therefore, there is an advantage that a message failure can be detected before the program is executed.
本発明は、ソフトウェアのメッセージ資源管理方法及び装置として利用可能である。 The present invention can be used as a software message resource management method and apparatus.
201…メッセージクラス生成装置、202…メッセージドキュメント生成装置、203…メッセージ資源定義ファイル、204…メッセージ管理クラス、205…メッセージドキュメント。
DESCRIPTION OF
Claims (1)
ソフトウェアのメッセージ資源に対応するプログラム用の情報とドキュメント用の情報とを、1つのファイルに記述したメッセージ資源定義ファイルを作成するステップと、
該メッセージ資源定義ファイルに基づいて、一つのメッセージに対応した一つのメソッドとして作成されるメッセージ管理クラスを作成するステップと
を有する方法。 A method for managing software message resources,
Creating a message resource definition file in which information for a program corresponding to a message resource of software and information for a document are described in one file;
Creating a message management class created as one method corresponding to one message based on the message resource definition file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005190002A JP2007011586A (en) | 2005-06-29 | 2005-06-29 | Method for managing message resource for software |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005190002A JP2007011586A (en) | 2005-06-29 | 2005-06-29 | Method for managing message resource for software |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2007011586A true JP2007011586A (en) | 2007-01-18 |
Family
ID=37750018
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2005190002A Pending JP2007011586A (en) | 2005-06-29 | 2005-06-29 | Method for managing message resource for software |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2007011586A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010079400A (en) * | 2008-09-24 | 2010-04-08 | Hitachi Information Systems Ltd | System, method and program for property file reading |
US7698688B2 (en) | 2008-03-28 | 2010-04-13 | International Business Machines Corporation | Method for automating an internationalization test in a multilingual web application |
-
2005
- 2005-06-29 JP JP2005190002A patent/JP2007011586A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7698688B2 (en) | 2008-03-28 | 2010-04-13 | International Business Machines Corporation | Method for automating an internationalization test in a multilingual web application |
JP2010079400A (en) * | 2008-09-24 | 2010-04-08 | Hitachi Information Systems Ltd | System, method and program for property file reading |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10795799B2 (en) | Website debugger for natural language translation and localization | |
US8370798B2 (en) | Analytical software design system | |
US8060791B2 (en) | Annotating GUI test automation playback and debugging | |
US6055369A (en) | Apparatus for visual programming with screen flow | |
US8042091B2 (en) | Automatic composition of model transformations | |
US20050240555A1 (en) | Interactive electronic technical manual system integrated with the system under test | |
US20070027670A1 (en) | User Interface Update System | |
JP4613214B2 (en) | Software automatic configuration device | |
US8955115B2 (en) | Automatic generation of security checks | |
JPWO2004104824A1 (en) | User interface application development device and development method | |
JP2009176064A (en) | Software refactoring support device and method | |
JP2007011586A (en) | Method for managing message resource for software | |
US20090288066A1 (en) | Editing apparatus and method for test driven development | |
US20080281850A1 (en) | System and Methods for Generating Runtime Messages | |
JP2008293382A (en) | Automatic test specification generation system | |
JP5119765B2 (en) | Specification creation support apparatus and support method | |
WO2023277802A2 (en) | Device and method for identifying errors in a software application | |
JP6097231B2 (en) | Program generating apparatus and method | |
JP5539921B2 (en) | Program development tools | |
JPH11224211A (en) | Software inspection support device | |
Fraser | Integrating VDM-SL into the continuous delivery pipelines of cloud-based software | |
US11733847B2 (en) | Knowledge engine auto-generation of guided flow experience | |
JP2006243996A (en) | Job network management system | |
JP2021174084A (en) | Test automatizing device | |
JP2004213488A (en) | Data consistency checking device and data consistency checking method |