Yes, of course. You can use j8583 in Groovy just as you would use any other Java library. However, some j8583 classes have certain methods in them written specifically for usage within Groovy.
In Java, you can deal with values in an IsoMessage like this:
message.setValue(32, "Some value", IsoType.LLVAR, 0); IsoValue isoValue = message.getField(32); String value = (String)message.getObjectValue(32); Object value2 = message.getField(32).getValue();
In Groovy you can do the same like this
message[32] = IsoType.LLVAR("Some value") message[7] = IsoType.DATE10(new Date()) message[41] = IsoType.ALPHA("Term", 16) message[11] = IsoType.NUMERIC(123, 6) IsoValue isoValue = message[32] def value = message[32]?.value
This is because the IsoMessage class has get getAt() and putAt() methods that work similar to getField() and setField, and the IsoType class has two call() methods, with and without length, which return IsoValue instances with the proper type and length. The variant that has a length parameter must be used with NUMERIC and ALPHA types, and the other types can use the variant without length.
In a similar fashion, you can use a shorter notation in Scala to set and get fields:
message(32) = IsoType.LLVAR("Some value") message(7) = IsoType.DATE10(new Date()) message(41) = IsoType.ALPHA("Term", 16) message(11) = IsoType.NUMERIC(123, 6) val v1:String = message(32).getValue val v2:String = message.getObjectValue(32)
This is because IsoMessage also implements the apply() and update() methods that work similarly to getField() and setField(). Also, IsoType now implements apply() so that you can create IsoValues from IsoTypes.
In any language, you can use the builder pattern, since now the setValue and setField methods return the message itself:
message.setValue(4, amount, IsoType.AMOUNT, 12) .setValue(7, new Date(), IsoType.DATE, 10) .setValue(11, trace, IsoType.NUMERIC, 6);
Of course it can be more succint in Groovy or Scala:
message.setField(4, IsoType.AMOUNT(amount)) .setField(7, IsoType.DATE(new Date())) .setField(11, IsoType.NUMERIC(trace, 6))