Menu

How would I infer type prior to reading and validating value

Help
2015-10-13
2015-10-13
  • Mats Naslund

    Mats Naslund - 2015-10-13

    For the moment I'm reading all values as strings via the .asString() but naturally I would need to obtain the right type. I was wondering is there some way in JRecord to infer the type prior to reading? And I would have to also validate the value to see if it pass/fail what is defined in the copybook.

    Thanks again for your time

     
  • Bruce Martin

    Bruce Martin - 2015-10-13

    You can test the FieldValue for either wether it is numeric or binary
    or test the actual type:

            AbstractFieldValue fieldValue = line.getFieldValue("Vendor-Number");
            if (fieldValue.isNumeric()) {
                if (fieldValue.getFieldDetail().getType() == Type.ftBinaryBigEndian) {
    
                }
            } else if (fieldValue.getFieldDetail().getType() == Type.ftChar) {
    
            }
    
     

Log in to post a comment.

MongoDB Logo MongoDB