Create your own Extension

Create your own Extension

Overview

This article will show how to develop an Andi Extension based on the included FirstExtension Eclipse project and the the andiExtensionsApi-xxx.jar extension API (Application Programming Interface) jar. If you haven't setup your Eclipse project and configured your Java 1.8 runtime, you can do so below.

Configure Eclipse for Andi Extension Development

Extension Overview

The FirstExtension project includes two files that make up an Andi Extension. The extension is provided to give you a quick start in creating your own extension.

  • *Verifications - The extension which extends AbstractFileViewColumnVerifier and implements the business logic and necessary additional logic to interface with the Andi extensionRegistry

  • *VerificationId - A Java Enum which provides all of the messages and message IDs that will be used by your extension(s)

image-20250906-150722.png

Extension Constructor

The extension is broken down into the following:

  • Registers all functions supported by the extension by add the information to the Map included. The key to the Map is the function name which must be unique and provides an easy to remember name that describes the function behavior.

  • You add a Function instance to document one or more parameters that can be passed to the extension and the description that provides details on how to use the function. This information will be available to users using the extensionRegistry.getExtensionDetails() and getExtensionDetails(<extensionId>) methods. 

  • The last line of the constructor registers the extension with the Andi extensionRegistry. This allow you to do register the jar and then execute new SampleVerifications() in the script and it will automatically be registered.

public SampleVerifications() { functions.put( "verifyAlpha", new Function( Arrays.asList( "required" ), "Verify alpha (a-z) upper or lower case characters only, Options: (required) if the value is required" ) ); functions.put( "verifyUpperCase", new Function( Arrays.asList( "required" ), "Convert case to upper Options: (required) if the value is required" ) ); ExtensionRegistryFactory.getExtensionRegistry().register(this); }

Developer Information

The two methods below are critical and must uniquely define your plugin. The names will be combined to create a unique ID for your extension. If another extension is already loaded with that ID, your extension will not be loaded.

  • getDeveloper - Update "companyName" to a name that specifies your company or other identifier.

  • getExtension - A unique name for your extension. This might be the name of the customer the extensions are being built for or a general name to categorize a specific set of functions.

  • getFunctions - This method is used by the extensionRegistry

/** * The name of your company or other unique developer name */ @Override public String getDeveloper( ) { return "companyName"; } /** * The name of the extension. */ @Override public String getExtensionName( ) { return "sampleExtension"; } /** * {@inheritDoc} */ @Override public Map<String, Function> getFunctions( ) { return functions; }

Extension

The last method provides the extension implementation for your functions.

 

/** * Use a simple switch to branch for each included function. Throw one of the following exceptions when appropriate. * - A code error occurred and the program should abort * validationException - A data error was found, the ValidationException allows the script to continue if running in * validation mode. */ @Override public String verify( String function, int rowIndex, int columnIndex, GridTable table, String value, List

Licensing

An Andi Professional Plus license allows you to have one custom plugin registered at a time. To have more than one plugin, you must purchase and register the Scripting Extension feature. This can be purchased by contacting Andi support staff at www.andiware.com Contact Us.