Package ilog.rules.brl.value.descriptor

Value descriptors are a BRL mechanism designed to manage literal values in the BRL framework.

See: Description

Package ilog.rules.brl.value.descriptor Description

Value descriptors are a BRL mechanism designed to manage literal values in the BRL framework.

Overview

A value descriptor enables you to describe a value so that all values of this type are displayed and edited in the same way. You declare a value descriptor if you want to apply value management to a BOM class. You can create a completely new value descriptor, or create one by reusing a predefined value descriptor.

A value descriptor enables you to:
  • represent the value as a parsable, locale-specific regular expression. The representation must provide a unique textual description of the value and cannot be used by more than one value descriptor
  • provide a persistent text form (locale-independent) and a localized text form for the value
  • define a default value for the value
  • check the value if entered manually, and report an error
  • transform the text representation of the value into or from an object representation

The value descriptors in this package are associated to concepts and provide the API to manipulate literal values of the type. For instance, a value descriptor provides a parsable representation of the value to be used by a BRL parser to parse literal values.

Predefined value descriptors

You can use the following predefined value descriptors:

The most common way to reuse a predefined value descriptor is to use a decorated value descriptor. For example, if you want to use the number value descriptor to describe a percentage, you 'decorate' it by adding % as a suffix in the label of the number value descriptor.

Integrating value descriptors

When you have created a value descriptor, you should then integrate it into Rule Designer, Rule Team Server or Rule Solutions for Office, as appropriate. For more information, see Customizing JRules > Customizing Rule Authoring > Tasks > Managing BOM value types > Implementing a value descriptor > Integrating a value descriptor.

Code Example

The following code example shows a custom value descriptor:

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
    }
 }
Since:
JRules 6.0
Rule Designer API

© Copyright IBM Corp. 1987, 2017