Rule Builder > Business Object Models > Exporting and Importing BOMs > Using the Java-like BOM Syntax

A .bom file exported from the Rule Builder resembles a Java file. However, although the syntax of this file is very similar to the Java language, it differs from Java in several ways.

Notes
  1. The java.lang.String is automatically defined in the default BOM provided in the Rule Builder.
  2. The Java syntax for comments can be used in BOM files.

The BOM Java-like syntax also supports additional features that do not exist in the Java language: properties, enumerated domains, and native classes. It differs from Java on the use of the import clause. Also, the requirement that a BOM file must be fully self-contained can be removed in some cases.

This section has the following subsections:

Properties

The property keyword adds properties (user-defined or other) to BOM elements. Properties are set on BOM elements using the Property Sheet in the Rule Builder. The value of a property can either be a character string or a structure with nested properties. Here is an example:

public class ShoppingCart
property category "Online store "
{
public int itemCount
property visible "true"
property system "false"
property range { min "0", max "10" };
}

The property keyword is used here to add a user-defined property to the ShoppingCart class and three properties to the attribute. The range property of the itemCount attribute is a structured property that contains two nested properties.

The property clause has either the following syntax:

property propertyName stringLiteral

or, for structured properties:

property propertyName { propertyName stringLiteral, ...}

Domains

The domain keyword specifies an enumerated domain of a class. Enumerated domains can be added to a class using the BOM editing facilities provided in the BOM Explorer, BOM Graphical Editor, or the Class Editor. Here is an example of what an enumerated domain looks like in a .bom file:

public class State {
domain {
Start = "State.getStartState()",
Running = "State.getRunningState()",
Wait = "State.getWaitState()",
Zombie = "State.getZombieState()"
}
public String getName();
public boolean precedes(State otherState);
}

In this example, the domain list provides a set of labels (Start, Running, Wait, and Zombie) to denote the possible instances of the class. The domain labels are called static references in the BOM vocabulary because they refer to entities that are statically computed at run-time or that can be constants.

The string to the right of the equals symbol following each label contains an executable Java expression that computes the value of the corresponding domain element at run-time.

Native Class Modifiers

The native keyword specifies that the BOM class originates from a Java class. The native keyword can be used as a modifier in class declarations, as in the following example:

public class Item {
public java.lang.String productName;
public int quantity;
public double getTotalPrice();
}
package java.lang;
public native class String
{}

Import Clause

The BOM syntax does not support wildcards in the import clause. Consequently, each reference to a class or an enumeration must be fully qualified using the appropriate package prefix, or there must be a prior import clause defined for that class. Here is an example:

import java.lang.String;
public class Person {
public String name;
}
package java.lang;
public class String
{}

See Also

Working With the BOM Explorer | Adding Elements to a BOM | Working With the BOM Property Sheet | Working With the Property Sheet | Updating or Merging BOMs


Customer Support | Copyright © 1987-2004 ILOG S.A. All rights reserved. Legal terms. PREVIOUS   NEXT