summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/isode/stroke/component/ComponentXMLTracer.java')
-rw-r--r--src/com/isode/stroke/component/ComponentXMLTracer.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/com/isode/stroke/component/ComponentXMLTracer.java b/src/com/isode/stroke/component/ComponentXMLTracer.java
new file mode 100644
index 0000000..005a937
--- /dev/null
+++ b/src/com/isode/stroke/component/ComponentXMLTracer.java
@@ -0,0 +1,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();
+ }
+} \ No newline at end of file