if (!isHeaderField(tag) && !isTrailerField(tag)) { if (!isMsgField(msgType, tag)) { throw new FieldException( SessionRejectReason.TAG_NOT_DEFINED_FOR_THIS_MESSAGE_TYPE, tag); } if (isGroup(msgType, tag)) { try { if (map.getGroupCount(tag) != IntConverter.convert(field.getValue())) { throw new FieldException( SessionRejectReason.INCORRECT_NUMINGROUP_COUNT_FOR_REPEATING_GROUP, tag);
if (!isHeaderField(tag) && !isTrailerField(tag)) { if (!isMsgField(msgType, tag)) { throw new FieldException( SessionRejectReason.TAG_NOT_DEFINED_FOR_THIS_MESSAGE_TYPE, tag); } if (isGroup(msgType, tag)) { try { if (map.getGroupCount(tag) != IntConverter.convert(field.getValue())) { throw new FieldException( SessionRejectReason.INCORRECT_NUMINGROUP_COUNT_FOR_REPEATING_GROUP, tag); } } catch (FieldConvertError e) { throw new InvalidMessage(e.getMessage());
    private void checkFields(FieldMap map, String msgType) throws InvalidMessage {        Iterator i = map.iterator();        int previousTag = -1;        while (i.hasNext()) {            StringField field = (StringField) i.next();            int tag = field.getTag();            if (previousTag >= 0 && tag == previousTag) {                throw new FieldException(SessionRejectReason.TAG_APPEARS_MORE_THAN_ONCE, tag);            }            if (doCheckFieldsHaveValues                    && (field.getValue() == null || field.getValue().length() == 0)) {                throw new FieldException(SessionRejectReason.TAG_SPECIFIED_WITHOUT_A_VALUE, tag);            }            if (version != null) {                checkValidFormat(field);                checkEnumValue(field);            }            if (shouldCheckTag(tag) && !isField(tag)) {                throw new FieldException(SessionRejectReason.INVALID_TAG_NUMBER, tag);            }            if (!isHeaderField(tag) && !isTrailerField(tag)) {                if (!isMsgField(msgType, tag)) {                    throw new FieldException(                            SessionRejectReason.TAG_NOT_DEFINED_FOR_THIS_MESSAGE_TYPE, tag);                }                if (isGroup(msgType, tag)) {                    try {                        if (map.getGroupCount(tag) != IntConverter.convert(field.getValue())) {                            throw new FieldException(                                    SessionRejectReason.INCORRECT_NUMINGROUP_COUNT_FOR_REPEATING_GROUP,                                    tag);                        }                    } catch (FieldConvertError e) {                        throw new InvalidMessage(e.getMessage());                    }                }            }            previousTag = tag;        }    }