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


Java FormatFlagsConversionMismatchException类代码示例

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


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

示例1: testSerializationCompatibility

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new FormatFlagsConversionMismatchException("MYTESTFLAGS", 'T'),
            exComparator);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:10,代码来源:FormatFlagsConversionMismatchExceptionTest.java

示例2: verifyPrintf

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
private void verifyPrintf(MethodInvocationTree tree, FormatParameters parameters)
    throws FormatFlagsConversionMismatchException, IllegalFormatException, FormatterException {
   List<? extends ExpressionTree> args = tree.getArguments();

  JCLiteral format = (JCLiteral) args.get(parameters.getFormatIndex());
  String formatString = (String) format.getValue();

  List<String> argTypes = new ArrayList<String>();
  for (int i = parameters.getFormatIndex() + 1; i < args.size(); ++i) {
    Type type = ((JCExpression) args.get(i)).type;
    argTypes.add(getFormatterType(type));
  }

  try {
    Formatter.check(formatString, argTypes.toArray(new String[0]));
  } catch (ExtraFormatArgumentsException e) {
    return; // We can handle this.
  }
}
 
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:20,代码来源:MisusedFormattingLogger.java

示例3: formatsBoolean

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
@Test
public void formatsBoolean() {
    assertEquals("true", new Formatter().format("%b", true).toString());
    assertEquals("false", new Formatter().format("%b", false).toString());

    assertEquals("true", new Formatter().format("%b", new Object()).toString());
    assertEquals("false", new Formatter().format("%b", null).toString());

    assertEquals("  true", new Formatter().format("%6b", true).toString());
    assertEquals("true  ", new Formatter().format("%-6b", true).toString());
    assertEquals("true", new Formatter().format("%2b", true).toString());
    assertEquals("tr", new Formatter().format("%2.2b", true).toString());
    assertEquals("  tr", new Formatter().format("%4.2b", true).toString());
    assertEquals("TRUE", new Formatter().format("%B", true).toString());

    try {
        new Formatter().format("%+b", true);
        fail("Should have thrown exception");
    } catch (FormatFlagsConversionMismatchException e) {
        assertEquals("+", e.getFlags());
        assertEquals('b', e.getConversion());
    }
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:24,代码来源:FormatterTest.java

示例4: formatTo

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
@Override
public void formatTo(Formatter formatter, int flags, int width, int precision)
{
    if ((flags & ALTERNATE) == ALTERNATE)
    {
        throw new FormatFlagsConversionMismatchException("#", 's');
    }
    if (precision != -1)
    {
        throw new IllegalFormatPrecisionException(precision);
    }
    this.value.formatTo(formatter, flags | ALTERNATE, width, precision);
}
 
开发者ID:mtommila,项目名称:apfloat,代码行数:14,代码来源:Apint.java

示例5: formatTo

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
public void formatTo(Formatter formatter, int flags, int width, int precision)
{
    if ((flags & ALTERNATE) == ALTERNATE)
    {
        throw new FormatFlagsConversionMismatchException("#", 's');
    }
    if (precision != -1)
    {
        throw new IllegalFormatPrecisionException(precision);
    }
    this.value.formatTo(formatter, flags | ALTERNATE, width, precision);
}
 
开发者ID:nick-paul,项目名称:aya-lang,代码行数:13,代码来源:Apint.java

示例6: test_formatFlagsConversionMismatchException

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
/**
 * @tests java.util.FormatFlagsConversionMismatchException#FormatFlagsConversionMismatchException(String,
 *        char)
 */
public void test_formatFlagsConversionMismatchException() {
    try {
        new FormatFlagsConversionMismatchException(null, ' ');
        fail("should throw NullPointerException.");
    } catch (NullPointerException e) {
        // expected
    }

}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:14,代码来源:FormatFlagsConversionMismatchExceptionTest.java

示例7: test_getFlags

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
/**
 * @tests java.util.FormatFlagsConversionMismatchException#getFlags()
 */
public void test_getFlags() {
    String flags = "MYTESTFLAGS";
    char conversion = 'T';
    FormatFlagsConversionMismatchException formatFlagsConversionMismatchException = new FormatFlagsConversionMismatchException(
            flags, conversion);
    assertEquals(flags, formatFlagsConversionMismatchException.getFlags());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:11,代码来源:FormatFlagsConversionMismatchExceptionTest.java

示例8: test_getConversion

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
/**
 * @tests java.util.FormatFlagsConversionMismatchException#getConversion()
 */
public void test_getConversion() {
    String flags = "MYTESTFLAGS";
    char conversion = 'T';
    FormatFlagsConversionMismatchException formatFlagsConversionMismatchException = new FormatFlagsConversionMismatchException(
            flags, conversion);
    assertEquals(conversion, formatFlagsConversionMismatchException
            .getConversion());

}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:13,代码来源:FormatFlagsConversionMismatchExceptionTest.java

示例9: test_getMessage

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
/**
 * @tests java.util.FormatFlagsConversionMismatchException#getMessage()
 */
public void test_getMessage() {
    String flags = "MYTESTFLAGS";
    char conversion = 'T';
    FormatFlagsConversionMismatchException formatFlagsConversionMismatchException = new FormatFlagsConversionMismatchException(
            flags, conversion);
    assertTrue(null != formatFlagsConversionMismatchException.getMessage());

}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:12,代码来源:FormatFlagsConversionMismatchExceptionTest.java

示例10: assertDeserialized

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
public void assertDeserialized(Serializable initial,
        Serializable deserialized) {

    SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
            deserialized);

    FormatFlagsConversionMismatchException initEx = (FormatFlagsConversionMismatchException) initial;
    FormatFlagsConversionMismatchException desrEx = (FormatFlagsConversionMismatchException) deserialized;

    assertEquals("Flags", initEx.getFlags(), desrEx.getFlags());
    assertEquals("Conversion", initEx.getConversion(), desrEx
            .getConversion());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:14,代码来源:FormatFlagsConversionMismatchExceptionTest.java

示例11: testSerializationSelf

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(
            new FormatFlagsConversionMismatchException("MYTESTFLAGS", 'T'),
            exComparator);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:10,代码来源:FormatFlagsConversionMismatchExceptionTest.java

示例12: assertFormatFlagsConversionMismatchException

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
private void assertFormatFlagsConversionMismatchException(Formatter f, String str) {
    try {
        f.format(str);
        fail("should throw FormatFlagsConversionMismatchException: "
                + str);
         /*
         * error on RI, throw IllegalFormatFlagsException specification
         * says FormatFlagsConversionMismatchException should be thrown
         */
    } catch (FormatFlagsConversionMismatchException e) {
       // expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:14,代码来源:FormatterTest.java

示例13: FormatSpecifier

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
FormatSpecifier(String source, String[] sa)
           throws FormatFlagsConversionMismatchException,
           FormatterNumberFormatException {
	int idx = 0;
	this.source = source;
	index(sa[idx++]);
	flags(sa[idx++]);
	width(sa[idx++]);
	precision(sa[idx++]);

	if (sa[idx] != null) {
		dt = true;
		if (sa[idx].equals("T"))
			f.add(Flags.UPPERCASE);
	}
	conversion(sa[++idx]);

	if (dt)
		checkDateTime();
	else if (Conversion.isGeneral(c))
		checkGeneral();
	else if (Conversion.isCharacter(c))
		checkCharacter();
	else if (Conversion.isInteger(c))
		checkInteger();
	else if (Conversion.isFloat(c))
		checkFloat();
	else if (Conversion.isText(c))
		checkText();
	else
		throw new UnknownFormatConversionException(String.valueOf(c));
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:33,代码来源:FormatSpecifier.java

示例14: checkGeneral

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
private void checkGeneral() throws FormatFlagsConversionMismatchException {
	if ((c == Conversion.BOOLEAN || c == Conversion.HASHCODE)
			&& f.contains(Flags.ALTERNATE))
		failMismatch(Flags.ALTERNATE, c);
	// '-' requires a width
	if (width == -1 && f.contains(Flags.LEFT_JUSTIFY))
		throw new MissingFormatWidthException(toString());
	checkBadFlags(Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD,
			Flags.GROUP, Flags.PARENTHESES);
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:11,代码来源:FormatSpecifier.java

示例15: checkDateTime

import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
private void checkDateTime() throws FormatFlagsConversionMismatchException {
	if (precision != -1)
		throw new IllegalFormatPrecisionException(precision);
	if (!DateTime.isValid(c))
		throw new UnknownFormatConversionException("t" + c);
	checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE,
			Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES);
	// '-' requires a width
	if (width == -1 && f.contains(Flags.LEFT_JUSTIFY))
		throw new MissingFormatWidthException(toString());
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:12,代码来源:FormatSpecifier.java


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