Get BarCodeReadType from String

Hi,

is it possible to get the BarCodeReadType long value from a given String (something like getBarCodeReadType(String barCodeReadType))

Example
long barcodeType = getBarCodeReadType(“DataMatrix”)
> Value of barcodeType should be BarCodeReadType.DataMatrix (=8589934592L)

Thanks a lot
Best regards
Matthias

Hi,

a possible solution is using reflection (see below). Is there a better solution for this request.

public static long getBarCodeReadType(String barcodeReadType)
{
try
{
Field declaredField = BarCodeReadType.class.getDeclaredField(barcodeReadType);
return declaredField.getLong(declaredField);
}
catch (Exception e)
{
return -1;
}
}

Best regards
Matthias

Hi Klaus,


Thank you for contacting support. This sample code will work for you. I’m afraid. We don’t have an alternative solution at the moment. We will let you know in case of any other better solution.