例: 色値記述子の作成
色を表す値タイプの場合は、色値記述子を定義します。
このタスクについて
BOM クラス sample.Color を色を表す値タイプとして使用する場合は、色値記述子を定義する必要があります。
手順
色値記述子を定義するには、以下のようにします。
- IlrAbstractValueDescriptor クラスを拡張します。
class ValueColorDescriptor extends IlrAbstractValueDescriptor { public ValueColorDescriptor(Concept concept) { super(concept); } { // Checks the value (but here no check is needed) public boolean checkValue(IlrSyntaxTree.Node node, Object value) { return true; } // Converts the persistent text form of the value to an instance of Color public Object getValue(String persistentText) { return Color.decode(persistentText); } // Converts the instance of Color into a persistent text form public String getPersistentText(Object value) { return '#' + Integer.toHexString(((Color) value).getRGB()); } //Converts the localized text form of the value into an instance of Color public Object getValue(String text, IlrBRLDefinition definition) { return Color.decode(text); // Here the text form is not locale dependent } // Converts the instance of Color into a localized text form public String getLocalizedText(Object value, IlrBRLDefinition definition) { return '#' + Integer.toHexString(((Color) value).getRGB()); // Here the text form is still not locale dependent } // Returns the default value in a localized text form public String getDefaultValue(IlrBRLDefinition definition) { return "#000000"; // By default, returns the value black } } - このクラスでカスタム・プロパティー valueDescriptor を定義することによって、BOM クラス sample.Color に値記述子を付加します。
valueDescriptor = sample.valueDescriptor.Color - 解析可能な値の表現を指定します。
そのためには、BOM エディターで sample.Color クラスにカスタム・プロパティー valueDescriptor.parsableRepresentation を追加し、それに以下の値を指定します。
#[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F] - 以下のパラメーターを使用して拡張ポイント ilog.rules.studio.model.brl.valueDescriptors を宣言することで、値記述子を Rule Designer に統合します。
ID: sample.valueDescriptor.Color
キー: sample.valueDescriptor.Color
クラス: sample.ValueColorDescriptor
タスクの結果
Rule Designer で色値記述子を使用できるようになりました。