in src/org/jetbrains/tfsIntegration/core/LogDecoder.java [49:100]
public static List<Entry> decode(InputStream inputStream) throws IOException {
List<Entry> result = new ArrayList<Entry>();
BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
String line;
Map<MessageType, String> session = null;
MessageType currentType = null;
StringBuilder accumulated = new StringBuilder();
while ((line = r.readLine()) != null) {
MessageType lineType = null;
for (MessageType type : MessageType.values()) {
if (line.contains(type.getPrefix())) {
lineType = type;
int beginIndex = line.indexOf(type.getPrefix()) + type.getPrefix().length();
int endIndex = line.lastIndexOf(type.getSuffix());
line = line.substring(beginIndex, endIndex);
break;
}
}
if (lineType == null) {
result.add(new UnknownEntry(line));
continue;
}
if (session == null) {
session = new HashMap<MessageType, String>();
}
else if (session.containsKey(currentType)) {
result.add(new SessionEntry(session));
session = new HashMap<MessageType, String>();
}
if (currentType != null && lineType != currentType) {
byte[] unescaped = unescape(accumulated.toString());
String unzipped = null;
if (currentType == MessageType.ContentIn) {
unzipped = tryUnzip(unescaped);
}
String display = unzipped != null ? unzipped : new String(unescaped);
display = tryPrettyPrintXml(display);
session.put(currentType, display);
accumulated = new StringBuilder();
}
accumulated.append(line);
currentType = lineType;
}
if (session != null) {
result.add(new SessionEntry(session));
}
return result;
}