Assert.isNotNull(input, "input"); //$NON-NLS-1$
Assert.isNotNull(collector, "collector"); //$NON-NLS-1$
try {
InputStream eventSetIS = getClass().getResourceAsStream(FILENAME_EVENTSET_XML);
XMLReader reader = XMLReaderFactory.createXMLReader();
XMLFilter filter = new Log4JXMLFilter(collector);
filter.setParent(reader);
filter.setEntityResolver(new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
if ((systemId != null) && systemId.toLowerCase().endsWith(FILENAME_LOG4J_DTD)) {
// Looking for the Log4J DTD?
InputStream is = getClass().getResourceAsStream(FILENAME_LOG4J_DTD);
return new InputSource(is);
}
if ((systemId != null) && systemId.equals("%file%")) { //$NON-NLS-1$
// Loading the log file
InputSource src = new InputSource(input);
// Apply the passed encoding
IHasEncoding enc = (IHasEncoding) log.getAdapter(IHasEncoding.class);
src.setEncoding(enc.getEncoding());
return src;
}
return null;
}
});
filter.parse(new InputSource(eventSetIS));
} catch (OperationCanceledException e) {
// Thrown by Log4JXMLFilter to cancel parsing
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, Log4JDialectPlugin.PLUGIN_ID,
NLS.bind(Messages.Log4JDialect_error_parsingFailed,