java.lang.Object
org.checkerframework.checker.formatter.util.FormatUtil

@AnnotatedFor("nullness") public final class FormatUtil extends Object
This class provides a collection of utilities to ease working with format strings.
  • Method Details

    • asFormat

      @ReturnsFormat public static String asFormat(String format, ConversionCategory... cc)
      Returns the first argument if the format string is satisfiable, and if the format's parameters match the passed ConversionCategorys. Otherwise throws an exception.
      Parameters:
      format - a format string
      cc - an array of conversion categories
      Returns:
      the format argument
      Throws:
      IllegalFormatException - if the format string is incompatible with the conversion categories
    • tryFormatSatisfiability

      public static void tryFormatSatisfiability(String format)
      Throws an exception if the format is not syntactically valid.
      Parameters:
      format - a format string
      Throws:
      IllegalFormatException - if the format string is invalid
    • formatParameterCategories

      public static ConversionCategory[] formatParameterCategories(String format)
      Returns a ConversionCategory for every conversion found in the format string.
      Parameters:
      format - a format string
      Returns:
      the conversion categories in the format string
      Throws:
      IllegalFormatException - if the format is not syntactically valid
    • conversionCharFromFormat

      @Deprecated public static char conversionCharFromFormat(String formatSpecifier)
      Deprecated.
      This method is public only for testing. Use private method #conversionCharFromFormat(Matcher).
      Returns the conversion character that is in the given format specifier.
      Parameters:
      formatSpecifier - a format specifier
      Returns:
      the conversion character that is in the given format specifier