@Test public void testUnpackThrowsNullPointerException() throws Throwable { byte[] b = new byte[3]; try { new EuroSubFieldPackager().unpack(new ISOBinaryField(100), b); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot load from object array because \"this.fld\" is null", ex.getMessage(), "ex.getMessage()"); } } }
@Override public int unpack (ISOComponent m, byte[] b) throws ISOException { LogEvent evt = new LogEvent (this, "unpack"); int consumed = 0; ISOComponent c = null; while (consumed < b.length) { int i = c == null && fld[0] != null ? 0 : tagPrefixer.decodeLength(b, consumed); if (i >= fld.length || fld[i] == null) throw new ISOException("Unsupported sub-field " + i + " unpacking field " + m.getKey()); c = fld[i].createComponent(i); consumed += fld[i].unpack (c, b, consumed); if (logger != null) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; }
EuroSubFieldPackager extends ISOBasePackager { @Override public int unpack (ISOComponent m, byte[] b) throws ISOException { LogEvent evt = new LogEvent (this, "unpack"); int consumed = 0; ISOComponent c = null; while (consumed < b.length) { int i = c == null && fld[0] != null ? 0 : tagPrefixer.decodeLength(b, consumed); if (i >= fld.length || fld[i] == null) throw new ISOException("Unsupported sub-field " + i + " unpacking field " + m.getKey()); c = fld[i].createComponent(i); consumed += fld[i].unpack (c, b, consumed); if (logger != null) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; } }
EuroSubFieldPackager extends ISOBasePackager { @Override public int unpack (ISOComponent m, byte[] b) throws ISOException { LogEvent evt = new LogEvent (this, "unpack"); int consumed = 0; ISOComponent c = null; while (consumed < b.length) { int i = c == null && fld[0] != null ? 0 : tagPrefixer.decodeLength(b, consumed); if (i >= fld.length || fld[i] == null) throw new ISOException("Unsupported sub-field " + i + " unpacking field " + m.getKey()); c = fld[i].createComponent(i); consumed += fld[i].unpack (c, b, consumed); if (logger != null) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; }  }
EuroSubFieldPackager extends ISOBasePackager { @Override public int unpack (ISOComponent m, byte[] b) throws ISOException { LogEvent evt = new LogEvent (this, "unpack"); int consumed = 0; ISOComponent c = null; while (consumed < b.length) { int i = c == null && fld[0] != null ? 0 : tagPrefixer.decodeLength(b, consumed); if (i >= fld.length || fld[i] == null) throw new ISOException("Unsupported sub-field " + i + " unpacking field " + m.getKey()); c = fld[i].createComponent(i); consumed += fld[i].unpack (c, b, consumed); if (logger != null) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; }  @Override byte[] pack(ISOComponent c); @Override int unpack(ISOComponent m, byte[] b); }
EuroSubFieldPackager extends ISOBasePackager { @Override public int unpack (ISOComponent m, byte[] b) throws ISOException { LogEvent evt = new LogEvent (this, "unpack"); int consumed = 0; ISOComponent c = null; while (consumed < b.length) { int i = c == null && fld[0] != null ? 0 : tagPrefixer.decodeLength(b, consumed); if (i >= fld.length || fld[i] == null) throw new ISOException("Unsupported sub-field " + i + " unpacking field " + m.getKey()); c = fld[i].createComponent(i); consumed += fld[i].unpack (c, b, consumed); if (logger != null) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; }  @Override byte[] pack(ISOComponent c); @Override int unpack(ISOComponent m, byte[] b);  }