本文整理汇总了Java中java.util.FormattableFlags.UPPERCASE属性的典型用法代码示例。如果您正苦于以下问题:Java FormattableFlags.UPPERCASE属性的具体用法?Java FormattableFlags.UPPERCASE怎么用?Java FormattableFlags.UPPERCASE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.FormattableFlags
的用法示例。
在下文中一共展示了FormattableFlags.UPPERCASE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: formatTo
@Override
public void formatTo(final Formatter formatter, final int flags,
final int width, final int precision) {
if (this.secret == null) {
formatter.format("NULL");
} else {
final StringBuilder fmt = new StringBuilder(10);
fmt.append('%');
if ((flags & FormattableFlags.LEFT_JUSTIFY) != 0) {
fmt.append('-');
}
if (width != 0) {
fmt.append(width);
}
if ((flags & FormattableFlags.UPPERCASE) == 0) {
fmt.append('s');
} else {
fmt.append('S');
}
formatter.format(
fmt.toString(),
SecretDecor.scramble(this.secret)
);
}
}
示例3: convertsDifferentFormatsViaLogger
/**
* AbstractDecor can convert object to text, via Logger.
* @throws Exception If some problem inside
*/
@Test
public final void convertsDifferentFormatsViaLogger() throws Exception {
final StringBuilder format = new StringBuilder();
format.append('%');
if ((this.flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags
.LEFT_JUSTIFY) {
format.append('-');
}
if (this.width > 0) {
format.append(Integer.toString(this.width));
}
if (this.precision > 0) {
format.append('.').append(Integer.toString(this.precision));
}
if ((this.flags & FormattableFlags.UPPERCASE) == FormattableFlags
.UPPERCASE) {
format.append('S');
} else {
format.append('s');
}
MatcherAssert.assertThat(
Logger.format(format.toString(), this.decor()),
Matchers.equalTo(this.text)
);
}
示例4: 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;
String out = upper ? getAsMention().toUpperCase(formatter.locale()) : getAsMention();
MiscUtil.appendTo(formatter, width, precision, leftJustified, out);
}
示例5: formatTo
@Override
public void formatTo(Formatter formatter, int flags, int width, int precision)
{
boolean upper = (flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE;
boolean leftJustified = (flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY;
String out = content;
if (upper)
out = out.toUpperCase(formatter.locale());
appendFormat(formatter, width, precision, leftJustified, out);
}
示例6: 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);
}
示例7: formatTo
public void formatTo(Formatter formatter, int flags, int width,
int precision) throws IllegalFormatException {
if ((flags & FormattableFlags.UPPERCASE) != 0) {
formatter.format("CUSTOMIZED FORMAT FUNCTION" + " WIDTH: "
+ width + " PRECISION: " + precision);
} else {
formatter.format("customized format function" + " width: "
+ width + " precision: " + precision);
}
}