import

The import keyword imports a Java™ class or package into a rule file.

Purpose

This statement is used to specify which Java classes a ruleset uses.

Context

At the top level of rulesets

Syntax

import [packageName
.] className |packageName
.*; 

Description

The import declarations must be the first statements in a rule file. Import statements are not mandatory, but when present, they are always placed at the beginning of the rule file, before the ruleset header. After it is imported, the class or package is accessible from the rules. The scope of the import declarations is the ruleset file.

It is possible to import a specific class or an entire package.

For some Java packages, the import declaration is implicit.

import java.lang.*;
import ilog.rules.engine.*;

The rule interpreter adds these packages automatically, therefore you do not need to import any classes from these packages explicitly.

Example

If you declare the following imports:

import java.util.*;
import userPackage.UserClass;

the rule interpreter reads:

import java.lang.*;
import ilog.rules.engine.*;
import java.util.*;
import userPackage.UserClass; 

Here are some examples of class names that might be used as a result of the two imports above:

Class Name Qualified Class Name
Vector java.util.Vector
java.util.Vector java.util.Vector
UserClass userPackage.UseClass
Number java.lang.Number
IlrRule ilog.rules.engine.IlrRule