@Test public void testUnpackThrowsISOException5() throws Throwable { byte[] b = new byte[2]; try { new GenericSubFieldPackager().unpack(new ISOBinaryField(), b); fail("Expected ISOException to be thrown"); } catch (ISOException ex) { assertEquals("Can't call packager on non Composite", ex.getMessage(), "ex.getMessage()"); assertNull(ex.getNested(), "ex.getNested()"); } }
@Override public int unpack (ISOComponent m, byte[] b) throws ISOException { LogEvent evt = new LogEvent (this, "unpack"); try { if (m.getComposite() != m) throw new ISOException ("Can't call packager on non Composite"); if (b.length == 0) return 0; if (logger != null) evt.addMessage (ISOUtil.hexString (b)); int consumed=0; ISOBitMap bitmap = new ISOBitMap (-1); BitSet bmap = null; int maxField = fld.length; if (emitBitMap()) { consumed += getBitMapfieldPackager().unpack(bitmap,b,consumed); bmap = (BitSet) bitmap.getValue(); m.set (bitmap); maxField = bmap.size(); } for (int i=getFirstField(); i<maxField && consumed < b.length; i++) { if ((bmap == null || bmap.get(i)) && i<fld.length && fld[i] != null) { ISOComponent c = fld[i].createComponent(i); consumed += fld[i].unpack (c, b, consumed); m.set(c); } } if (b.length != consumed) { evt.addMessage ( "WARNING: unpack len=" +b.length +" consumed=" +consumed); } return consumed; } catch (ISOException e) { evt.addMessage (e); throw e; } catch (Exception e) { evt.addMessage (e); throw new ISOException (e); } finally { Logger.log (evt); } }
GenericSubFieldPackager extends GenericPackager implements ISOSubFieldPackager { @Override public int unpack (ISOComponent m, byte[] b) throws ISOException { LogEvent evt = new LogEvent (this, "unpack"); try { if (m.getComposite() != m) throw new ISOException ("Can't call packager on non Composite"); if (b.length == 0) return 0; if (logger != null) evt.addMessage (ISOUtil.hexString (b)); int consumed=0; ISOBitMap bitmap = new ISOBitMap (-1); BitSet bmap = null; int maxField = fld.length; if (emitBitMap()) { consumed += getBitMapfieldPackager().unpack(bitmap,b,consumed); bmap = (BitSet) bitmap.getValue(); m.set (bitmap); maxField = bmap.size(); } for (int i=getFirstField(); i<maxField && consumed < b.length; i++) { if ((bmap == null || bmap.get(i)) && i<fld.length && fld[i] != null) { ISOComponent c = fld[i].createComponent(i); consumed += fld[i].unpack (c, b, consumed); m.set(c); } } if (b.length != consumed) { evt.addMessage ( "WARNING: unpack len=" +b.length +" consumed=" +consumed); } return consumed; } catch (ISOException e) { evt.addMessage (e); throw e; } catch (Exception e) { evt.addMessage (e); throw new ISOException (e); } finally { Logger.log (evt); } } }
GenericSubFieldPackager extends GenericPackager implements ISOSubFieldPackager { @Override public int unpack (ISOComponent m, byte[] b) throws ISOException { LogEvent evt = new LogEvent (this, "unpack"); try { if (m.getComposite() != m) throw new ISOException ("Can't call packager on non Composite"); if (b.length == 0) return 0; if (logger != null) evt.addMessage (ISOUtil.hexString (b)); int consumed=0; ISOBitMap bitmap = new ISOBitMap (-1); BitSet bmap = null; int maxField = fld.length; if (emitBitMap()) { consumed += getBitMapfieldPackager().unpack(bitmap,b,consumed); bmap = (BitSet) bitmap.getValue(); m.set (bitmap); maxField = bmap.size(); } for (int i=getFirstField(); i<maxField && consumed < b.length; i++) { if ((bmap == null || bmap.get(i)) && i<fld.length && fld[i] != null) { ISOComponent c = fld[i].createComponent(i); consumed += fld[i].unpack (c, b, consumed); m.set(c); } } if (b.length != consumed) { evt.addMessage ( "WARNING: unpack len=" +b.length +" consumed=" +consumed); } return consumed; } catch (ISOException e) { evt.addMessage (e); throw e; } catch (Exception e) { evt.addMessage (e); throw new ISOException (e); } finally { Logger.log (evt); } } GenericSubFieldPackager(); }
GenericSubFieldPackager extends GenericPackager implements ISOSubFieldPackager { @Override public int unpack (ISOComponent m, byte[] b) throws ISOException { LogEvent evt = new LogEvent (this, "unpack"); try { if (m.getComposite() != m) throw new ISOException ("Can't call packager on non Composite"); if (b.length == 0) return 0; if (logger != null) evt.addMessage (ISOUtil.hexString (b)); int consumed=0; ISOBitMap bitmap = new ISOBitMap (-1); BitSet bmap = null; int maxField = fld.length; if (emitBitMap()) { consumed += getBitMapfieldPackager().unpack(bitmap,b,consumed); bmap = (BitSet) bitmap.getValue(); m.set (bitmap); maxField = bmap.size(); } for (int i=getFirstField(); i<maxField && consumed < b.length; i++) { if ((bmap == null || bmap.get(i)) && i<fld.length && fld[i] != null) { ISOComponent c = fld[i].createComponent(i); consumed += fld[i].unpack (c, b, consumed); m.set(c); } } if (b.length != consumed) { evt.addMessage ( "WARNING: unpack len=" +b.length +" consumed=" +consumed); } return consumed; } catch (ISOException e) { evt.addMessage (e); throw e; } catch (Exception e) { evt.addMessage (e); throw new ISOException (e); } finally { Logger.log (evt); } } GenericSubFieldPackager(); @Override int getFieldNumber(); @Override int unpack(ISOComponent m, byte[] b); @Override byte[] pack(ISOComponent m); }
GenericSubFieldPackager extends GenericPackager implements ISOSubFieldPackager { @Override public int unpack (ISOComponent m, byte[] b) throws ISOException { LogEvent evt = new LogEvent (this, "unpack"); try { if (m.getComposite() != m) throw new ISOException ("Can't call packager on non Composite"); if (b.length == 0) return 0; if (logger != null) evt.addMessage (ISOUtil.hexString (b)); int consumed=0; ISOBitMap bitmap = new ISOBitMap (-1); BitSet bmap = null; int maxField = fld.length; if (emitBitMap()) { consumed += getBitMapfieldPackager().unpack(bitmap,b,consumed); bmap = (BitSet) bitmap.getValue(); m.set (bitmap); maxField = bmap.size(); } for (int i=getFirstField(); i<maxField && consumed < b.length; i++) { if ((bmap == null || bmap.get(i)) && i<fld.length && fld[i] != null) { ISOComponent c = fld[i].createComponent(i); consumed += fld[i].unpack (c, b, consumed); m.set(c); } } if (b.length != consumed) { evt.addMessage ( "WARNING: unpack len=" +b.length +" consumed=" +consumed); } return consumed; } catch (ISOException e) { evt.addMessage (e); throw e; } catch (Exception e) { evt.addMessage (e); throw new ISOException (e); } finally { Logger.log (evt); } } GenericSubFieldPackager(); @Override int getFieldNumber(); @Override int unpack(ISOComponent m, byte[] b); @Override byte[] pack(ISOComponent m);  }