use of net.percederberg.mibble.Mib in project opennms by OpenNMS.
the class Mib2Events method printEvents.
public void printEvents(PrintStream out) throws MarshalException, ValidationException, ParserConfigurationException, SAXException, IOException {
if (m_loader == null) {
throw new IllegalStateException("convert() must be called first");
}
for (Mib mib : m_loader.getAllMibs()) {
if (!mib.isLoaded()) {
continue;
}
Events events = convertMibToEvents(mib, getEffectiveUeiBase());
if (events.getEventCount() < 1) {
System.err.println("No trap or notification definitions found in this MIB (" + mib.getName() + "), exiting");
System.exit(0);
}
if (!m_compat) {
StringWriter writer = new StringWriter();
events.marshal(writer);
stripXmlNameSpace(writer.toString(), out);
} else {
for (Event event : events.getEventCollection()) {
StringWriter writer = new StringWriter();
event.marshal(writer);
ByteArrayOutputStream formattedXml = new ByteArrayOutputStream();
stripXmlNameSpace(writer.toString(), formattedXml);
String noXmlProcessingInstruction = formattedXml.toString().replaceAll("(?m)<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>\n", "");
out.print(noXmlProcessingInstruction.replaceAll("dest=\"logndisplay\"", "dest='logndisplay'"));
}
}
}
}
Aggregations