I have a converter that will convert an array of int into a String.
**EDIT** [1, 2, -45, 678] -> "1 2 -45 678";
[1] -> "1"
Into this converter, I have a supportFromString
method to identify if the string can be converted back into an array.
I though of using regex to do so, but I can't find a good match.
I tried "\\d+\\s"
and "[\\d+]\\s"
but s.matches(pattern)
returns false.
Any suggestion? If one non-numeric character is found, it's not valid.
EDIT Here is the toString method of the converter
@Override
public String toString(Object o, ConverterContext converterContext) {
StringBuilder builder = new StringBuilder();
for (Integer integer : ((Integer[]) o)) {
if (builder.toString().length() > 0) {
builder.append(" ");
}
builder.append(integer);
}
return builder.toString();
}