Class InstantPatternDynamicFormatter.DynamicPatternSequence
- java.lang.Object
-
- org.apache.logging.log4j.core.util.internal.instant.InstantPatternDynamicFormatter.PatternSequence
-
- org.apache.logging.log4j.core.util.internal.instant.InstantPatternDynamicFormatter.DynamicPatternSequence
-
- Enclosing class:
- InstantPatternDynamicFormatter
static final class InstantPatternDynamicFormatter.DynamicPatternSequence extends InstantPatternDynamicFormatter.PatternSequence
Creates formatters that useDateTimeFormatter.
-
-
Field Summary
-
Fields inherited from class org.apache.logging.log4j.core.util.internal.instant.InstantPatternDynamicFormatter.PatternSequence
pattern, precision
-
-
Constructor Summary
Constructors Constructor Description DynamicPatternSequence(java.lang.String singlePattern)DynamicPatternSequence(java.lang.String pattern, java.time.temporal.ChronoUnit precision)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) InstantPatternFormattercreateFormatter(java.util.Locale locale, java.util.TimeZone timeZone)private static java.time.temporal.ChronoUnitpatternPrecision(java.lang.String singlePattern)private static java.lang.StringremovePadding(java.lang.String content)(package private) @Nullable InstantPatternDynamicFormatter.PatternSequencetryMerge(InstantPatternDynamicFormatter.PatternSequence other, java.time.temporal.ChronoUnit thresholdPrecision)Tries to merge two pattern sequences.private static voidvalidateContent(java.lang.String content)-
Methods inherited from class org.apache.logging.log4j.core.util.internal.instant.InstantPatternDynamicFormatter.PatternSequence
equals, escapeLiteral, hashCode, isConstantForDurationOf, mergePatterns, toString
-
-
-
-
Constructor Detail
-
DynamicPatternSequence
DynamicPatternSequence(java.lang.String singlePattern)
- Parameters:
singlePattern- ADateTimeFormatterpattern containing a single letter.
-
DynamicPatternSequence
DynamicPatternSequence(java.lang.String pattern, java.time.temporal.ChronoUnit precision)- Parameters:
pattern- AnyDateTimeFormatterpattern.precision- The maximum interval of time over which this pattern is constant.
-
-
Method Detail
-
createFormatter
InstantPatternFormatter createFormatter(java.util.Locale locale, java.util.TimeZone timeZone)
- Specified by:
createFormatterin classInstantPatternDynamicFormatter.PatternSequence
-
tryMerge
@Nullable InstantPatternDynamicFormatter.PatternSequence tryMerge(InstantPatternDynamicFormatter.PatternSequence other, java.time.temporal.ChronoUnit thresholdPrecision)
Description copied from class:InstantPatternDynamicFormatter.PatternSequenceTries to merge two pattern sequences.If not {@link null}, the pattern sequence returned by this method must:
- Have a
InstantPatternDynamicFormatter.PatternSequence.precision, which is the minimum of the precisions of the two merged sequences. - Create formatters that are equivalent to the concatenation of the formatters produced by the two merged sequences.
The returned pattern sequence should try to achieve these two goals:
- Create formatters which are faster than the concatenation of the formatters produced by the two merged sequences.
-
It should be {@link null} if one of the pattern sequences is effectively constant over
thresholdPrecision, but the other one is not.
- Specified by:
tryMergein classInstantPatternDynamicFormatter.PatternSequence- Parameters:
other- A pattern sequence.thresholdPrecision- A precision threshold to determine effectively constant sequences. This prevents merging effectively constant and dynamic pattern sequences.- Returns:
- A merged formatter factory or
nullif merging is not possible.
- Have a
-
patternPrecision
private static java.time.temporal.ChronoUnit patternPrecision(java.lang.String singlePattern)
- Parameters:
singlePattern- a single-letter directive singlePattern complying (e.g.,H,HH, orpHH)- Returns:
- the time precision of the directive
-
validateContent
private static void validateContent(java.lang.String content)
-
removePadding
private static java.lang.String removePadding(java.lang.String content)
-
-