Rule Builder > Business Object Models > Exporting and Importing BOMs > Using the Java-like BOM Syntax |
Using the Java-like BOM Syntax |
PREVIOUS NEXT |
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.
.bom
). This contrasts with Java, where each public class or interface is written in a distinct file.
import
clause.
// The ShoppingCart class
public class ShoppingCart {
public int itemCount;
public Item getItem(int index);
}
/* The Item class */
public class Item {
public java.lang.String productName;
public int quantity;
public double getTotalPrice();
}
package java.lang;
public class String
{}
Notes |
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:
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 |
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, ...} |
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:
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.
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 { |
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; |
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 |