Community articleHolder objects
Added by IBM contributorIBM on May 2, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Many methods in the API require one or more Holder objects as parameters.

Because Java™ does not support output parameters, methods are normally limited to returning a single value. However, in many cases it is useful to return multiple values from a single method. In these cases, the API uses Holder objects. Holder objects contain a single member variable called value. Holder objects have no methods.

Holder objects are objects that are created with a single variable. These objects can then be passed into a method that sets that variable. When the method returns, the value of variable can be retrieved.

Holder types

The following table lists the holder types that are available, the data type of each holder's variable, and the class that you must import to use the holder:

Table 1. Holder objects and data types
HolderData TypeClass
ShortListHolderShort [ ]com.PureEdge.ShortListHolder
StringListHolderString [ ]com.PureEdge.StringListHolder

Note: Some methods in the FCI library require an IFSUserDataHolder as a parameter, but you do not need to manipulate this object.

Holder constructors

Each Holder class provides two constructors.
  • An empty constructor that creates an object and declares an empty member variable called value. For example, to create an empty IntHolder use the following constructor:
  • IntHolder myInt = new IntHolder();

  • A constructor that creates an object, declares a variable called value, and sets the value of the variable. For example, to create an IntHolder object with a value of 5, use the following constructor:
  • IntHolder myInt = new IntHolder(5);

Getting and setting values of Holder objects

To get or set the value of a particular Holder object, dereference the holder's value. For example:

   int value = myIntHolder.value;
   myIntHolder.value = 2;

Parent topic: Java API