当前位置: 首页>>代码示例>>Java>>正文


Java FormattableFlags.UPPERCASE属性代码示例

本文整理汇总了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);
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:17,代码来源:UserImpl.java

示例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)
        );
    }
}
 
开发者ID:jcabi,项目名称:jcabi-log,代码行数:25,代码来源:SecretDecor.java

示例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)
    );
}
 
开发者ID:jcabi,项目名称:jcabi-log,代码行数:29,代码来源:AbstractDecorTest.java

示例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);
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:9,代码来源:IMentionable.java

示例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);
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:13,代码来源:AbstractMessage.java

示例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);
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:15,代码来源:TextChannel.java

示例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);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:FormatterTest.java


注:本文中的java.util.FormattableFlags.UPPERCASE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。