FormatOptions

public final class FormatOptions

A structured representation of formatting options compatible with printf style formatting.

This class is immutable and thread safe.

Properties

Link copied to clipboard
public final static int ALL_FLAGS
A mask of all allowed formatting flags.
Link copied to clipboard
public final static int FLAG_LEFT_ALIGN
A formatting flag which specifies that output should be left-aligned within the minimum available width.
Link copied to clipboard
public final static int FLAG_PREFIX_PLUS_FOR_POSITIVE_VALUES
A formatting flag which specifies that for signed numeric output, positive values should be prefixed with an ASCII plus ('+').
Link copied to clipboard
public final static int FLAG_PREFIX_SPACE_FOR_POSITIVE_VALUES
A formatting flag which specifies that for signed numeric output, positive values should be prefixed with an ASCII space (' ').
Link copied to clipboard
public final static int FLAG_SHOW_ALT_FORM
A formatting flag which specifies that output should be shown in a type dependent alternate form.
Link copied to clipboard
public final static int FLAG_SHOW_GROUPING
A formatting flag which specifies that for non-exponential, base-10, numeric output a grouping separator (often a ',') should be used.
Link copied to clipboard
public final static int FLAG_SHOW_LEADING_ZEROS
A formatting flag which specifies that numeric output should be padding with leading zeros as necessary to fill the minimum width.
Link copied to clipboard
public final static int FLAG_UPPER_CASE
A formatting flag which specifies that output should be upper-cased after all other formatting.
Link copied to clipboard
public final static int FLAG_USE_PARENS_FOR_NEGATIVE_VALUES
A formatting flag which specifies that for signed numeric output, negative values should be surrounded by parentheses.
Link copied to clipboard
public final int flags
Link copied to clipboard
public final int precision
Link copied to clipboard
public final static int UNSET
The value used to specify that either width or precision were not specified.
Link copied to clipboard
public final int width

Functions

Link copied to clipboard
@CanIgnoreReturnValue()
public StringBuilder appendPrintfOptions(StringBuilder out)
Appends the data for this options instance in a printf compatible form to the given buffer.
Link copied to clipboard
public boolean areValidFor(FormatChar formatChar)
Validates these options as if they were being applied to the given FormatChar and checks for inconsistencies in flag values.
Link copied to clipboard
public boolean equals(@Nullable() Object o)
Link copied to clipboard
public FormatOptions filter(int allowedFlags, boolean allowWidth, boolean allowPrecision)
Returns a possibly new FormatOptions instance possibly containing a subset of the formatting information.
Link copied to clipboard
public static FormatOptions getDefault()
Returns the default options singleton instance.
Link copied to clipboard
public int getFlags()
Returns the flag bits for this options instance.
Link copied to clipboard
public int getPrecision()
Returns the precision for these options, or UNSET if not specified.
Link copied to clipboard
public int getWidth()
Returns the width for these options, or UNSET if not specified.
Link copied to clipboard
public int hashCode()
Link copied to clipboard
public boolean isDefault()
Returns true if this instance has only default formatting options.
Link copied to clipboard
public static FormatOptions of(int flags, int width, int precision)
Creates a options instance with the given values.
Link copied to clipboard
public static FormatOptions parse(String message, int pos, int end, boolean isUpperCase)
Parses a sub-sequence of a log message to extract and return its options.
Link copied to clipboard
public boolean shouldLeftAlign()
Corresponds to printf flag '-' (incompatible with '0').
Link copied to clipboard
Corresponds to printf flag '+'.
Link copied to clipboard
Corresponds to printf flag ' '.
Link copied to clipboard
public boolean shouldShowAltForm()
Corresponds to printf flag '#'.
Link copied to clipboard
public boolean shouldShowGrouping()
Corresponds to printf flag ','.
Link copied to clipboard
public boolean shouldShowLeadingZeros()
Corresponds to printf flag '0'.
Link copied to clipboard
public boolean shouldUpperCase()
Corresponds to formatting with an upper-case format character.
Link copied to clipboard
public boolean validate(int allowedFlags, boolean allowPrecision)
Validates these options according to the allowed criteria and checks for inconsistencies in flag values.