@Override public void incOffset() { if (offset < delegate.getMaxField()) { offset++; } }
@Override public void setOffset(int offset) { if (offset <= delegate.getMaxField()) { ISOMsgRef.this.offset = offset; } }
@Override public int getMaxField() { return delegate.getMaxField(); }
private void setValidFields() { validFields = new Vector(); for (int i=0; i<=m.getMaxField(); i++) if (m.hasField(i)) validFields.addElement(i); } private JComponent createISOMsgTable() {
private void assertNoExtraFields (ISOMsg m, Set validFields, Result rc) { StringBuffer sb = new StringBuffer(); for (int i=1; i<=m.getMaxField(); i++) { // we start at 1, MTI is always valid String s = Integer.toString (i); if (m.hasField(i) && !validFields.contains (s)) { if (sb.length() > 0) sb.append (' '); sb.append (s); } } if (sb.length() > 0) rc.fail(CMF.EXTRA_FIELD, Caller.info(), sb.toString()); }
/** * setup BitMap * @exception ISOException on error */ public void recalcBitMap () throws ISOException { if (!dirty) return; int mf = Math.min (getMaxField(), 192); BitSet bmap = new BitSet (mf+62 >>6 <<6); for (int i=1; i<=mf; i++) if (fields.get (i) != null) bmap.set (i); set (new ISOBitMap (-1, bmap)); dirty = false; } /**
/** * add all fields present on received parameter to this ISOMsg<br> * please note that received fields take precedence over * existing ones (simplifying card agent message creation * and template handling) * @param m ISOMsg to merge */ @SuppressWarnings("PMD.EmptyCatchBlock") public void merge (ISOMsg m) { for (int i=0; i<=m.getMaxField(); i++) try { if (m.hasField(i)) set (m.getComponent(i)); } catch (ISOException ignored) { // should never happen } }
public void merge (ISOMsg m) { if (m instanceof FSDISOMsg) { fsd.merge (((FSDISOMsg)m).getFSDMsg()); } else { for (int i=0; i<=m.getMaxField(); i++) { if (m.hasField(i)) fsd.set (Integer.toString(i), m.getString(i)); } } } public void setResponseMTI() {
@Test public void testGetMaxField1() throws Throwable { ISOMsg iSOMsg = new ISOMsg("testISOMsgMti"); int maxField = iSOMsg.getMaxField(); int result = iSOMsg.getMaxField(); assertEquals("result", maxField, result); }
private void applyProps (ISOMsg m) throws ISOException { int maxField = m.getMaxField (); for (int i=0; i<=maxField; i++) { Object o = null;
@Test public void testFilter5() throws Throwable { MacroFilter macroFilter = new MacroFilter(); LogEvent evt = new LogEvent(); ISOChannel channel = new NACChannel(); when(m.getMaxField()).thenReturn(0); when(m.hasField(0)).thenReturn(true); when(m.getValue(0)).thenReturn("N/A in Composite"); ISOMsg result = macroFilter.filter(channel, m, evt); assertSame("result", m, result); }
@Test public void testFilter3() throws Throwable { MacroFilter macroFilter = new MacroFilter(); ISOChannel channel = new PADChannel(new GenericSubFieldPackager()); LogEvent evt = new LogEvent(); when(m.getMaxField()).thenReturn(0); when(m.hasField(0)).thenReturn(false); ISOMsg result = macroFilter.filter(channel, m, evt); assertSame("result", m, result); }
@Test public void testFilter() throws Throwable { MacroFilter macroFilter = new MacroFilter(); ISOChannel channel = new GZIPChannel(new X92GenericPackager()); LogEvent evt = new LogEvent("testMacroFilterTag", "\u0000\u0000"); when(m.getMaxField()).thenReturn(0); ISOMsg result = macroFilter.filter(channel, m, evt); assertSame("result", m, result); verify(m).hasField(0); }
@Test public void testGetMaxField2() throws Throwable { ISOMsg iSOMsg = new ISOMsg(); int result = iSOMsg.getMaxField(); assertEquals("iSOMsg.maxField", 0, iSOMsg.maxField); assertFalse("iSOMsg.maxFieldDirty", iSOMsg.maxFieldDirty); assertEquals("result", 0, result); }
@Override public synchronized void writeTo(ISOMsg isoMsg) throws ISOException { int maxField = isoMsg.getMaxField(); List<TagValue> tagValueList = getOrderedList(); int fieldNumber = 0; for (TagValue tagValue : tagValueList) { Object value = tagValue.getValue(); if (value != null) { ISOComponent subField; if (value instanceof byte[]) { subField = new ISOBinaryField(fieldNumber + maxField + 1, (byte[]) value); } else if (value instanceof String) { subField = new ISOField(fieldNumber + maxField + 1, (String) value); } else if (value instanceof TagSequence) { TagSequence subSequence = (TagSequence) tagValue; subField = new ISOMsg(fieldNumber + maxField + 1); subSequence.writeTo((ISOMsg) subField); } else if (value instanceof ISOMsg) { ISOMsgTagValue subSequence = (ISOMsgTagValue) tagValue; subField = subSequence.getValue(); subField.setFieldNumber(fieldNumber + maxField + 1); } else { throw new ISOException("Unknown TagValue subclass: " + tagValue.getClass()); } isoMsg.set(new ISOTaggedField(tagValue.getTag(), subField)); } fieldNumber++; } }
@Test public void testPack() throws Throwable { ISOPackager p = new ISO87APackagerBBitmap(); ISOMsg iSOMsg = new ISOMsg(); iSOMsg.setPackager(p); iSOMsg.getMaxField(); byte[] result = iSOMsg.pack(); assertEquals("iSOMsg.fields.size()", 1, iSOMsg.fields.size()); assertFalse("iSOMsg.dirty", iSOMsg.dirty); assertEquals("result.length", 0, result.length); assertSame("iSOMsg.packager", p, iSOMsg.packager); }
@Test public void testGetMaxField() throws Throwable { ISOMsg iSOMsg = new ISOMsg(); iSOMsg.set(100, "testISOMsgValue"); byte[] v = new byte[2]; iSOMsg.set(new ISOBinaryField(100, v)); iSOMsg.set(1000, (byte[]) null); int result = iSOMsg.getMaxField(); assertFalse("iSOMsg.maxFieldDirty", iSOMsg.maxFieldDirty); assertEquals("result", 100, result); assertEquals("iSOMsg.maxField", 100, iSOMsg.maxField); }
@Test public void testFilter() throws Throwable { MD5Filter mD5Filter = new MD5Filter(); mD5Filter.setConfiguration(new SimpleConfiguration()); ISOMsg m = new ISOMsg("testMD5FilterMti"); m.setDirection(2); ISOMsg result = mD5Filter.filter(new ASCIIChannel(new EuroSubFieldPackager()), m, new LogEvent()); assertEquals("m.getMaxField()", 128, m.getMaxField()); assertSame("result", m, result); }
@Test public void testFilter2() throws Throwable { MD5Filter mD5Filter = new MD5Filter(); mD5Filter.setConfiguration(new SimpleConfiguration()); int[] fields = new int[1]; mD5Filter.setFields(fields); ISOMsg m = new ISOMsg("testMD5FilterMti"); m.setDirection(2); ISOMsg result = mD5Filter.filter(new ASCIIChannel(new ISOBaseValidatingPackager()), m, new LogEvent("testMD5FilterTag")); assertEquals("m.getMaxField()", 128, m.getMaxField()); assertSame("result", m, result); }
@Test public void testFilter1() throws Throwable { MD5Filter mD5Filter = new MD5Filter(); mD5Filter.setConfiguration(new SimpleConfiguration()); int[] fields = new int[1]; fields[0] = -100; mD5Filter.setFields(fields); ISOMsg m = new ISOMsg("testMD5FilterMti"); m.setDirection(2); ISOMsg result = mD5Filter.filter(new ASCIIChannel(new ISOBaseValidatingPackager()), m, new LogEvent("testMD5FilterTag")); assertEquals("m.getMaxField()", 128, m.getMaxField()); assertSame("result", m, result); }