@Test public void testPackThrowsISOException1() throws Throwable { try { new EuroSubFieldPackager().pack(new ISOMsg("testEuroSubFieldPackagerMti")); fail("Expected ISOException to be thrown"); } catch (ISOException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertEquals("java.lang.NullPointerException", ex.getMessage(), "ex.getMessage()"); assertNull(ex.getNested().getMessage(), "ex.getNested().getMessage()"); } else { assertEquals("java.lang.NullPointerException: Cannot load from object array because \"this.fld\" is null", ex.getMessage(), "ex.getMessage()"); assertEquals("Cannot load from object array because \"this.fld\" is null", ex.getNested().getMessage(), "ex.getNested().getMessage()"); } } }
@Override public byte[] pack (ISOComponent c) throws ISOException { LogEvent evt = new LogEvent (this, "pack"); try (ByteArrayOutputStream bout = new ByteArrayOutputStream(100)) { Map tab = c.getChildren(); for (Entry ent : (Set<Entry>) tab.entrySet()) { Integer i = (Integer) ent.getKey(); if (i < 0) continue; if (fld[i] == null) throw new ISOException ("Unsupported sub-field " + i + " packing field " + c.getKey()); if (ent.getValue() instanceof ISOComponent) try { ISOComponent f = (ISOComponent) ent.getValue(); byte[] b = fld[i].pack(f); bout.write(b); } catch (Exception e) { evt.addMessage ("error packing subfield "+i); evt.addMessage (c); evt.addMessage (e); throw e; } } byte[] d = bout.toByteArray(); if (logger != null) evt.addMessage (ISOUtil.hexString (d)); return d; } catch (Exception ex) { throw new ISOException (ex); } }
EuroSubFieldPackager extends ISOBasePackager { @Override public byte[] pack (ISOComponent c) throws ISOException { LogEvent evt = new LogEvent (this, "pack"); try (ByteArrayOutputStream bout = new ByteArrayOutputStream(100)) { Map tab = c.getChildren(); for (Entry ent : (Set<Entry>) tab.entrySet()) { Integer i = (Integer) ent.getKey(); if (i < 0) continue; if (fld[i] == null) throw new ISOException ("Unsupported sub-field " + i + " packing field " + c.getKey()); if (ent.getValue() instanceof ISOComponent) try { ISOComponent f = (ISOComponent) ent.getValue(); byte[] b = fld[i].pack(f); bout.write(b); } catch (Exception e) { evt.addMessage ("error packing subfield "+i); evt.addMessage (c); evt.addMessage (e); throw e; } } byte[] d = bout.toByteArray(); if (logger != null) evt.addMessage (ISOUtil.hexString (d)); return d; } catch (Exception ex) { throw new ISOException (ex); } } }
EuroSubFieldPackager extends ISOBasePackager { @Override public byte[] pack (ISOComponent c) throws ISOException { LogEvent evt = new LogEvent (this, "pack"); try (ByteArrayOutputStream bout = new ByteArrayOutputStream(100)) { Map tab = c.getChildren(); for (Entry ent : (Set<Entry>) tab.entrySet()) { Integer i = (Integer) ent.getKey(); if (i < 0) continue; if (fld[i] == null) throw new ISOException ("Unsupported sub-field " + i + " packing field " + c.getKey()); if (ent.getValue() instanceof ISOComponent) try { ISOComponent f = (ISOComponent) ent.getValue(); byte[] b = fld[i].pack(f); bout.write(b); } catch (Exception e) { evt.addMessage ("error packing subfield "+i); evt.addMessage (c); evt.addMessage (e); throw e; } } byte[] d = bout.toByteArray(); if (logger != null) evt.addMessage (ISOUtil.hexString (d)); return d; } catch (Exception ex) { throw new ISOException (ex); } }  }
EuroSubFieldPackager extends ISOBasePackager { @Override public byte[] pack (ISOComponent c) throws ISOException { LogEvent evt = new LogEvent (this, "pack"); try (ByteArrayOutputStream bout = new ByteArrayOutputStream(100)) { Map tab = c.getChildren(); for (Entry ent : (Set<Entry>) tab.entrySet()) { Integer i = (Integer) ent.getKey(); if (i < 0) continue; if (fld[i] == null) throw new ISOException ("Unsupported sub-field " + i + " packing field " + c.getKey()); if (ent.getValue() instanceof ISOComponent) try { ISOComponent f = (ISOComponent) ent.getValue(); byte[] b = fld[i].pack(f); bout.write(b); } catch (Exception e) { evt.addMessage ("error packing subfield "+i); evt.addMessage (c); evt.addMessage (e); throw e; } } byte[] d = bout.toByteArray(); if (logger != null) evt.addMessage (ISOUtil.hexString (d)); return d; } catch (Exception ex) { throw new ISOException (ex); } }  @Override byte[] pack(ISOComponent c); @Override int unpack(ISOComponent m, byte[] b); }
EuroSubFieldPackager extends ISOBasePackager { @Override public byte[] pack (ISOComponent c) throws ISOException { LogEvent evt = new LogEvent (this, "pack"); try (ByteArrayOutputStream bout = new ByteArrayOutputStream(100)) { Map tab = c.getChildren(); for (Entry ent : (Set<Entry>) tab.entrySet()) { Integer i = (Integer) ent.getKey(); if (i < 0) continue; if (fld[i] == null) throw new ISOException ("Unsupported sub-field " + i + " packing field " + c.getKey()); if (ent.getValue() instanceof ISOComponent) try { ISOComponent f = (ISOComponent) ent.getValue(); byte[] b = fld[i].pack(f); bout.write(b); } catch (Exception e) { evt.addMessage ("error packing subfield "+i); evt.addMessage (c); evt.addMessage (e); throw e; } } byte[] d = bout.toByteArray(); if (logger != null) evt.addMessage (ISOUtil.hexString (d)); return d; } catch (Exception ex) { throw new ISOException (ex); } }  @Override byte[] pack(ISOComponent c); @Override int unpack(ISOComponent m, byte[] b);  }