Parses the specified string as a size value.
The ASCII characters {@code \}{@code u002a} ('*') and
{@code \}{@code u0078} ('x') are recognized as separators between
the width and height.
For any {@code Size s}: {@code Size.parseSize(s.toString()).equals(s)}.
However, the method also handles sizes expressed in the
following forms:
"width{@code x}height" or
"width{@code *}height" {@code => new Size(width, height)},
where width and height are string integers potentially
containing a sign, such as "-10", "+7" or "5".
{@code
Size.parseSize("3*+6").equals(new Size(3, 6)) == true
Size.parseSize("-3x-6").equals(new Size(-3, -6)) == true
Size.parseSize("4 by 3") => throws NumberFormatException
}
checkNotNull(string, "string must not be null");
int sep_ix = string.indexOf('*");
if (sep_ix < 0) {
sep_ix = string.indexOf('x");
}
if (sep_ix < 0) {
throw invalidSize(string);
}
try {
return new Size(Integer.parseInt(string.substring(0, sep_ix)),
Integer.parseInt(string.substring(sep_ix + 1)));
} catch (NumberFormatException e) {
throw invalidSize(string);
}