char conversion)
throws IOException
{
assert radix == 8 || radix == 16;
CPStringBuilder builder = basicIntegralConversion(arg, flags, width,
precision, radix,
conversion);
int insertPoint = 0;
// Insert the sign.
if (builder.charAt(0) == '-')
{
// Already inserted. Note that we don't insert a sign, since
// the only case where it is needed it BigInteger, and it has
// already been inserted by toString.
++insertPoint;
}
else if ((flags & FormattableFlags.PLUS) != 0)
{
builder.insert(insertPoint, '+');
++insertPoint;
}
else if ((flags & FormattableFlags.SPACE) != 0)
{
builder.insert(insertPoint, ' ');
++insertPoint;
}
// Insert the radix prefix.
if ((flags & FormattableFlags.ALTERNATE) != 0)
{
builder.insert(insertPoint, radix == 8 ? "0" : "0x");
insertPoint += radix == 8 ? 1 : 2;
}
// Now justify the result.
int resultWidth = builder.length();
if (resultWidth < width)
{
char fill = ((flags & FormattableFlags.ZERO) != 0) ? '0' : ' ';
if ((flags & FormattableFlags.LEFT_JUSTIFY) != 0)
{
// Left justify.
if (fill == ' ')
insertPoint = builder.length();
}
else
{
// Right justify. Insert spaces before the radix prefix
// and sign.
insertPoint = 0;
}
while (resultWidth++ < width)
builder.insert(insertPoint, fill);
}
String result = builder.toString();
if ((flags & FormattableFlags.UPPERCASE) != 0)
{
if (fmtLocale == null)
result = result.toUpperCase();
else