UtilLoggingXmlLogImporter extends AbstractPluginableElement implements LogImporter { public void decodeEvents(final String document, LogDataCollector collector, ParsingContext parsingContext) { if (document != null) { if (document.trim().equals("")) { return; } String newDoc; String newPartialEvent; String partialEvent = (String) parsingContext.getCustomConextProperties().get(PARTIAL_EVENT); if (document.lastIndexOf(RECORD_END) == -1) { partialEvent = partialEvent + document; parsingContext.getCustomConextProperties().put(PARTIAL_EVENT, partialEvent); return; } if (document.lastIndexOf(RECORD_END) + RECORD_END.length() < document.length()) { newDoc = document.substring(0, document.lastIndexOf(RECORD_END) + RECORD_END.length()); newPartialEvent = document.substring(document.lastIndexOf(RECORD_END) + RECORD_END.length()); parsingContext.getCustomConextProperties().put(PARTIAL_EVENT, newPartialEvent); } else { newDoc = document; } if (partialEvent != null) { newDoc = partialEvent + newDoc; } Document doc = parse(newDoc, (DocumentBuilder) parsingContext.getCustomConextProperties().get(DOC_BUILDER)); if (doc == null) { return; } decodeEvents(doc, collector, parsingContext); } } UtilLoggingXmlLogImporter(); @Override void init(Properties properties); @Override void importLogs(InputStream in, LogDataCollector collector, ParsingContext parsingContext); void decodeEvents(final String document, LogDataCollector collector, ParsingContext parsingContext); @Override String getKeyStrokeAccelelator(); @Override int getMnemonic(); @Override Icon getIcon(); @Override TableColumns[] getTableColumnsToUse(); @Override void initParsingContext(ParsingContext parsingContext); @Override int getApiVersion();  }
@Test public void testDecodeEvents() throws IOException, InitializationException { InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("julxml/julXmlException.xml"); ParsingContext parsingContext = new ParsingContext("A"); importer.initParsingContext(parsingContext); ProxyLogDataCollector logDataCollector = new ProxyLogDataCollector(); String expected = "msg\n" + "java.util.UnknownFormatConversionException: Conversion = 'i'\n" + "\tat java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2646)\n" + "\tat java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2675)\n" + "\tat java.util.Formatter.parse(Formatter.java:2528)\n" + "\tat java.util.Formatter.format(Formatter.java:2469)\n" + "\tat java.util.Formatter.format(Formatter.java:2423)\n" + "\tat java.lang.String.format(String.java:2797)\n" + "\tat ThrowAndLog.main(ThrowAndLog.java:23)"; importer.importLogs(resourceAsStream, logDataCollector, parsingContext); LogData[] logDates = logDataCollector.getLogData(); assertEquals(1, logDates.length); LogData logData = logDataCollector.getLogData()[0]; assertEquals(expected, logData.getMessage()); }