Class FormatUtil
java.lang.Object
org.checkerframework.checker.formatter.util.FormatUtil
This class provides a collection of utilities to ease working with format strings.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
asFormat
(String format, ConversionCategory... cc) Returns the first argument if the format string is satisfiable, and if the format's parameters match the passedConversionCategory
s.static char
conversionCharFromFormat
(String formatSpecifier) Deprecated.This method is public only for testing.static ConversionCategory[]
formatParameterCategories
(String format) Returns aConversionCategory
for every conversion found in the format string.static void
tryFormatSatisfiability
(String format) Throws an exception if the format is not syntactically valid.
-
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 passedConversionCategory
s. Otherwise throws an exception.- Parameters:
format
- a format stringcc
- an array of conversion categories- Returns:
- the
format
argument - Throws:
IllegalFormatException
- if the format string is incompatible with the conversion categories
-
tryFormatSatisfiability
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 aConversionCategory
for every conversion found in the format string.Throws an exception if the format is not syntactically valid.
- Throws:
IllegalFormatException
-
conversionCharFromFormat
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
-