Class FormattingInfo
java.lang.Object
org.apache.logging.log4j.core.pattern.FormattingInfo
Modifies the output of a pattern converter for a specified minimum and maximum width and alignment.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final FormattingInfo
Default instance.static final FormattingInfo[]
Empty array.private final boolean
Alignment.private final boolean
Left vs.private final int
Maximum length.private final int
Minimum length.private static final char[]
Array of spaces.private final boolean
Use zero-padding instead whitespace paddingprivate static final char[]
Array of zeros. -
Constructor Summary
ConstructorsConstructorDescriptionFormattingInfo
(boolean leftAlign, int minLength, int maxLength, boolean leftTruncate) Creates new instance.FormattingInfo
(boolean leftAlign, int minLength, int maxLength, boolean leftTruncate, boolean zeroPad) Creates new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
format
(int fieldStart, StringBuilder buffer) Adjust the content of the buffer based on the specified lengths and alignment.static FormattingInfo
Gets default instance.int
Get maximum length.int
Get minimum length.boolean
Determine if left aligned.boolean
Determine if left truncated.boolean
Determine if zero-padded.toString()
Returns a String suitable for debugging.
-
Field Details
-
SPACES
private static final char[] SPACESArray of spaces. -
ZEROS
private static final char[] ZEROSArray of zeros. -
DEFAULT
Default instance. -
minLength
private final int minLengthMinimum length. -
maxLength
private final int maxLengthMaximum length. -
leftAlign
private final boolean leftAlignAlignment. -
leftTruncate
private final boolean leftTruncateLeft vs. right-hand side truncation. -
zeroPad
private final boolean zeroPadUse zero-padding instead whitespace padding -
EMPTY_ARRAY
Empty array.
-
-
Constructor Details
-
FormattingInfo
public FormattingInfo(boolean leftAlign, int minLength, int maxLength, boolean leftTruncate) Creates new instance.- Parameters:
leftAlign
- left align if true.minLength
- minimum length.maxLength
- maximum length.leftTruncate
- truncates to the left if true
-
FormattingInfo
public FormattingInfo(boolean leftAlign, int minLength, int maxLength, boolean leftTruncate, boolean zeroPad) Creates new instance.- Parameters:
leftAlign
- left align if true.minLength
- minimum length.maxLength
- maximum length.leftTruncate
- truncates to the left if truezeroPad
- use zero-padding instead of whitespace-padding
-
-
Method Details
-
getDefault
Gets default instance.- Returns:
- default instance.
-
isLeftAligned
public boolean isLeftAligned()Determine if left aligned.- Returns:
- true if left aligned.
-
isLeftTruncate
public boolean isLeftTruncate()Determine if left truncated.- Returns:
- true if left truncated.
-
isZeroPad
public boolean isZeroPad()Determine if zero-padded.- Returns:
- true if zero-padded.
-
getMinLength
public int getMinLength()Get minimum length.- Returns:
- minimum length.
-
getMaxLength
public int getMaxLength()Get maximum length.- Returns:
- maximum length.
-
format
Adjust the content of the buffer based on the specified lengths and alignment.- Parameters:
fieldStart
- start of field in buffer.buffer
- buffer to be modified.
-
toString
Returns a String suitable for debugging.
-