Package com.google.common.flogger.parser
Class MessageParser
- java.lang.Object
-
- com.google.common.flogger.parser.MessageParser
-
- Direct Known Subclasses:
BraceStyleMessageParser,PrintfMessageParser
public abstract class MessageParser extends Object
Base class from which any specific message parsers are derived (e.g.PrintfMessageParserandBraceStyleMessageParser).
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_ARG_COUNTThe maximum allowed index (this should correspond to the MAX_ALLOWED_WIDTH inFormatOptionsbecause at times it is ambiguous as to which is being parsed).
-
Constructor Summary
Constructors Constructor Description MessageParser()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description protected abstract <T> voidparseImpl(MessageBuilder<T> builder)Abstract parse method implemented by specific subclasses to modify parsing behavior.abstract voidunescape(StringBuilder out, String message, int start, int end)Appends the unescaped literal representation of the given message string (assumed to be escaped according to this parser's escaping rules).
-
-
-
Field Detail
-
MAX_ARG_COUNT
public static final int MAX_ARG_COUNT
The maximum allowed index (this should correspond to the MAX_ALLOWED_WIDTH inFormatOptionsbecause at times it is ambiguous as to which is being parsed).- See Also:
- Constant Field Values
-
-
Method Detail
-
parseImpl
protected abstract <T> void parseImpl(MessageBuilder<T> builder) throws ParseException
Abstract parse method implemented by specific subclasses to modify parsing behavior.Note that when extending parsing behavior, it is expected that specific parsers such as
DefaultPrintfMessageParserorDefaultBraceStyleMessageParserwill be sub-classed. Extending this class directly is only necessary when an entirely new type of format needs to be supported (which should be extremely rare).Implementations of this method are required to invoke the
MessageBuilder.addParameterImpl(int, int, com.google.common.flogger.parameter.Parameter)method of the supplied builder once for each parameter place-holder in the message.- Throws:
ParseException
-
unescape
public abstract void unescape(StringBuilder out, String message, int start, int end)
Appends the unescaped literal representation of the given message string (assumed to be escaped according to this parser's escaping rules). This method is designed to be invoked from a callback method in aMessageBuilderinstance.- Parameters:
out- the destination into which to append charactersmessage- the escaped log messagestart- the start index (inclusive) in the log messageend- the end index (exclusive) in the log message
-
-