Class FormattingInfo
- java.lang.Object
-
- org.apache.logging.log4j.core.pattern.FormattingInfo
-
public final class FormattingInfo extends java.lang.Object
Modifies the output of a pattern converter for a specified minimum and maximum width and alignment.
-
-
Field Summary
Fields Modifier and Type Field Description private static FormattingInfo
DEFAULT
Default instance.static FormattingInfo[]
EMPTY_ARRAY
Empty array.private boolean
leftAlign
Alignment.private boolean
leftTruncate
Left vs.private int
maxLength
Maximum length.private int
minLength
Minimum length.private static char[]
SPACES
Array of spaces.private boolean
zeroPad
Use zero-padding instead whitespace paddingprivate static char[]
ZEROS
Array of zeros.
-
Constructor Summary
Constructors Constructor Description FormattingInfo(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
format(int fieldStart, java.lang.StringBuilder buffer)
Adjust the content of the buffer based on the specified lengths and alignment.static FormattingInfo
getDefault()
Gets default instance.int
getMaxLength()
Get maximum length.int
getMinLength()
Get minimum length.boolean
isLeftAligned()
Determine if left aligned.boolean
isLeftTruncate()
Determine if left truncated.boolean
isZeroPad()
Determine if zero-padded.java.lang.String
toString()
Returns a String suitable for debugging.
-
-
-
Field Detail
-
SPACES
private static final char[] SPACES
Array of spaces.
-
ZEROS
private static final char[] ZEROS
Array of zeros.
-
DEFAULT
private static final FormattingInfo DEFAULT
Default instance.
-
minLength
private final int minLength
Minimum length.
-
maxLength
private final int maxLength
Maximum length.
-
leftAlign
private final boolean leftAlign
Alignment.
-
leftTruncate
private final boolean leftTruncate
Left vs. right-hand side truncation.
-
zeroPad
private final boolean zeroPad
Use zero-padding instead whitespace padding
-
EMPTY_ARRAY
public static final FormattingInfo[] EMPTY_ARRAY
Empty array.
-
-
Constructor Detail
-
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 Detail
-
getDefault
public static FormattingInfo 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
public void format(int fieldStart, java.lang.StringBuilder buffer)
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
public java.lang.String toString()
Returns a String suitable for debugging.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a String suitable for debugging.
-
-