Search in sources :

Example 1 with ContextConstants

use of org.jpos.transaction.ContextConstants in project jPOS by jpos.

the class CheckFields method assertFields.

private void assertFields(Context ctx, ISOMsg m, String fields, boolean mandatory, Set<String> validFields, Result rc) {
    StringTokenizer st = new StringTokenizer(fields, ", ");
    while (st.hasMoreTokens()) {
        String s = st.nextToken();
        ContextConstants k = null;
        try {
            k = ContextConstants.valueOf(s);
        } catch (IllegalArgumentException ignored) {
        }
        if (k != null) {
            switch(k) {
                case PCODE:
                    putPCode(ctx, m, mandatory, validFields, rc);
                    break;
                case CARD:
                    putCard(ctx, m, mandatory, validFields, rc);
                    break;
                case TID:
                    putTid(ctx, m, mandatory, validFields, rc);
                    break;
                case MID:
                    putMid(ctx, m, mandatory, validFields, rc);
                    break;
                case TRANSMISSION_TIMESTAMP:
                    putTimestamp(ctx, m, TRANSMISSION_TIMESTAMP.toString(), 7, mandatory, validFields, rc);
                    break;
                case TRANSACTION_TIMESTAMP:
                    putTimestamp(ctx, m, TRANSACTION_TIMESTAMP.toString(), 12, mandatory, validFields, rc);
                    break;
                case POS_DATA_CODE:
                    putPDC(ctx, m, mandatory, validFields, rc);
                    break;
                case CAPTURE_DATE:
                    putCaptureDate(ctx, m, mandatory, validFields, rc);
                    break;
                case AMOUNT:
                    putAmount(ctx, m, mandatory, validFields, rc);
                    break;
                case ORIGINAL_DATA_ELEMENTS:
                    putOriginalDataElements(ctx, m, mandatory, validFields, rc);
                    break;
                default:
                    k = null;
            }
        }
        if (k == null) {
            if (mandatory && !m.hasField(s))
                rc.fail(CMF.MISSING_FIELD, Caller.info(), s);
            else
                validFields.add(s);
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) ContextConstants(org.jpos.transaction.ContextConstants)

Aggregations

StringTokenizer (java.util.StringTokenizer)1 ContextConstants (org.jpos.transaction.ContextConstants)1