blob: 005a937491bc62761d3fe9934d89a22bd84e3859 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*
* Copyright (c) 2010 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
/*
* Copyright (c) 2015 Tarun Gupta.
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
package com.isode.stroke.component;
import com.isode.stroke.component.Component;
import com.isode.stroke.component.CoreComponent;
import com.isode.stroke.base.SafeByteArray;
import com.isode.stroke.signals.Slot1;
public class ComponentXMLTracer {
public ComponentXMLTracer(CoreComponent client) {
client.onDataRead.connect(new Slot1<SafeByteArray>() {
@Override
public void call(SafeByteArray b1) {
printData('<', b1);
}
});
client.onDataWritten.connect(new Slot1<SafeByteArray>() {
@Override
public void call(SafeByteArray b1) {
printData('>', b1);
}
});
}
private static void printData(char direction, final SafeByteArray data) {
printLine(direction);
System.err.println(data);
}
private static void printLine(char c) {
for (int i = 0; i < 80; ++i) {
System.err.print(c);
}
System.err.println();
}
}
|