in src/main/java/org/apache/log4j/receivers/xml/UtilLoggingXMLDecoder.java [300:437]
private Vector decodeEvents(final Document document) {
Vector events = new Vector();
NodeList eventList = document.getElementsByTagName("record");
for (int eventIndex = 0; eventIndex < eventList.getLength();
eventIndex++) {
Node eventNode = eventList.item(eventIndex);
Logger logger = null;
long timeStamp = 0L;
Level level = null;
String threadName = null;
Object message = null;
String ndc = null;
String[] exception = null;
String className = null;
String methodName = null;
String fileName = null;
String lineNumber = null;
Hashtable properties = new Hashtable();
//format of date: 2003-05-04T11:04:52
//ignore date or set as a property? using millis in constructor instead
NodeList list = eventNode.getChildNodes();
int listLength = list.getLength();
if (listLength == 0) {
continue;
}
for (int y = 0; y < listLength; y++) {
String tagName = list.item(y).getNodeName();
if (tagName.equalsIgnoreCase("logger")) {
logger = Logger.getLogger(getCData(list.item(y)));
}
if (tagName.equalsIgnoreCase("millis")) {
timeStamp = Long.parseLong(getCData(list.item(y)));
}
if (tagName.equalsIgnoreCase("level")) {
level = UtilLoggingLevel.toLevel(getCData(list.item(y)));
}
if (tagName.equalsIgnoreCase("thread")) {
threadName = getCData(list.item(y));
}
if (tagName.equalsIgnoreCase("sequence")) {
properties.put("log4jid", getCData(list.item(y)));
}
if (tagName.equalsIgnoreCase("message")) {
message = getCData(list.item(y));
}
if (tagName.equalsIgnoreCase("class")) {
className = getCData(list.item(y));
}
if (tagName.equalsIgnoreCase("method")) {
methodName = getCData(list.item(y));
}
if (tagName.equalsIgnoreCase("exception")) {
ArrayList exceptionList = new ArrayList();
NodeList exList = list.item(y).getChildNodes();
int exlistLength = exList.getLength();
for (int i2 = 0; i2 < exlistLength; i2++) {
Node exNode = exList.item(i2);
String exName = exList.item(i2).getNodeName();
if (exName.equalsIgnoreCase("message")) {
exceptionList.add(getCData(exList.item(i2)));
}
if (exName.equalsIgnoreCase("frame")) {
NodeList exList2 = exNode.getChildNodes();
int exlist2Length = exList2.getLength();
for (int i3 = 0; i3 < exlist2Length; i3++) {
exceptionList.add(getCData(exList2.item(i3)) + "\n");
}
}
}
if (exceptionList.size() > 0) {
exception =
(String[]) exceptionList.toArray(new String[exceptionList.size()]);
}
}
}
/**
* We add all the additional properties to the properties
* hashtable. Override properties that already exist
*/
if (additionalProperties.size() > 0) {
if (properties == null) {
properties = new Hashtable(additionalProperties);
}
Iterator i = additionalProperties.entrySet().iterator();
while (i.hasNext()) {
Map.Entry e = (Map.Entry) i.next();
properties.put(e.getKey(), e.getValue());
}
}
LocationInfo info;
if ((fileName != null)
|| (className != null)
|| (methodName != null)
|| (lineNumber != null)) {
info = new LocationInfo(fileName, className, methodName, lineNumber);
} else {
info = LocationInfo.NA_LOCATION_INFO;
}
ThrowableInformation throwableInfo = null;
if (exception != null) {
throwableInfo = new ThrowableInformation(exception);
}
LoggingEvent loggingEvent = new LoggingEvent(null,
logger, timeStamp, level, message,
threadName,
throwableInfo,
ndc,
info,
properties);
events.add(loggingEvent);
}
return events;
}