Skip to content

Commit

Permalink
Enable handling of complex field
Browse files Browse the repository at this point in the history
  • Loading branch information
cyao136 authored and ar committed Jan 23, 2024
1 parent 16c7a12 commit d7ebd51
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions jpos/src/main/java/org/jpos/iso/ISOTagStringFieldPackager.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,16 @@ private String makeExceptionMessage(ISOComponent c, String operation) {
*/
public byte[] pack(ISOComponent c) throws ISOException {
try{
String data = (String)c.getValue();
String data;
if(c.getValue() instanceof byte[])
data = new String(c.getBytes(), ISOUtil.CHARSET); // transparent handling of complex fields
else
data = (String)c.getValue();

if (data.length() > getLength())
{
throw new ISOException("Field length " + data.length() + " too long. Max: " + getLength());

}
int tag = (Integer)c.getKey();
String paddedData = padder.pad(data, getLength());
byte[] rawData = new byte[tagPrefixer.getPackedLength()+prefixer.getPackedLength()
Expand Down

0 comments on commit d7ebd51

Please sign in to comment.