Class AccumulatingMessageHandler
- java.lang.Object
-
- com.github.oowekyala.ooxml.messages.AccumulatingMessageHandler
-
- All Implemented Interfaces:
XmlMessageHandler,java.lang.AutoCloseable
public abstract class AccumulatingMessageHandler extends java.lang.Object implements XmlMessageHandler, java.lang.AutoCloseable
Accumulates messages and does not display them until the reporter is closed.
-
-
Field Summary
Fields Modifier and Type Field Description protected XmlMessageHandlerbasePrinterprivate java.util.EnumMap<XmlSeverity,java.util.Map<java.lang.String,java.util.List<XmlException>>>entriesprotected XmlSeverityminSeverity-
Fields inherited from interface com.github.oowekyala.ooxml.messages.XmlMessageHandler
NOOP, SYSTEM_ERR
-
-
Constructor Summary
Constructors Constructor Description AccumulatingMessageHandler(XmlMessageHandler basePrinter, XmlSeverity minSeverity)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaccept(XmlException ex)Handle an XML message.voidclose()voidclose(XmlSeverity minSeverityToPrintSummary, XmlSeverity minSeverityToPrintFully)Close the reporter and print the accumulated exceptions.protected voiddontPrint(XmlSeverity severity, java.util.Map<java.lang.String,java.util.List<XmlException>> entriesByMessage)Handle ignored messages.protected voidprintFully(XmlSeverity severity, java.lang.String message, java.util.List<XmlException> entry)Print "fully", the default prints all entries.protected voidprintSummary(XmlSeverity severity, java.lang.String message, java.util.List<XmlException> entry)Print a summary line, not every one of the entries.protected abstract voidprintSummaryLine(java.lang.String kind, XmlSeverity severity, java.lang.String message)
-
-
-
Field Detail
-
entries
private final java.util.EnumMap<XmlSeverity,java.util.Map<java.lang.String,java.util.List<XmlException>>> entries
-
minSeverity
protected final XmlSeverity minSeverity
-
basePrinter
protected final XmlMessageHandler basePrinter
-
-
Constructor Detail
-
AccumulatingMessageHandler
public AccumulatingMessageHandler(XmlMessageHandler basePrinter, XmlSeverity minSeverity)
-
-
Method Detail
-
accept
public void accept(XmlException ex)
Description copied from interface:XmlMessageHandlerHandle an XML message. May throw, ignore, or print to an external stream.- Specified by:
acceptin interfaceXmlMessageHandler- Parameters:
ex- Message to handle
-
printSummaryLine
protected abstract void printSummaryLine(java.lang.String kind, XmlSeverity severity, java.lang.String message)
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
close
public void close(XmlSeverity minSeverityToPrintSummary, XmlSeverity minSeverityToPrintFully)
Close the reporter and print the accumulated exceptions. The two parameters select how entries are printed to thebasePrinter, they are dispatched to the methodsdontPrint(XmlSeverity, Map),printFully(XmlSeverity, String, List)andprintSummary(XmlSeverity, String, List).
-
printFully
protected void printFully(XmlSeverity severity, java.lang.String message, java.util.List<XmlException> entry)
Print "fully", the default prints all entries. This is so that previous errors are not forgotten.- Parameters:
severity- severity of the messagemessage- Message with which the entry was reportedentry- A nonempty list
-
printSummary
protected void printSummary(XmlSeverity severity, java.lang.String message, java.util.List<XmlException> entry)
Print a summary line, not every one of the entries.- Parameters:
severity- severity of the messagemessage- Message with which the entry was reportedentry- A nonempty list
-
dontPrint
protected void dontPrint(XmlSeverity severity, java.util.Map<java.lang.String,java.util.List<XmlException>> entriesByMessage)
Handle ignored messages.- Parameters:
severity- SeverityentriesByMessage- Entries for the given severity, indexed by their message
-
-