本文整理汇总了Java中java.util.FormattableFlags.ALTERNATE属性的典型用法代码示例。如果您正苦于以下问题:Java FormattableFlags.ALTERNATE属性的具体用法?Java FormattableFlags.ALTERNATE怎么用?Java FormattableFlags.ALTERNATE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.FormattableFlags
的用法示例。
在下文中一共展示了FormattableFlags.ALTERNATE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatTo
@Override
public void formatTo(Formatter formatter, int flags, int width, int precision)
{
String s = null;
if ((flags & FormattableFlags.ALTERNATE) > 0)
{
s = toString();
}
else
{
s = "" + unicode;
}
formatTo(s, formatter, flags, width, precision);
}
示例2: formatTo
@Override
public void formatTo(Formatter formatter, int flags, int width, int precision)
{
boolean alt = (flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE;
boolean upper = (flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE;
boolean leftJustified = (flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY;
String out;
if (!alt)
out = getAsMention();
else if (upper)
out = String.format(formatter.locale(), "%S#%s", getName(), getDiscriminator());
else
out = String.format(formatter.locale(), "%s#%s", getName(), getDiscriminator());
MiscUtil.appendTo(formatter, width, precision, leftJustified, out);
}
示例3: formatTo
@Override
public void formatTo(Formatter formatter, int flags, int width, int precision)
{
String s = values.toString();
if ((flags & FormattableFlags.ALTERNATE) == 0 && s.charAt(0) == '"')
{
s = s.substring(1, s.length()-1);
}
formatTo(s, formatter, flags, width, precision);
}
示例4: formatTo
protected void formatTo(String value, Formatter formatter, int flags, int width, int precision)
{
StringBuilder sb = new StringBuilder("%");
switch (flags)
{
case FormattableFlags.LEFT_JUSTIFY:
sb.append('-');
break;
case FormattableFlags.ALTERNATE:
sb.append('#');
break;
}
if (width > 0)
{
sb.append(width);
}
if (precision > 0)
{
sb.append('.');
sb.append(precision);
}
sb.append('s');
formatter.format(sb.toString(), value);
}
示例5: formatTo
@Override
default void formatTo(Formatter formatter, int flags, int width, int precision)
{
boolean leftJustified = (flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY;
boolean upper = (flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE;
boolean alt = (flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE;
String out;
if (alt)
out = "#" + (upper ? getName().toUpperCase(formatter.locale()) : getName());
else
out = getAsMention();
MiscUtil.appendTo(formatter, width, precision, leftJustified, out);
}
示例6: formatTo
@Override
public void formatTo(final Formatter formatter, final int flags,
final int width, final int precision) {
final String text;
if (this.throwable == null) {
text = "NULL";
} else if ((flags & FormattableFlags.ALTERNATE) == 0) {
final StringWriter writer = new StringWriter();
this.throwable.printStackTrace(new PrintWriter(writer));
text = writer.toString();
} else {
text = this.throwable.getMessage();
}
formatter.format("%s", text);
}