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


Java FormattableFlags.ALTERNATE属性代码示例

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

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

示例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);
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:12,代码来源:SeqValue.java

示例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);
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:30,代码来源:Value.java

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

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


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