Interfaces supporting custom functions

Several interfaces that support custom functions are available to you when you configure your custom functions.

You can find information about the interfaces that contain methods that can be used when you write custom functions especially when you use them to manipulate tags in Rational® Integration Tester.

Interface

Methods

Result

TagDefaults

public void resetValue (String name)

Resets the value of a given tag (if it exists) to the previously specified default value.

TagInspector

public Iterable<String> getTagNames()

public Iterable<String> getTagNames()

Returns an Iterator over all the currently available tag names.

Returns the value of a tag (if it exists) when the name is provided.

TagStorer

public boolean setTagValue(String tagName, Object tagValue)

Sets the value of a tag when the name and the corresponding value are provided.

CursorProvider

public Cursor getCursor(String dataSetPath)

Returns a Cursor object (if it exists) when the path is provided. The Cursor object provides access to the underlying data from the dataset.

DbConnectionPoolProvider

public DbConnectionPool getDbConnectionPoolFromLogicalPath(String dbServerPath)

Returns a DbConnectionPool object (if it exists) when the path of a logical resource is provided.

The following example describes how you can use the interfaces in your custom functions. In this example, a custom function is created that returns the value of a tag when the tag name is provided. You can observe how objects can be cast to the necessary interface so that the methods of that interface are used.

You must consider this along with the example provided for the formatDate example so that you can get to know more about how you can create custom functions. See The formatDate example for a custom function.

import java.util.Vector;
import com.ghc.ghTester.expressions.Function;
import com.ghc.ghTester.expressions.TagInspector;

public class TagReader extends Function {	

		/**
		* This function will return the name of the tag that we wish to read as a String.
		*/
		private Function tag;	
	
		public TagReader () {}	
	
		public TagReader(Function f1) {		
			tag = f1;			
		}

		@Override
		public Function create(int size, Vector params) {				
			return new TagReader((Function)params.get(0));		
		}


		/*
	 	* The 'evaluate' method should be implemented by subclasses of
	 	* Function. This method performs the actual work of the function.
	 	*/
		@Override
		public Object evaluate(Object data) {
			String tagName = tag.evaluateAsString(data);			
			return ((TagInspector) data).getTagValue(tagName);	
		}
}