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


Java FormattableFlags类代码示例

本文整理汇总了Java中java.util.FormattableFlags的典型用法代码示例。如果您正苦于以下问题:Java FormattableFlags类的具体用法?Java FormattableFlags怎么用?Java FormattableFlags使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FormattableFlags类属于java.util包,在下文中一共展示了FormattableFlags类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: formatTo

import java.util.FormattableFlags; //导入依赖的package包/类
@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,代码行数:17,代码来源:CharacterValue.java

示例2: formatTo

import java.util.FormattableFlags; //导入依赖的package包/类
@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,代码行数:18,代码来源:UserImpl.java

示例3: formatTo

import java.util.FormattableFlags; //导入依赖的package包/类
@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,代码行数:26,代码来源:SecretDecor.java

示例4: convertsDifferentFormatsViaLogger

import java.util.FormattableFlags; //导入依赖的package包/类
/**
 * 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,代码行数:30,代码来源:AbstractDecorTest.java

示例5: params

import java.util.FormattableFlags; //导入依赖的package包/类
/**
 * Params for this parametrized test.
 * @return Array of arrays of params for ctor
 */
@Parameters
@SuppressWarnings("PMD.ProhibitPublicStaticMethods")
public static Collection<Object[]> params() {
    return Arrays.asList(
        new Object[][] {
            // @checkstyle MagicNumber (14 lines)
            {null, "NULL", 0, 0, 0},
            {1L, "1b", 0, 0, 0},
            {123L, "  123b", 0, 6, 0},
            {1024L, "1.000Kb", 0, 0, 3},
            {5120L, "5Kb", 0, 0, 0},
            {12345L, "12.056Kb", 0, 0, 3},
            {12345L, "12.1Kb  ", FormattableFlags.LEFT_JUSTIFY, 8, 1},
            {98765432L, "94.190MB", FormattableFlags.UPPERCASE, 0, 3},
            {98765432L, "94.190Mb", 0, 0, 3},
            {90L * 1024 * 1024 * 1024, "90Gb", 0, 0, 0},
            {13L * 1024 * 1024 * 1024 * 1024, "13Tb", 0, 0, 0},
            {33L * 1024 * 1024 * 1024 * 1024 * 1024, "33Pb", 0, 0, 0},
            {3L * 1024 * 1024 * 1024 * 1024 * 1024 * 1024, "3Eb", 0, 0, 0},
        }
    );
}
 
开发者ID:jcabi,项目名称:jcabi-log,代码行数:27,代码来源:SizeDecorTest.java

示例6: params

import java.util.FormattableFlags; //导入依赖的package包/类
/**
 * Params for this parametrized test.
 * @return Array of arrays of params for ctor
 */
@Parameters
@SuppressWarnings("PMD.ProhibitPublicStaticMethods")
public static Collection<Object[]> params() {
    return Arrays.asList(
        new Object[][] {
            // @checkstyle LineLength (20 lines)
            // @checkstyle MagicNumber (20 lines)
            {null, "NULL", 0, 0, 0},
            {13L, "13ms", 0, 0, -1},
            {13L, "13.0ms", 0, 0, 1},
            {1024L, "1s", 0, 0, 0},
            {6001L, "6.0010s", 0, 0, 4},
            {122001L, "  2MIN", FormattableFlags.UPPERCASE, 6, 0},
            {3789003L, "1hr", 0, 0, 0},
            {86400000L, "1days", 0, 0, 0},
            {864000000L, "10days", 0, 0, 0},
        }
    );
}
 
开发者ID:jcabi,项目名称:jcabi-log,代码行数:24,代码来源:MsDecorTest.java

示例7: formatTo

import java.util.FormattableFlags; //导入依赖的package包/类
@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,代码行数:13,代码来源:SeqValue.java

示例8: formatTo

import java.util.FormattableFlags; //导入依赖的package包/类
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,代码行数:31,代码来源:Value.java

示例9: formatTo

import java.util.FormattableFlags; //导入依赖的package包/类
@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,代码行数:10,代码来源:IMentionable.java

示例10: formatTo

import java.util.FormattableFlags; //导入依赖的package包/类
@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,代码行数:14,代码来源:AbstractMessage.java

示例11: formatTo

import java.util.FormattableFlags; //导入依赖的package包/类
@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,代码行数:16,代码来源:TextChannel.java

示例12: test_ConstantFieldValues

import java.util.FormattableFlags; //导入依赖的package包/类
/**
 * @test java.util.FormattableFlags ConstantFieldValues
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Verifies fields.",
    method = "!Constants",
    args = {}
)
public void test_ConstantFieldValues() {
    assertEquals(1, FormattableFlags.LEFT_JUSTIFY);
    assertEquals(2, FormattableFlags.UPPERCASE);
    assertEquals(4, FormattableFlags.ALTERNATE);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:15,代码来源:FormattableFlagsTest.java

示例13: formatTo

import java.util.FormattableFlags; //导入依赖的package包/类
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,代码行数:11,代码来源:FormatterTest.java

示例14: formatTo

import java.util.FormattableFlags; //导入依赖的package包/类
@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,代码行数:16,代码来源:ExceptionDecor.java

示例15: params

import java.util.FormattableFlags; //导入依赖的package包/类
/**
 * Params for this parametrized test.
 * @return Array of arrays of params for ctor
 */
@Parameters
@SuppressWarnings("PMD.ProhibitPublicStaticMethods")
public static Collection<Object[]> params() {
    return Arrays.asList(
        new Object[][] {
            // @checkstyle LineLength (20 lines)
            // @checkstyle MagicNumber (20 lines)
            {null, "NULL", 0, 0, 0},
            {13L, "13ns", 0, 0, -1},
            {13L, "13.0ns", 0, 0, 1},
            {25L, "25.00ns", 0, 0, 2},
            {234L, "234.0ns", 0, 0, 1},
            {1024L, "1µs", 0, 0, 0},
            {1056L, "1.056µs", 0, 0, 3},
            {9022L, "9.02µs", 0, 0, 2},
            {53111L, "53.11µs   ", FormattableFlags.LEFT_JUSTIFY, 10, 2},
            {53156L, "   53µs", 0, 7, 0},
            {87090432L, "  87ms", 0, 6, 0},
            {87090543L, "87.09ms", 0, 0, 2},
            {87090548L, "87.0905ms", 0, 0, 4},
            {6001001001L, "6.0010s", 0, 0, 4},
            {122001001001L, "  2MIN", FormattableFlags.UPPERCASE, 6, 0},
            {3789001001001L, "63.15002min", 0, 0, 5},
            {3789002002002L, "63.2min", 0, 0, 1},
            {3789003003003L, "63min", 0, 0, 0},
            {342000004004004L, "5700min", 0, 0, 0},
        }
    );
}
 
开发者ID:jcabi,项目名称:jcabi-log,代码行数:34,代码来源:NanoDecorTest.java


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