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


Java IllegalFormatPrecisionException类代码示例

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


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

示例1: checkInteger

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
private void checkInteger() {
    checkNumeric();
    if (precision != -1)
        throw new IllegalFormatPrecisionException(precision);

    switch (c) {
        case Conversion.DECIMAL_INTEGER:
            checkBadFlags(Flags.ALTERNATE);
            break;
        case Conversion.OCTAL_INTEGER:
        case Conversion.HEXADECIMAL_INTEGER:
        case Conversion.HEXADECIMAL_INTEGER_UPPER:
            checkBadFlags(Flags.GROUP);
            break;
    }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:17,代码来源:F3Formatter.java

示例2: checkNumeric

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
private void checkNumeric() {
    if (width != -1 && width < 0)
        throw new IllegalFormatWidthException(width);

    if (precision != -1 && precision < 0)
        throw new IllegalFormatPrecisionException(precision);

    // '-' and '0' require a width
    if (width == -1
        && (f.contains(Flags.LEFT_JUSTIFY) || f.contains(Flags.ZERO_PAD)))
        throw new MissingFormatWidthException(toString());

    // bad combination
    if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE))
        || (f.contains(Flags.LEFT_JUSTIFY) && f.contains(Flags.ZERO_PAD)))
        throw new IllegalFormatFlagsException(f.toString());
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:18,代码来源:F3Formatter.java

示例3: checkNumeric

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
private void checkNumeric() {
	if (width != -1 && width < 0)
		throw new IllegalFormatWidthException(width);

	if (precision != -1 && precision < 0)
		throw new IllegalFormatPrecisionException(precision);

	// '-' and '0' require a width
	if (width == -1
			&& (f.contains(Flags.LEFT_JUSTIFY) || f
					.contains(Flags.ZERO_PAD)))
		throw new MissingFormatWidthException(toString());

	// bad combination
	if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE))
			|| (f.contains(Flags.LEFT_JUSTIFY) && f
					.contains(Flags.ZERO_PAD)))
		throw new IllegalFormatFlagsException(f.toString());
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:20,代码来源:FormatSpecifier.java

示例4: checkText

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
private void checkText() {
	if (precision != -1)
		throw new IllegalFormatPrecisionException(precision);
	switch (c) {
	case Conversion.PERCENT_SIGN:
		if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf()
				&& f.valueOf() != Flags.NONE.valueOf())
			throw new IllegalFormatFlagsException(f.toString());
		// '-' requires a width
		if (width == -1 && f.contains(Flags.LEFT_JUSTIFY))
			throw new MissingFormatWidthException(toString());
		break;
	case Conversion.LINE_SEPARATOR:
		if (width != -1)
			throw new IllegalFormatWidthException(width);
		if (f.valueOf() != Flags.NONE.valueOf())
			throw new IllegalFormatFlagsException(f.toString());
		break;
	default:
           throw new UnknownFormatConversionException(String.valueOf(c));
	}
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:23,代码来源:FormatSpecifier.java

示例5: formatTo

import java.util.IllegalFormatPrecisionException; //导入依赖的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

示例6: formatTo

import java.util.IllegalFormatPrecisionException; //导入依赖的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

示例7: precision

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
private int precision(String s) {
    precision = -1;
    if (s != null) {
        try {
            // remove the '.'
            precision = Integer.parseInt(s.substring(1));
            if (precision < 0)
                throw new IllegalFormatPrecisionException(precision);
        } catch (NumberFormatException x) {
            assert(false);
        }
    }
    return precision;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:15,代码来源:F3Formatter.java

示例8: checkDateTime

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
private void checkDateTime() {
    if (precision != -1)
        throw new IllegalFormatPrecisionException(precision);
    if (!DateTime.isValid(c, c2))
        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:unktomi,项目名称:form-follows-function,代码行数:12,代码来源:F3Formatter.java

示例9: checkCharacter

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
private void checkCharacter() {
    if (precision != -1)
        throw new IllegalFormatPrecisionException(precision);
    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:unktomi,项目名称:form-follows-function,代码行数:10,代码来源:F3Formatter.java

示例10: test_illegalFormatPrecisionException

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
/**
 * @tests java.util.IllegalFormatPrecisionException#IllegalFormatPrecisionException(int)
 */
public void test_illegalFormatPrecisionException() {
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            Integer.MIN_VALUE);
    assertEquals(Integer.MIN_VALUE, illegalFormatPrecisionException
            .getPrecision());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:10,代码来源:IllegalFormatPrecisionExceptionTest.java

示例11: test_getPrecision

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
/**
 * @tests java.util.IllegalFormatPrecisionException#getPrecision()
 */
public void test_getPrecision() {
    int precision = 12345;
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            precision);
    assertEquals(precision, illegalFormatPrecisionException.getPrecision());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:10,代码来源:IllegalFormatPrecisionExceptionTest.java

示例12: test_getMessage

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
/**
 * @tests method for 'java.util.IllegalFormatPrecisionException#getMessage()
 */
public void test_getMessage() {
    int precision = 12345;
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            precision);
    assertTrue(null != illegalFormatPrecisionException.getMessage());

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

示例13: assertDeserialized

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

    SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
            deserialized);

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

    assertEquals("Precision", initEx.getPrecision(), desrEx
            .getPrecision());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:13,代码来源:IllegalFormatPrecisionExceptionTest.java

示例14: IntVector

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
/**
 * Initialize the IntVector with an existing integer array and a specified element bit-width.
 *
 * @param data     Array of integers to store.
 * @param bitWidth Width in bits of each element.
 */
public IntVector(int[] data, int bitWidth) {
  super(data.length * bitWidth);
  this.bitWidth = bitWidth;
  for (int i = 0; i < data.length; i++) {
    if (BitUtils.bitWidth(data[i]) > bitWidth) {
      throw new IllegalFormatPrecisionException(bitWidth);
    }
    add(i, data[i]);
  }
}
 
开发者ID:amplab,项目名称:succinct,代码行数:17,代码来源:IntVector.java

示例15: precision

import java.util.IllegalFormatPrecisionException; //导入依赖的package包/类
private int precision(String s) throws FormatterNumberFormatException {
	precision = -1;
	if (s != null) {
		try {
			// remove the '.'
			precision = Integer.parseInt(s.substring(1));
			if (precision < 0)
				throw new IllegalFormatPrecisionException(precision);
		} catch (NumberFormatException x) {
               throw new FormatterNumberFormatException(s, "precision");
		}
	}
	return precision;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:15,代码来源:FormatSpecifier.java


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