Type mismatch: cannot convert from Object...to String in tMap

Four Stars

Type mismatch: cannot convert from Object...to String in tMap

Hi,
This is driving me crazy - pretty sure it's my knowledge of Java
(name value pair context file)
row1.Column0 is String
row1.Column1 is String
When (0) is LastBatchId, position (1) is treated as int which we want to increment plus 1
row1.Column0.equals("LastBatchId")
? Integer.parseInt(row1.Column1)+1 : "0"
Testing in the expression builder works, but executing and expression warning output is throwing this error
Type mismatch: cannot convert from Object...to String.
I am output all pairs to as strings. See screen shot for better idea.
Any help welcome
Seventeen Stars

Re: Type mismatch: cannot convert from Object...to String in tMap

The problem is a bit misleading error message. The true-part of your ? operator returns an int and this cannot be cast to a String. Try this:
row1.Column0.equals("LastBatchId") ? String.valueOf(Integer.parseInt(row1.Column1)+1) : "0"
In this version the int values will be converted into a String and this can be used.
Four Stars

Re: Type mismatch: cannot convert from Object...to String in tMap

Thanks, that makes sense and works!
One Star

Re: Type mismatch: cannot convert from Object...to String in tMap

Hi,
This is driving me crazy - pretty sure it's my knowledge of Java
(name value pair context file)
row1.Column0 is String
row1.Column1 is String
When (0) is LastBatchId, position (1) is treated as int which we want to increment plus 1
row1.Column0.equals("LastBatchId")
? Integer.parseInt(row1.Column1)+1 : "0"  
Testing in the expression builder works, but executing and expression warning output is throwing this error
Type mismatch: cannot convert from Object...to String.
I am output all pairs to as strings. See screen shot for better idea.
Any help welcome

type Mismatch error: How to convert object type into int