Java 类java.util.IllegalFormatPrecisionException 实例源码

项目:form-follows-function    文件:F3Formatter.java   
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;
    }
}
项目:form-follows-function    文件:F3Formatter.java   
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());
}
项目:bazel    文件:FormatSpecifier.java   
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());
}
项目:bazel    文件:FormatSpecifier.java   
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));
    }
}
项目:apfloat    文件:Apint.java   
@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);
}
项目:aya-lang    文件:Apint.java   
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);
}
项目:form-follows-function    文件:F3Formatter.java   
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;
}
项目:form-follows-function    文件:F3Formatter.java   
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());
}
项目:form-follows-function    文件:F3Formatter.java   
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());
}
项目:In-the-Box-Fork    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests java.util.IllegalFormatPrecisionException#IllegalFormatPrecisionException(int)
 */
public void test_illegalFormatPrecisionException() {
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            Integer.MIN_VALUE);
    assertEquals(Integer.MIN_VALUE, illegalFormatPrecisionException
            .getPrecision());
}
项目:In-the-Box-Fork    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests java.util.IllegalFormatPrecisionException#getPrecision()
 */
public void test_getPrecision() {
    int precision = 12345;
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            precision);
    assertEquals(precision, illegalFormatPrecisionException.getPrecision());
}
项目:In-the-Box-Fork    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests method for 'java.util.IllegalFormatPrecisionException#getMessage()
 */
public void test_getMessage() {
    int precision = 12345;
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            precision);
    assertTrue(null != illegalFormatPrecisionException.getMessage());

}
项目:In-the-Box-Fork    文件:IllegalFormatPrecisionExceptionTest.java   
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());
}
项目:succinct    文件:IntVector.java   
/**
 * 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]);
  }
}
项目:succinct    文件:IntVector.java   
/**
 * Initialize the IntVector with an existing integer array list and a specified element bit-width.
 *
 * @param data     Array list of integers to store.
 * @param bitWidth Width in bits of each element.
 */
public IntVector(IntArrayList data, int bitWidth) {
  super(data.size() * bitWidth);
  this.bitWidth = bitWidth;
  for (int i = 0; i < data.size(); i++) {
    if (BitUtils.bitWidth(data.get(i)) > bitWidth) {
      throw new IllegalFormatPrecisionException(bitWidth);
    }
    add(i, data.get(i));
  }
}
项目:cn1    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests java.util.IllegalFormatPrecisionException#IllegalFormatPrecisionException(int)
 */
public void test_illegalFormatPrecisionException() {
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            Integer.MIN_VALUE);
    assertEquals(Integer.MIN_VALUE, illegalFormatPrecisionException
            .getPrecision());
}
项目:cn1    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests java.util.IllegalFormatPrecisionException#getPrecision()
 */
public void test_getPrecision() {
    int precision = 12345;
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            precision);
    assertEquals(precision, illegalFormatPrecisionException.getPrecision());
}
项目:cn1    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests method for 'java.util.IllegalFormatPrecisionException#getMessage()
 */
public void test_getMessage() {
    int precision = 12345;
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            precision);
    assertTrue(null != illegalFormatPrecisionException.getMessage());

}
项目:cn1    文件:IllegalFormatPrecisionExceptionTest.java   
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());
}
项目:bazel    文件:FormatSpecifier.java   
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;
}
项目:bazel    文件:FormatSpecifier.java   
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());
}
项目:bazel    文件:FormatSpecifier.java   
private void checkCharacter() throws FormatFlagsConversionMismatchException {
    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());
}
项目:bazel    文件:FormatSpecifier.java   
private void checkInteger() throws FormatFlagsConversionMismatchException {
    checkNumeric();
    if (precision != -1)
        throw new IllegalFormatPrecisionException(precision);

    if (c == Conversion.DECIMAL_INTEGER)
        checkBadFlags(Flags.ALTERNATE);
    else
        checkBadFlags(Flags.GROUP);
}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests java.util.IllegalFormatPrecisionException#IllegalFormatPrecisionException(int)
 */
public void test_illegalFormatPrecisionException() {
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            Integer.MIN_VALUE);
    assertEquals(Integer.MIN_VALUE, illegalFormatPrecisionException
            .getPrecision());
}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests java.util.IllegalFormatPrecisionException#getPrecision()
 */
public void test_getPrecision() {
    int precision = 12345;
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            precision);
    assertEquals(precision, illegalFormatPrecisionException.getPrecision());
}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests method for 'java.util.IllegalFormatPrecisionException#getMessage()
 */
public void test_getMessage() {
    int precision = 12345;
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            precision);
    assertTrue(null != illegalFormatPrecisionException.getMessage());

}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
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());
}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests java.util.IllegalFormatPrecisionException#IllegalFormatPrecisionException(int)
 */
public void test_illegalFormatPrecisionException() {
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            Integer.MIN_VALUE);
    assertEquals(Integer.MIN_VALUE, illegalFormatPrecisionException
            .getPrecision());
}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests java.util.IllegalFormatPrecisionException#getPrecision()
 */
public void test_getPrecision() {
    int precision = 12345;
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            precision);
    assertEquals(precision, illegalFormatPrecisionException.getPrecision());
}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests method for 'java.util.IllegalFormatPrecisionException#getMessage()
 */
public void test_getMessage() {
    int precision = 12345;
    IllegalFormatPrecisionException illegalFormatPrecisionException = new IllegalFormatPrecisionException(
            precision);
    assertTrue(null != illegalFormatPrecisionException.getMessage());

}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
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());
}
项目:In-the-Box-Fork    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(
            new IllegalFormatPrecisionException(12345), exComparator);
}
项目:In-the-Box-Fork    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new IllegalFormatPrecisionException(12345), exComparator);
}
项目:cn1    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(
            new IllegalFormatPrecisionException(12345), exComparator);
}
项目:cn1    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new IllegalFormatPrecisionException(12345), exComparator);
}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(
            new IllegalFormatPrecisionException(12345), exComparator);
}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new IllegalFormatPrecisionException(12345), exComparator);
}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(
            new IllegalFormatPrecisionException(12345), exComparator);
}
项目:freeVM    文件:IllegalFormatPrecisionExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new IllegalFormatPrecisionException(12345), exComparator);
}