本文整理汇总了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);
}
示例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.
}
}
示例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());
}
}
示例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);
}
示例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);
}
示例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
}
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例11: testSerializationSelf
import java.util.FormatFlagsConversionMismatchException; //导入依赖的package包/类
/**
* @tests serialization/deserialization.
*/
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(
new FormatFlagsConversionMismatchException("MYTESTFLAGS", 'T'),
exComparator);
}
示例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
}
}
示例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));
}
示例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);
}
示例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());
}