Generic Variable

Create a generic variable with an optionally fixed length. This variable can act as a String, Byte, Boolean, and a number of other types and provides utility methods such as subtraction, division, multiplication, splits, etc. It also holds a rounding mode simplifying rounding operations when dealing with numbers.


Using this components with the default values gives you:

GenericType var1 = new GenericType("", "*System", BigDecimal.ROUND_HALF_UP, false, 0, "", false);

This is now as generic as it could be. You can now set the value.

For a boolean:


For a long:


For a String:

var1.set("Some string");

Get the value

Depending on what type you wish to get a number of methods are available.

To get a boolean:

boolean bol = var1.toBoolean();

To get a long:

long length = var1.toLong();

To get a String:

String text = var1.toString();

When using any of these to methods the variable tries to convert the value it holds to the type you are asking to get, this might not always be possible for obvious reasons.

Working with fixed length Strings

To have the variable be of a fixed length check the Fixed length format, enter how long the variable should be in the Length field and type in the padding characters in the Padding string field (you can also select a String variable if you wish). If you leave this field empty an empty space will be used as padding. You will get something like this:

GenericType var1 = new GenericType("", "*System", BigDecimal.ROUND_HALF_UP, true, 20, "-", false);

Note: In the sample above we're using a minus sign ("-") as the padding character.

Right adjust

With this option the variable will treat the String backwards, i.e. all trimming and padding will be done from the end of the String.

How to get the raw value

If you need to get the value of the variable as it currently is (without any output formatting).

For numbers (represented as BigDecimal):

BigDecimal value = var1.getNumericValue();

For String values:

String value = var1.getStringValue();

Is the variable a String

When you need to know if the variable holds a value of type String use:

boolean isString = var1.isString();