skip to main content
Corticon Extensions Guide : Creating custom extended operators

Try Corticon Now

Creating custom extended operators

Note: Corticon Studio is built on Eclipse which provides a Java development environment you can use for creating Corticon extensions that you can use in current and future versions of Corticon. If you want to create extensions in a separate IDE, you must use Java 1.7.0_05 or higher.
Note: You might want to simply copy the sample project Extended Operator Java Project, and then tweak a sample such as by renaming the TopLevelFolder to mySampleExtendedOperators for your first run. You can then go ahead to Building the Java classes and JARs.
For many developers, the quickest way to learn is by example. You might want to compare the three Java source files in the Extended Operator Java Project to see what is common and what changes. In this example, the is presented.
1. Specify the imports and interfaces you will need.
package com.corticon.samples.extensions;

import java.util.Calendar;
import java.util.Date;

This class imports the Corticon ICcStringExtension and ICcDateTimeExtension interfaces because it will implement extended operators for String and DateTime attributes. The other Corticon imports are for the annotations which will be used to describe the extensions.
2. Enter your comments that describe the class.
* This class provides sample Corticon stand-alone extended operators.
* Extended operators are a means to add custom features to Corticon for
* use in Corticon rules.
* The samples in this class provide simple operators for calculating the
* present and future value of an investment for a number of years at a given
* interest rate.
A general description of this source file is always good coding practice. It has no use outside of the source file.
3. Specify the TopLevelFolder name.
@TopLevelFolder("Sample Extended Operators")
The TopLevelFolder annotation identifies the folder that will group the extended operators on the Rule Operators tab in Corticon Studio. You can name the folder to fit your needs, such as "My Operators", or "Financial Operators".
4. Specify the class and its implementations.
public class AttributeOperators implements ICcStringExtension, ICcDateTimeExtension {
5. Name your operator folder, and use the locale parameters if appropriate.
@OperatorFolder(lang = { "en" }, values = { "Date" })
The OperatorFolder defines the subfolder that will list an individual operator within the TopLevelFolder on the Rule Operators tab in Corticon Studio. You can organize and name folders to fit your needs.
6. Add your description of the operator, and use the locale parameters if appropriate..
@Description(lang = { "en" }, values = { "Returns true if the date is in a leap year." })
The Description annotation describes the specific operator. The hover help reveals what is passed, what is returned, and description text for the locale.
7. Write your actual implementation of the extended operator. It is always public static.
public static Boolean isLeapYear(Date d) {
if (d == null)
return null;

Calendar c = Calendar.getInstance();

int year = c.get(Calendar.YEAR);
if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))
return true;
return false;
The example takes a date and returns a boolean. It is up to you to determine that this produces the result you want, and that you can verify it across a range of values and error conditions.
8. The sample includes another operator definition using the same structure, this one for the String OperatorFolder. You can similarly change this section, or just cut the whole section out.
* Replaces all occurrences of a substring in a string with another string.
* @param s A string.
* @param searchString The substring to look for in s.
* @param replacement The string to replace it with.
* @return The original string with all instances of searchString replace by
* replacement.
@OperatorFolder(lang = { "en" }, values = { "String" })
@Description(lang = { "en" }, values = { "Replace all occurrences of a substring within a string with another string." })
public static String replaceAll(String s,
@ArgumentName(lang = { "en" }, values = { "searchString" }) String searchString,
@ArgumentName(lang = { "en" }, values = { "replacement" }) String replacement) {
if (s == null)
return null;

if (searchString == null)
return s;

String r = s.replaceAll(searchString, replacement);
return r;
9. Save your work, and then go ahead to Building the Java classes and JARs.
Note: Compatibility of extensions created in an earlier release, any extension operators and service callouts that are in extended.core.jar are shared across all Rule Projects. As a result, such extensions are always in the Rule Operator tab in every editor. Then, you can add your extended operators and service callouts to specific Rule Projects using the new mechanism.