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

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

    • FormatUtil

      public FormatUtil()
  • Method Details

    • asFormat

      @ReturnsFormat public static String asFormat(String format, ConversionCategory... cc) throws IllegalFormatException
      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 IllegalFormatException
      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) throws IllegalFormatException
      Returns a ConversionCategory for every conversion found in the format string.

      Throws an exception if the format is not syntactically valid.

      Throws:
      IllegalFormatException
    • conversionCharFromFormat

      @Deprecated public static char conversionCharFromFormat(String formatSpecifier)
      Deprecated.
      This method is public only for testing. Use private method #conversionCharFromFormat(Matcher).
      Return 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