Index: trunk/EventBenchConsole/.classpath
===================================================================
--- trunk/EventBenchConsole/.classpath	(revision 1)
+++ trunk/EventBenchConsole/.classpath	(revision 1)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="lib" path="lib/collections-generic-4.01.jar"/>
+	<classpathentry kind="lib" path="lib/jdom.jar"/>
+	<classpathentry kind="lib" path="lib/colt-1.2.0.jar"/>
+	<classpathentry kind="lib" path="lib/concurrent-1.3.4.jar"/>
+	<classpathentry kind="lib" path="lib/j3d-core-1.3.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-3d-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-3d-demos-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-algorithms-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-api-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-graph-impl-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-io-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-jai-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-jai-samples-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-samples-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-visualization-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/stax-api-1.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/vecmath-1.3.1.jar"/>
+	<classpathentry kind="lib" path="lib/wstx-asl-3.2.6.jar"/>
+	<classpathentry kind="lib" path="lib/commons-codec-1.5.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/JavaHelperLib"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/EventBenchCore"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: trunk/EventBenchConsole/.project
===================================================================
--- trunk/EventBenchConsole/.project	(revision 1)
+++ trunk/EventBenchConsole/.project	(revision 1)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>EventBenchConsole</name>
+	<comment></comment>
+	<projects>
+		<project>JavaHelperLib</project>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>net.sourceforge.metrics.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>net.sourceforge.metrics.nature</nature>
+	</natures>
+</projectDescription>
Index: trunk/EventBenchConsole/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/EventBenchConsole/.settings/org.eclipse.jdt.core.prefs	(revision 1)
+++ trunk/EventBenchConsole/.settings/org.eclipse.jdt.core.prefs	(revision 1)
@@ -0,0 +1,12 @@
+#Wed May 26 13:38:36 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Index: trunk/EventBenchConsole/rules/ruleDoctype.dtd
===================================================================
--- trunk/EventBenchConsole/rules/ruleDoctype.dtd	(revision 1)
+++ trunk/EventBenchConsole/rules/ruleDoctype.dtd	(revision 1)
@@ -0,0 +1,155 @@
+<!ENTITY WM_NULL "0">
+<!ENTITY WM_CREATE "1">
+<!ENTITY WM_DESTROY "2">
+<!ENTITY WM_MOVE "3">
+<!ENTITY WM_SIZE "5">
+<!ENTITY WM_ACTIVATE "6">
+<!ENTITY WM_SETFOCUS "7">
+<!ENTITY WM_KILLFOCUS "8">
+<!ENTITY WM_ENABLE "10">
+<!ENTITY WM_SETREDRAW "11">
+<!ENTITY WM_SETTEXT "12">
+<!ENTITY WM_GETTEXT "13">
+<!ENTITY WM_GETTEXTLENGTH "14">
+<!ENTITY WM_PAINT "15">
+<!ENTITY WM_CLOSE "16">
+<!ENTITY WM_QUERYENDSESSION "17">
+<!ENTITY WM_QUIT "18">
+<!ENTITY WM_QUERYOPEN "19">
+<!ENTITY WM_ERASEBKGND "20">
+<!ENTITY WM_SYSCOLORCHANGE "21">
+<!ENTITY WM_ENDSESSION "22">
+<!ENTITY WM_SHOWWINDOW "24">
+<!ENTITY WM_CTLCOLOR "25">
+<!ENTITY WM_WININICHANGE "26">
+<!ENTITY WM_DEVMODECHANGE "27">
+<!ENTITY WM_ACTIVATEAPP "28">
+<!ENTITY WM_FONTCHANGE "29">
+<!ENTITY WM_TIMECHANGE "30">
+<!ENTITY WM_CANCELMODE "31">
+<!ENTITY WM_SETCURSOR "32">
+<!ENTITY WM_MOUSEACTIVATE "33">
+<!ENTITY WM_CHILDACTIVATE "34">
+<!ENTITY WM_QUEUESYNC "35">
+<!ENTITY WM_GETMINMAXINFO "36">
+<!ENTITY WM_PAINTICON "38">
+<!ENTITY WM_ICONERASEBKGND "39">
+<!ENTITY WM_NEXTDLGCTL "40">
+<!ENTITY WM_SPOOLERSTATUS "42">
+<!ENTITY WM_DRAWITEM "43">
+<!ENTITY WM_MEASUREITEM "44">
+<!ENTITY WM_DELETEITEM "45">
+<!ENTITY WM_VKEYTOITEM "46">
+<!ENTITY WM_CHARTOITEM "47">
+<!ENTITY WM_SETFONT "48">
+<!ENTITY WM_GETFONT "49">
+<!ENTITY WM_SETHOTKEY "50">
+<!ENTITY WM_GETHOTKEY "51">
+<!ENTITY WM_QUERYDRAGICON "55">
+<!ENTITY WM_COMPAREITEM "57">
+<!ENTITY WM_GETOBJECT "61">
+<!ENTITY WM_COMPACTING "65">
+<!ENTITY WM_COMMNOTIFY "68">
+<!ENTITY WM_WINDOWPOSCHANGING "70">
+<!ENTITY WM_WINDOWPOSCHANGED "71">
+<!ENTITY WM_POWER "72">
+<!ENTITY WM_COPYDATA "74">
+<!ENTITY WM_CANCELJOURNAL "75">
+<!ENTITY WM_NOTIFY "78">
+<!ENTITY WM_INPUTLANGCHANGEREQUEST "80">
+<!ENTITY WM_INPUTLANGCHANGE "81">
+<!ENTITY WM_TCARD "82">
+<!ENTITY WM_HELP "83">
+<!ENTITY WM_USERCHANGED "84">
+<!ENTITY WM_NOTIFYFORMAT "85">
+<!ENTITY WM_CONTEXTMENU "123">
+<!ENTITY WM_STYLECHANGING "124">
+<!ENTITY WM_STYLECHANGED "125">
+<!ENTITY WM_DISPLAYCHANGE "126">
+<!ENTITY WM_GETICON "127">
+<!ENTITY WM_SETICON "128">
+<!ENTITY WM_NCCREATE "129">
+<!ENTITY WM_NCDESTROY "130">
+<!ENTITY WM_NCCALCSIZE "131">
+<!ENTITY WM_NCHITTEST "132">
+<!ENTITY WM_NCPAINT "133">
+<!ENTITY WM_NCACTIVATE "134">
+<!ENTITY WM_GETDLGCODE "135">
+<!ENTITY WM_SYNCPAINT "136">
+<!ENTITY WM_NCMOUSEMOVE "160">
+<!ENTITY WM_NCLBUTTONDOWN "161">
+<!ENTITY WM_NCLBUTTONUP "162">
+<!ENTITY WM_NCLBUTTONDBLCLK "163">
+<!ENTITY WM_NCRBUTTONDOWN "164">
+<!ENTITY WM_NCRBUTTONUP "165">
+<!ENTITY WM_NCRBUTTONDBLCLK "166">
+<!ENTITY WM_NCMBUTTONDOWN "167">
+<!ENTITY WM_NCMBUTTONUP "168">
+<!ENTITY WM_NCMBUTTONDBLCLK "169">
+<!ENTITY WM_NCXBUTTONDOWN "171">
+<!ENTITY WM_NCXBUTTONUP "172">
+<!ENTITY WM_NCXBUTTONDBLCLK "173">
+<!ENTITY BM_CLICK "245">
+<!ENTITY WM_INPUT "255">
+<!ENTITY WM_KEYDOWN "256">
+<!ENTITY WM_KEYFIRST "256">
+<!ENTITY WM_KEYUP "257">
+<!ENTITY WM_CHAR "258">
+<!ENTITY WM_DEADCHAR "259">
+<!ENTITY WM_SYSKEYDOWN "260">
+<!ENTITY WM_SYSKEYUP "261">
+<!ENTITY WM_SYSCHAR "262">
+<!ENTITY WM_SYSDEADCHAR "263">
+<!ENTITY WM_KEYLAST "264">
+<!ENTITY WM_WNT_CONVERTREQUESTEX "265">
+<!ENTITY WM_CONVERTREQUEST "266">
+<!ENTITY WM_CONVERTRESULT "267">
+<!ENTITY WM_INTERIM "268">
+<!ENTITY WM_IME_STARTCOMPOSITION "269">
+<!ENTITY WM_IME_ENDCOMPOSITION "270">
+<!ENTITY WM_IME_COMPOSITION "271">
+<!ENTITY WM_IME_KEYLAST "271">
+<!ENTITY WM_INITDIALOG "272">
+<!ENTITY WM_COMMAND "273">
+<!ENTITY WM_SYSCOMMAND "274">
+<!ENTITY WM_TIMER "275">
+<!ENTITY WM_HSCROLL "276">
+<!ENTITY WM_VSCROLL "277">
+<!ENTITY WM_INITMENU "278">
+<!ENTITY WM_INITMENUPOPUP "279">
+<!ENTITY WM_MENUSELECT "287">
+<!ENTITY WM_MENUCHAR "288">
+<!ENTITY WM_ENTERIDLE "289">
+<!ENTITY WM_MENURBUTTONUP "290">
+<!ENTITY WM_MENUDRAG "291">
+<!ENTITY WM_MENUGETOBJECT "292">
+<!ENTITY WM_UNINTMENUPOPUP "293">
+<!ENTITY WM_MENUCOMMAND "294">
+<!ENTITY WM_CHANGEUISTATE "295">
+<!ENTITY WM_UPDATEUISTATE "296">
+<!ENTITY WM_QUERYUISTATE "297">
+<!ENTITY WM_CTLCOLORMSGBOX "306">
+<!ENTITY WM_CTLCOLOREDIT "307">
+<!ENTITY WM_CTLCOLORLISTBOX "308">
+<!ENTITY WM_CTLCOLORBTN "309">
+<!ENTITY WM_CTLCLOLORDLG "310">
+<!ENTITY WM_CTLCOLORSCROLLBAR "311">
+<!ENTITY WM_CTLCOLORSTATIC "312">
+<!ENTITY CB_SHOWDROPDOWN "335">
+<!ENTITY WM_MOUSEFIRST "512">
+<!ENTITY WM_MOUSEMOVE "512">
+<!ENTITY WM_LBUTTONDOWN "513">
+<!ENTITY WM_LBUTTONUP "514">
+<!ENTITY WM_LBUTTONDBLCLK "515">
+<!ENTITY WM_RBUTTONDOWN "516">
+<!ENTITY WM_RBUTTONUP "517">
+<!ENTITY WM_RBUTTONDBLCLK "518">
+<!ENTITY WM_MBUTTONDOWN "519">
+<!ENTITY WM_MBUTTONUP "520">
+<!ENTITY WM_MBUTTONDBLCLK "521">
+<!ENTITY WM_MOUSELAST "521">
+<!ENTITY WM_MOUSEWHEEL "522">
+<!ENTITY WM_XBUTTONDOWN "523">
+<!ENTITY WM_XBUTTONUP "524">
+<!ENTITY WM_XBUTTONDBLCLK "525">
+<!ENTITY TBM_SETPOS "1029">
Index: trunk/EventBenchConsole/rules/ruleSchema.xsd
===================================================================
--- trunk/EventBenchConsole/rules/ruleSchema.xsd	(revision 1)
+++ trunk/EventBenchConsole/rules/ruleSchema.xsd	(revision 1)
@@ -0,0 +1,207 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<xs:schema targetNamespace="ul:rules"
+    elementFormDefault="qualified"
+    xmlns="ul:rules"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+>
+
+  <xs:element name="rules">
+    <xs:complexType>
+      <xs:sequence minOccurs="0" maxOccurs="unbounded">
+        <xs:element name="rule" type="ruleType"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+
+  <!-- rule type definition -->
+  <xs:complexType name="ruleType">
+    <xs:sequence>
+      <xs:element name="msg" type="msgType" minOccurs="0" maxOccurs="unbounded"/>
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:element name="genMsg" type="genMsgType"/>
+        <xs:element name="genMsgSeq" type="genMsgSeqType"/>
+      </xs:choice>
+      <xs:element name="idinfo" type="varType" minOccurs="0" maxOccurs="1"/>
+    </xs:sequence>
+    <xs:attribute name="name" type="xs:string" use="optional"/>
+  </xs:complexType>
+
+  <!-- message type definition -->
+  <xs:complexType name="msgType">
+    <xs:sequence minOccurs="0" maxOccurs="1">
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:element name="equals" type="equalsType"/>
+        <xs:element name="equalsSeq" type="equalsSeqType"/>
+      </xs:choice>
+      <xs:choice minOccurs="0" maxOccurs="unbounded">
+        <xs:element name="store" type="storeType"/>
+        <xs:element name="storeSeq" type="storeSeqType"/>
+      </xs:choice>
+    </xs:sequence>
+    <xs:attribute name="type" type="xs:int" use="required"/>
+    <!-- problem: should be strings like WM_LBUTTONDOWN, but program needs ints -->
+    <!--<xs:attribute name="type" type="xs:string" use="required"/>-->
+    <xs:attribute name="multiple" type="xs:boolean" use="optional"/>
+  </xs:complexType>
+  
+  <!-- storage types for message nodes -->
+  <!-- a restriction forbidding "this" would be nice -->
+  <xs:complexType name="storeType">
+    <xs:sequence>
+      <xs:element name="resolveHwnd" type="resolveTargetType" minOccurs="0" maxOccurs="unbounded"/>
+    </xs:sequence>
+    <xs:attribute name="var" use="required" type="storVarName"/>
+  </xs:complexType>
+  <xs:complexType name="storeSeqType">
+    <xs:sequence>
+      <xs:element name="resolveHwnd" type="resolveTargetType" minOccurs="0" maxOccurs="unbounded"/>
+    </xs:sequence>
+    <xs:attribute name="varSeq" use="required" type="storVarName"/>
+  </xs:complexType>
+  <xs:complexType name="resolveTargetType">
+    <xs:attribute name="param" type="xs:string"/>
+    <xs:attribute name="storeParam" type="xs:string"/>
+  </xs:complexType>
+  
+  <!-- equals type for message nodes -->
+  <xs:complexType name="equalsType">
+    <xs:sequence minOccurs="2" maxOccurs="2">
+      <xs:group ref="valueGroup"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="equalsSeqType">
+    <xs:sequence>
+      <xs:element name="seqValue" type="seqValueType"/>
+      <xs:choice>
+        <xs:group ref="seqValueGroup"/>
+      </xs:choice>
+    </xs:sequence>
+  </xs:complexType>
+
+  <!-- types for generating messages -->
+  <xs:complexType name="genMsgType">
+    <xs:choice>
+      <xs:sequence>
+        <xs:element name="type" type="varType"/>
+        <xs:element name="target" type="varType"/>
+        <xs:element name="LPARAM" type="PARAMtype" minOccurs="0" maxOccurs="1"/>
+        <xs:element name="WPARAM" type="PARAMtype" minOccurs="0" maxOccurs="1"/>
+      </xs:sequence>
+      <xs:element name="storedVar">
+        <xs:complexType>
+          <xs:attribute name="obj" type="xs:string"/>
+        </xs:complexType>
+      </xs:element>
+    </xs:choice>
+    <xs:attribute name="delay" type="xs:int" use="required"/>
+  </xs:complexType>
+  <xs:complexType name="genMsgSeqType">
+    <xs:choice>
+      <xs:sequence>
+        <xs:element name="type" type="seqType"/>
+        <!-- target must be a variable! -->
+        <xs:element name="target">
+          <xs:complexType >
+            <xs:sequence>
+              <xs:element name="seqValue" type="seqValueType"/>
+            </xs:sequence>
+          </xs:complexType>
+        </xs:element>        
+        <xs:element name="LPARAM" type="seqPARAMtype" minOccurs="0" maxOccurs="1"/>
+        <xs:element name="WPARAM" type="seqPARAMtype" minOccurs="0" maxOccurs="1"/>
+      </xs:sequence>
+      <xs:element name="storedSeqVar">
+        <xs:complexType>
+          <xs:attribute name="seqObj" type="xs:string"/>
+        </xs:complexType>
+      </xs:element>
+    </xs:choice>
+    <xs:attribute name="delay" type="xs:int" use="required"/>
+  </xs:complexType>
+
+  <xs:complexType name="PARAMtype">
+    <xs:choice>
+      <xs:group ref="valueGroup"/>
+      <xs:sequence>
+        <xs:element name="LOWORD" type="varType"/>
+        <xs:element name="HIWORD" type="varType"/>
+      </xs:sequence>
+    </xs:choice>
+  </xs:complexType>
+  
+  <xs:complexType name="seqPARAMtype">
+    <xs:choice>
+      <xs:group ref="seqValueGroup"/>
+      <xs:sequence>
+        <xs:element name="LOWORD" type="seqType"/>
+        <xs:element name="HIWORD" type="seqType"/>
+      </xs:sequence>
+    </xs:choice>
+  </xs:complexType>
+  
+  
+  <xs:complexType name="seqValueType">
+    <xs:attribute name ="seqObj" type="xs:string" use="required"/>
+    <xs:attribute name ="param" type="xs:string" use="required"/>
+  </xs:complexType>
+
+  <!-- values that can be used by equals and genMsg nodes -->
+  <xs:group name="valueGroup">
+    <xs:choice>
+      <xs:element name="paramValue" type="paramValueType"/>
+      <xs:element name="constValue" type="constValueType"/>
+      <xs:element name="winInfoValue" type ="winInfoValueType"/>
+      <xs:element name="msgInfoValue" type="msgInfoType"/>
+    </xs:choice>
+  </xs:group>
+  <xs:complexType name="varType">
+    <xs:group ref="valueGroup"/>
+  </xs:complexType>
+  
+  <xs:group name="seqValueGroup">
+    <xs:choice>
+      <xs:element name="constValue" type="constValueType"/>
+      <xs:element name="seqValue" type="seqValueType"/>
+    </xs:choice>
+  </xs:group>
+  <xs:complexType name="seqType">
+    <xs:group ref="seqValueGroup"/>
+  </xs:complexType>
+  
+  <xs:complexType name="paramValueType">
+    <xs:attribute name="obj" type="xs:string" use="required"/>
+    <xs:attribute name="param" type="xs:string" use="required"/>
+  </xs:complexType>
+  <xs:complexType name="constValueType">
+    <xs:attribute name="value" use="required"/>
+  </xs:complexType>
+  <xs:complexType name="winInfoValueType">
+    <xs:attribute name="obj" type="xs:string" use="required"/>
+    <xs:attribute name="winParam" type="winParamType" use="required"/>
+  </xs:complexType>
+  <xs:complexType name="msgInfoType">
+    <xs:attribute name="obj" type="xs:string" use="required"/>
+    <xs:attribute name="msgParam" type="msgParamType" use="required"/>
+  </xs:complexType>
+  <xs:simpleType name="winParamType">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="class"/>
+      <xs:enumeration value="resourceId"/>
+      <xs:enumeration value="hwnd"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:simpleType name="msgParamType">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="type"/>
+      <xs:enumeration value="target"/>
+    </xs:restriction>
+  </xs:simpleType>
+  
+
+  <xs:simpleType name="storVarName">
+    <xs:restriction base="xs:string">
+      <!-- this regex is formally not supported by XMLSchema, als look-arounds and \b are not supported :/ -->
+      <xs:pattern value="(?:(?!(?>\bthis\b))\w)+"/>
+    </xs:restriction>
+  </xs:simpleType>
+</xs:schema>
Index: trunk/EventBenchConsole/rules/rules.xml
===================================================================
--- trunk/EventBenchConsole/rules/rules.xml	(revision 1)
+++ trunk/EventBenchConsole/rules/rules.xml	(revision 1)
@@ -0,0 +1,414 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE rules SYSTEM "ruleDoctype.dtd">
+<rules xmlns="ul:rules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="ul:rules ruleSchema.xsd">
+
+  <!-- rules regarding mouse clicks -->
+<rule name="LeftClickButton">
+ <msg type="&WM_LBUTTONDOWN;">
+  <store var="clicked"/>
+ </msg>
+ <msg type="&WM_LBUTTONUP;">
+  <equals>
+   <constValue value="Button"/>
+   <winInfoValue obj="this" winParam="class"/>
+  </equals>
+  <equals>
+   <paramValue obj="clicked" param="window.hwnd"/>
+   <paramValue obj="this" param="window.hwnd"/>
+  </equals>
+ </msg>
+ <genMsg delay="100">
+  <type>
+   <constValue value="&BM_CLICK;"/>
+  </type>
+  <target>
+   <msgInfoValue obj="clicked" msgParam="target"/>
+  </target>
+ </genMsg>
+</rule>
+
+  <rule name="ComboBox">
+    <msg type="&WM_LBUTTONDOWN;">
+      <equals>
+        <winInfoValue obj="this" winParam="class"/>
+        <constValue value="ComboBox"/>
+      </equals>
+      <store var="clicked"/>
+    </msg>
+    <msg type="&WM_COMMAND;">
+      <equals>
+        <paramValue obj="this" param="window.hwnd"/>
+        <paramValue obj="clicked" param="window.hwnd"/>
+      </equals>
+      <store var="cmd1">
+        <resolveHwnd param="source" storeParam="sourceDesc"/>
+      </store>
+    </msg>
+    <msg type="&WM_COMMAND;" multiple="true">
+      <equals>
+        <paramValue obj="this" param="source"/>
+        <paramValue obj="clicked" param="window.hwnd"/>
+      </equals>
+      <storeSeq varSeq="cmds">
+        <resolveHwnd param="window.hwnd" storeParam="msgTarget"/>
+        <resolveHwnd param="source" storeParam="sourceDesc"/>
+      </storeSeq>
+    </msg>
+    <msg type="&WM_LBUTTONUP;">
+      <equals>
+        <paramValue obj="this" param="window.hwnd"/>
+        <paramValue obj="clicked" param="window.hwnd"/>
+      </equals>
+    </msg>
+    <genMsg delay="100">
+      <type>
+        <constValue value="&WM_SETFOCUS;"/>
+      </type>
+      <target>
+        <msgInfoValue obj="clicked" msgParam="target"/>
+      </target>
+    </genMsg>
+    <genMsg delay="100">
+      <type>
+        <constValue value="&CB_SHOWDROPDOWN;"/>
+      </type>
+      <target>
+        <msgInfoValue obj="clicked" msgParam="target"/>
+      </target>
+      <WPARAM>
+        <constValue value="1"/>
+      </WPARAM>
+    </genMsg>
+    <!--
+    <genMsg delay="100">
+      <type>
+        <constValue value="273"/>
+      </type>
+      <target>
+        <msgInfoValue obj="cmd1" msgParam="target"/>
+      </target>
+      <LPARAM>
+        <paramValue obj="cmd1" param="sourceDesc"/>
+      </LPARAM>
+      <WPARAM>
+        <paramValue obj="cmd1" param="WPARAM"/>
+      </WPARAM>
+    </genMsg>
+    <genMsgSeq delay="50">
+      <type>
+        <constValue value="273"/>
+      </type>
+      <target>
+        <seqValue seqObj="cmds" param="msgTarget"/>
+      </target>
+      <LPARAM>
+        <seqValue seqObj="cmds" param ="sourceDesc"/>
+      </LPARAM>
+      <WPARAM>
+        <seqValue seqObj="cmds" param="WPARAM"/>
+      </WPARAM>
+    </genMsgSeq>-->
+  </rule>
+  
+  <rule name="LeftClickCommand">
+    <msg type="&WM_LBUTTONDOWN;">
+      <store var="clicked"/>
+    </msg>
+    <msg type="&WM_LBUTTONUP;">
+      <equals>
+        <paramValue obj="clicked" param="window.hwnd"/>
+        <paramValue obj="this" param="window.hwnd"/>
+      </equals>
+    </msg>
+    <msg type="&WM_COMMAND;">
+      <equals>
+        <paramValue obj="clicked" param="window.hwnd"/>
+        <paramValue obj="this" param="source"/>
+      </equals>
+      <store var="cmd">
+        <resolveHwnd param="source" storeParam="sourceDesc"/>
+      </store>
+    </msg>
+    <genMsg delay="100">
+      <type>
+        <msgInfoValue obj="cmd" msgParam="type"/>
+      </type>
+      <target>
+        <msgInfoValue obj="cmd" msgParam="target"/>
+      </target>
+      <LPARAM>
+        <paramValue obj="cmd" param="sourceDesc"/>
+      </LPARAM>
+      <WPARAM>
+        <paramValue obj="cmd" param="WPARAM"/>
+      </WPARAM>
+    </genMsg>
+  </rule>
+
+  <rule name="LeftClickSysCommand">
+    <msg type="&WM_LBUTTONDOWN;">
+      <store var="clicked"/>
+    </msg>
+    <msg type="&WM_LBUTTONUP;">
+      <equals>
+        <paramValue obj="clicked" param="window.hwnd"/>
+        <paramValue obj="this" param="window.hwnd"/>
+      </equals>
+    </msg>
+    <msg type="&WM_SYSCOMMAND;">
+      <store var="cmd"/>
+    </msg>
+    <genMsg delay="100">
+      <storedVar obj="cmd"/>
+    </genMsg>
+  </rule>
+
+  <rule name="NCLeftClickSysCommand">
+    <msg type="&WM_NCLBUTTONDOWN;">
+      <store var="clicked"/>
+    </msg>
+    <msg type="&WM_LBUTTONUP;">
+      <equals>
+        <paramValue obj="clicked" param="window.hwnd"/>
+        <paramValue obj="this" param="window.hwnd"/>
+      </equals>
+    </msg>
+    <msg type="&WM_SYSCOMMAND;">
+      <equals>
+        <paramValue obj="clicked" param="window.hwnd"/>
+        <paramValue obj="this" param="window.hwnd"/>
+      </equals>
+      <store var="cmd"/>
+    </msg>
+    <genMsg delay="100">
+      <storedVar obj="cmd"/>
+    </genMsg>
+  </rule>
+
+  <rule name="LeftClickMenuItemCmd">
+    <msg type="&WM_LBUTTONDOWN;">
+      <store var="clicked"/>
+    </msg>
+    <msg type="&WM_LBUTTONUP;">
+      <equals>
+        <paramValue obj="clicked" param="window.hwnd"/>
+        <paramValue obj="this" param="window.hwnd"/>
+      </equals>
+    </msg>
+    <msg type="&WM_MENUSELECT;">
+      <equals>
+        <paramValue obj="clicked" param="window.hwnd"/>
+        <paramValue obj="this" param="window.hwnd"/>
+      </equals>
+    </msg>
+    <msg type="&WM_COMMAND;">
+      <equals>
+        <paramValue obj="this" param="sourceType"/>
+        <constValue value="0"/>
+      </equals>
+      <store var="cmd"/>
+    </msg>
+    <genMsg delay="100">
+      <storedVar obj="cmd"/>
+    </genMsg>
+  </rule>
+
+ 
+  <!-- rules involving mouse movement -->
+  <rule name="HScroll">
+    <msg type="&WM_LBUTTONDOWN;">
+      <store var="clicked"/>
+    </msg>
+    <msg type="&WM_HSCROLL;" multiple="true">
+      <equals>
+        <paramValue obj="this" param="scrollBarHandle"/>
+        <paramValue obj="clicked" param="window.hwnd"/>
+      </equals>
+      <storeSeq varSeq="scrolls">
+        <resolveHwnd param="scrollBarHandle" storeParam="scrollBarTarget"/>
+      </storeSeq>
+    </msg>
+    <msg type="&WM_LBUTTONUP;">
+      <equals>
+        <paramValue obj="clicked" param="window.hwnd"/>
+        <paramValue obj="clicked" param="window.hwnd"/>
+      </equals>
+    </msg>
+    <genMsgSeq delay="20">
+      <type>
+        <constValue value="&TBM_SETPOS;"/>
+      </type>
+      <target>
+        <seqValue seqObj="scrolls" param="scrollBarTarget"/>
+      </target>
+      <LPARAM>
+        <constValue value="1"/>
+      </LPARAM>
+      <WPARAM>
+        <seqValue seqObj="scrolls" param="scrollPos"/>
+      </WPARAM>
+    </genMsgSeq>
+  </rule>
+  
+  <!-- if nothing else, at least switch focus, works only partially -->
+  <rule name="LeftClickChangeFocus">
+    <msg type="&WM_LBUTTONDOWN;">
+      <equals>
+        <winInfoValue obj="this" winParam="class"/>
+        <constValue value="Edit"/>
+      </equals>
+      <store var="clicked"/>
+    </msg>
+    <msg type="&WM_KILLFOCUS;">
+      <store var="killfocus"/>
+    </msg>
+    <msg type="&WM_SETFOCUS;">
+      <equals>
+        <paramValue obj="this" param="WPARAM"/>
+        <paramValue obj="killfocus" param="window.hwnd"/>
+      </equals>
+      <store var="setfocus"/>
+    </msg>
+    <msg type="&WM_COMMAND;">
+      <equals>
+        <paramValue obj="this" param="source"/>
+        <paramValue obj="clicked" param="window.hwnd"/>
+      </equals>
+      <equals>
+        <paramValue obj="this" param="sourceType"/>
+        <constValue value="256"/>
+      </equals>
+      <store var="cmd"/>
+    </msg>
+    <msg type="&WM_LBUTTONUP;">
+      <equals>
+        <paramValue obj="this" param="window.hwnd"/>
+        <paramValue obj="clicked" param="window.hwnd"/>
+      </equals>
+    </msg>
+    <genMsg delay="20">
+      <type>
+        <constValue value="&WM_KILLFOCUS;"/>
+      </type>
+      <target>
+        <msgInfoValue obj="killfocus" msgParam="target"/>
+      </target>
+      <WPARAM>
+        <msgInfoValue obj="setfocus" msgParam="target"/>
+      </WPARAM>
+    </genMsg>
+    <genMsg delay="20">
+      <type>
+        <constValue value="&WM_SETFOCUS;"/>
+      </type>
+      <target>
+        <msgInfoValue obj="setfocus" msgParam="target"/>
+      </target>
+      <WPARAM>
+        <msgInfoValue obj="killfocus" msgParam="target"/>
+      </WPARAM>
+    </genMsg>
+    <genMsg delay="100">
+      <type>
+        <constValue value="&WM_COMMAND;"/>
+      </type>
+      <target>
+        <msgInfoValue obj="cmd" msgParam="target"/>
+      </target>
+      <LPARAM>
+        <msgInfoValue obj="setfocus" msgParam="target"/>
+      </LPARAM>
+      <WPARAM>
+        <paramValue obj="cmd" param="WPARAM"/>
+      </WPARAM>
+    </genMsg>
+  </rule>
+
+
+  <!-- rules regarding keyboard input -->
+  <!-- <rule name="KeyPressed">
+    <msg type="&WM_KEYDOWN;">
+      <store var="keydown"/>
+    </msg>
+    <msg type="&WM_KEYUP;">
+      <store var="keyup"/>
+    </msg>
+    <genMsg delay="20">
+      <storedVar obj="keydown"/>
+    </genMsg>
+    <genMsg delay="100">
+      <storedVar obj="keyup"/>
+    </genMsg>
+    <idinfo>
+      <paramValue obj="keydown" param="key"/>
+    </idinfo>
+  </rule>
+
+  <rule name="SysKeyPressed">
+    <msg type="&WM_SYSKEYDOWN;">
+      <store var="keydown"/>
+    </msg>
+    <msg type="&WM_SYSKEYUP;">
+      <store var="keyup"/>
+    </msg>
+    <genMsg delay="20">
+      <storedVar obj="keydown"/>
+    </genMsg>
+    <genMsg delay="100">
+      <storedVar obj="keyup"/>
+    </genMsg>
+    <idinfo>
+      <paramValue obj="keydown" param="key"/>
+    </idinfo>
+  </rule> -->
+  
+  <!-- Alternate rules -->
+  <rule name="KeyDown">
+    <msg type="&WM_KEYDOWN;">
+      <store var="keydown"/>
+    </msg>
+    <genMsg delay="20">
+      <storedVar obj="keydown"/>
+    </genMsg>
+    <idinfo>
+      <paramValue obj="keydown" param="key"/>
+    </idinfo>
+  </rule>
+
+  <rule name="KeyUp">
+    <msg type="&WM_KEYUP;">
+      <store var="keyup"/>
+    </msg>
+    <genMsg delay="20">
+      <storedVar obj="keyup"/>
+    </genMsg>
+    <idinfo>
+      <paramValue obj="keyup" param="key"/>
+    </idinfo>
+  </rule>
+
+  <rule name="SysKeyDown">
+    <msg type="&WM_SYSKEYDOWN;">
+      <store var="keydown"/>
+    </msg>
+    <genMsg delay="20">
+      <storedVar obj="keydown"/>
+    </genMsg>
+    <idinfo>
+      <paramValue obj="keydown" param="key"/>
+    </idinfo>
+  </rule>
+
+  <rule name="SysKeyUp">
+    <msg type="&WM_SYSKEYUP;">
+      <store var="keyup"/>
+    </msg>
+    <genMsg delay="20">
+      <storedVar obj="keyup"/>
+    </genMsg>
+    <idinfo>
+      <paramValue obj="keyup" param="key"/>
+    </idinfo>
+  </rule>
+
+</rules>
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/EventGenerator.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/EventGenerator.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/EventGenerator.java	(revision 1)
@@ -0,0 +1,707 @@
+package de.ugoe.cs.eventbench;
+
+import java.io.IOException;
+import java.security.InvalidParameterException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.Namespace;
+import org.jdom.input.SAXBuilder;
+
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.eventbench.data.ReplayableEvent;
+import de.ugoe.cs.eventbench.data.WindowTree;
+import de.ugoe.cs.eventbench.data.WindowTreeNode;
+import de.ugoe.cs.eventbench.data.WindowsMessage;
+import de.ugoe.cs.util.console.Console;
+
+/**
+ * <p>
+ * Translates sequences of windows messages into events that can be used by the
+ * Logalyzer core libraries for usage analysis.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ * 
+ */
+public class EventGenerator {
+
+	/**
+	 * <p>
+	 * Helper method that fetches the document node of an XML file.
+	 * </p>
+	 * 
+	 * @param filename
+	 *            name of the XML file
+	 * @return the document node
+	 */
+	private static Document getDocument(String filename) {
+		SAXBuilder builder = new SAXBuilder();
+		Document doc = null;
+
+		try {
+			doc = builder.build(filename);
+			rulesNamespace = Namespace.getNamespace("ul:rules");
+		} catch (JDOMException e) {
+			System.err.println("Invalid rules file.");
+			e.printStackTrace();
+		} catch (IOException e) {
+			System.err.println("Invalid rules file.");
+			e.printStackTrace();
+		}
+
+		return doc;
+	}
+
+	/**
+	 * <p>
+	 * Name and path of the XML files containing the rules.
+	 * </p>
+	 */
+	private String rulesFile;
+
+	/**
+	 * <p>
+	 * Iterator used for the current sequence.
+	 * </p>
+	 */
+	private ListIterator<WindowsMessage> sequenceIterator;
+
+	/**
+	 * <p>
+	 * Token that is currently being generated.
+	 * </p>
+	 */
+	private ReplayableEvent<WindowsMessage> currentToken;
+
+	/**
+	 * <p>
+	 * Reference to the ul:rules namespace.
+	 * </p>
+	 */
+	private static Namespace rulesNamespace;
+
+	/**
+	 * <p>
+	 * The name of the rule that is currently being evaluated.
+	 * </p>
+	 */
+	private String currentRuleName;
+
+	/**
+	 * <p>
+	 * Internal message storage. Used to implement the
+	 * <code>{@literal <store>}</code> and <code>{@literal <storeSeq>}</code>
+	 * tags.
+	 * </p>
+	 */
+	private Map<String, Object> messageStorage;
+
+	/**
+	 * <p>
+	 * Creates a new EventGenerator. Sets "rules/rules.xml" as default file for
+	 * the rules.
+	 * </p>
+	 */
+	public EventGenerator() {
+		rulesFile = "rules/rules.xml";
+	}
+
+	/**
+	 * <p>
+	 * Tries to match the rules to the given sequence to generate an
+	 * {@link Event}.
+	 * </p>
+	 * <p>
+	 * The rules are matched the order, in which they are defined in the XML
+	 * file. Therefore, the order of the rules in the file defines priorities,
+	 * when multiple rules could be matched to the same sequence.
+	 * </p>
+	 * 
+	 * @param sequence
+	 *            sequence of message for which an event will be generated
+	 * @return event that matches the messages; null, if no rule can be matched
+	 */
+	@SuppressWarnings("unchecked")
+	public Event<WindowsMessage> generateEvent(List<WindowsMessage> sequence) {
+		Document rulesDoc = getDocument(rulesFile);
+		Element rulesRoot = rulesDoc.getRootElement();
+
+		List<Element> ruleElements = rulesRoot.getChildren("rule",
+				rulesNamespace);
+
+		boolean isMatch = false;
+
+		for (int ruleIndex = 0; ruleIndex < ruleElements.size() && !isMatch; ruleIndex++) {
+			Element currentRule = ruleElements.get(ruleIndex);
+			currentToken = new ReplayableEvent<WindowsMessage>(currentRuleName);
+			currentRuleName = currentRule.getAttributeValue("name");
+			isMatch = true;
+			messageStorage = new HashMap<String, Object>();
+			sequenceIterator = sequence.listIterator();
+			List<Element> ruleChildrenMsg = currentRule.getChildren("msg",
+					rulesNamespace);
+
+			int i = 0;
+			while (isMatch && i < ruleChildrenMsg.size()) {
+				Element messageElement = ruleChildrenMsg.get(i);
+				if ("true".equals(messageElement.getAttributeValue("multiple"))) {
+					Element nextMessageElement = null;
+					if (i + 1 < ruleChildrenMsg.size()) {
+						nextMessageElement = ruleChildrenMsg.get(i + 1);
+					}
+					try {
+						isMatch = matchMultipleMessages(messageElement,
+								nextMessageElement);
+					} catch (InvalidParameterException e) {
+						Console.printerrln(e.getMessage());
+					}
+				} else {
+					try {
+						isMatch = matchSingleMessage(messageElement);
+					} catch (InvalidParameterException e) {
+						Console.printerrln(e.getMessage());
+					}
+				}
+				i++;
+			}
+			if (isMatch) {
+				List<Element> ruleChildren = currentRule.getChildren();
+				for (Element genMsgElement : ruleChildren) {
+					if (genMsgElement.getName().equals("genMsg")) {
+						try {
+							generateReplayMessage(genMsgElement);
+						} catch (InvalidParameterException e) {
+							Console.printerrln(e.getMessage());
+							currentToken.invalidateReplay();
+						}
+					} else if (genMsgElement.getName().equals("genMsgSeq")) {
+						try {
+							generateReplaySequence(genMsgElement);
+							currentToken.invalidateReplay();
+						} catch (InvalidParameterException e) {
+							Console.printerrln(e.getMessage());
+							currentToken.invalidateReplay();
+						}
+					}
+				}
+				Element idinfoElement = currentRule.getChild("idinfo",
+						rulesNamespace);
+				if (idinfoElement != null) {
+					// cannot be empty if document is valid
+					List<Element> valueElements = idinfoElement.getChildren();
+					currentToken.setIdInfo(getTermValue(null,
+							valueElements.get(0)));
+				}
+				Console.traceln(currentRule.getAttributeValue("name")
+						+ currentToken.getIdInfo() + " matched");
+			} else {
+				currentToken = null;
+			}
+		}
+		if (!isMatch) {
+			Console.traceln("no match found for sequence: "
+					+ sequence.toString());
+		}
+		return currentToken;
+	}
+
+	private boolean createSequenceLParam(
+			List<WindowsMessage> generatedMessageSeq, boolean msgsGenerated,
+			int constMsgType, Element termElement)
+			throws NoSuchElementException {
+		Iterator<WindowsMessage> seqIterator = generatedMessageSeq.iterator();
+		if (termElement.getName().equals("seqValue")) {
+			String obj = termElement.getAttributeValue("seqObj");
+			List<WindowsMessage> seqVar = getStoredSeqVariable(obj);
+			if (msgsGenerated && seqVar.size() != generatedMessageSeq.size()) {
+				throw new InvalidParameterException(
+						"Failure generating replay sequence for rule "
+								+ currentRuleName
+								+ ": One or more of the sequence variables used to generate a sequence have different lenghts.");
+			}
+			for (WindowsMessage msg : seqVar) {
+				WindowsMessage currentSeqMsg = getCurrentSeqMsg(
+						generatedMessageSeq, msgsGenerated, constMsgType,
+						seqIterator);
+				String paramValueStr = msg.getParameter(termElement
+						.getAttributeValue("param"));
+				int paramValue = 0;
+				try {
+					paramValue = Integer.parseInt(paramValueStr);
+					currentSeqMsg.setLPARAM(paramValue);
+				} catch (NumberFormatException e) {
+					currentSeqMsg.setLPARAMasWindowDesc(paramValueStr);
+				}
+			}
+			if (seqIterator.hasNext()) {
+				// the first seq-var has a different number of elements than the
+				// current one
+				throw new NoSuchElementException();
+			}
+			msgsGenerated = true;
+		} else { // const value
+			int paramValue = Integer.parseInt(getTermValue(null, termElement));
+			while (seqIterator.hasNext()) {
+				seqIterator.next().setLPARAM(paramValue);
+			}
+		}
+		return msgsGenerated;
+	}
+
+	private boolean createSequenceTarget(
+			List<WindowsMessage> generatedMessageSeq, boolean msgsGenerated,
+			int constMsgType, Element termElement)
+			throws NoSuchElementException {
+		Iterator<WindowsMessage> seqIterator = generatedMessageSeq.iterator();
+		if (termElement.getName().equals("seqValue")) {
+			String obj = termElement.getAttributeValue("seqObj");
+			List<WindowsMessage> seqVar = getStoredSeqVariable(obj);
+			if (msgsGenerated && seqVar.size() != generatedMessageSeq.size()) {
+				throw new InvalidParameterException(
+						"Failure generating replay sequence for rule "
+								+ currentRuleName
+								+ ": One or more of the sequence variables used to generate a sequence have different lenghts.");
+			}
+			for (WindowsMessage msg : seqVar) {
+				WindowsMessage currentSeqMsg = getCurrentSeqMsg(
+						generatedMessageSeq, msgsGenerated, constMsgType,
+						seqIterator);
+				String targetString = msg.getParameter(termElement
+						.getAttributeValue("param"));
+				currentSeqMsg.setXmlWindowDescription(targetString);
+			}
+			msgsGenerated = true;
+		} else { // const value
+			throw new AssertionError("target must be a sequence variable!");
+			/*
+			 * If target would not be a variable, the message-elements could not
+			 * yet be created and the whole sequence might be broken. If this is
+			 * to be changed, createSequenceLParam and createSequenceWParam need
+			 * to be addepted, too.
+			 */
+		}
+		return msgsGenerated;
+	}
+
+	private boolean createSequenceWParam(
+			List<WindowsMessage> generatedMessageSeq, boolean msgsGenerated,
+			int constMsgType, Element termElement)
+			throws NoSuchElementException {
+		Iterator<WindowsMessage> seqIterator = generatedMessageSeq.iterator();
+		if (termElement.getName().equals("seqValue")) {
+			String obj = termElement.getAttributeValue("seqObj");
+			List<WindowsMessage> seqVar = getStoredSeqVariable(obj);
+			if (msgsGenerated && seqVar.size() != generatedMessageSeq.size()) {
+				throw new InvalidParameterException(
+						"Failure generating replay sequence for rule "
+								+ currentRuleName
+								+ ": One or more of the sequence variables used to generate a sequence have different lenghts.");
+			}
+			for (WindowsMessage msg : seqVar) {
+				WindowsMessage currentSeqMsg = getCurrentSeqMsg(
+						generatedMessageSeq, msgsGenerated, constMsgType,
+						seqIterator);
+				String paramValueStr = msg.getParameter(termElement
+						.getAttributeValue("param"));
+				int paramValue = 0;
+				try {
+					paramValue = Integer.parseInt(paramValueStr);
+					currentSeqMsg.setWPARAM(paramValue);
+				} catch (NumberFormatException e) {
+					currentSeqMsg.setWPARAMasWindowDesc(paramValueStr);
+				}
+			}
+			if (seqIterator.hasNext()) {
+				// the first seq-var has a different number of elements than the
+				// current one
+				throw new NoSuchElementException();
+			}
+			msgsGenerated = true;
+		} else { // const value
+			int paramValue = Integer.parseInt(getTermValue(null, termElement));
+			while (seqIterator.hasNext()) {
+				seqIterator.next().setWPARAM(paramValue);
+			}
+		}
+		return msgsGenerated;
+	}
+
+	@SuppressWarnings("unchecked")
+	private boolean evalEqualRestrictions(WindowsMessage currentMessage,
+			Element messageElement) {
+		boolean isMatch = true;
+		for (Element childElement : (List<Element>) messageElement.getChildren(
+				"equals", rulesNamespace)) {
+			List<Element> termElements = childElement.getChildren();
+			// the size 2 of termElements is guaranteed by the XML schema
+			String value1 = getTermValue(currentMessage, termElements.get(0));
+			String value2 = getTermValue(currentMessage, termElements.get(1));
+			if (value1 == null || value2 == null) {
+				isMatch = false;
+			} else {
+				isMatch = isMatch && value1.equals(value2);
+			}
+		}
+		for (Element childElement : (List<Element>) messageElement.getChildren(
+				"equalsSeq", rulesNamespace)) {
+			List<Element> termElements = childElement.getChildren();
+			List<String> values1 = getTermValueSeq(currentMessage,
+					termElements.get(0));
+			List<String> values2 = getTermValueSeq(currentMessage,
+					termElements.get(0));
+			if (values1 == null || values2 == null) {
+				isMatch = false;
+			} else {
+				isMatch = isMatch && values1.equals(values2);
+			}
+		}
+		return isMatch;
+	}
+
+	@SuppressWarnings("unchecked")
+	private void generateReplayMessage(Element genMsgElement) {
+		List<Element> genMsgChildren = genMsgElement.getChildren();
+		WindowsMessage generatedMessage = null;
+		if (genMsgChildren.size() == 1) { // replay stored message without
+											// change
+			String obj = genMsgChildren.get(0).getAttributeValue("obj");
+			generatedMessage = getStoredMessageVariable(null, obj);
+		} else { // generate message according to the rule
+			for (Element genMsgChild : genMsgChildren) {
+				Element termElement = (Element) genMsgChild.getChildren()
+						.get(0);
+				if (genMsgChild.getName().equals("type")) {
+					try {
+						int msgType = Integer.parseInt(getTermValue(null,
+								termElement));
+						generatedMessage = new WindowsMessage(msgType);
+					} catch (NumberFormatException e) {
+						throw new InvalidParameterException(
+								"Failure generating replay sequence for rule "
+										+ currentRuleName
+										+ ": Defined type is not an integer.");
+					}
+				} else if (genMsgChild.getName().equals("target")) {
+					String targetString = getTermValue(null, termElement);
+					generatedMessage.setXmlWindowDescription(targetString);
+				} else if (genMsgChild.getName().equals("LPARAM")) {
+					String paramValueStr = getTermValue(null, termElement);
+					int paramValue = 0;
+					try {
+						paramValue = Integer.parseInt(paramValueStr);
+						generatedMessage.setLPARAM(paramValue);
+					} catch (NumberFormatException e) {
+						generatedMessage.setLPARAMasWindowDesc(paramValueStr);
+					}
+				} else if (genMsgChild.getName().equals("WPARAM")) {
+					String paramValueStr = getTermValue(null, termElement);
+					int paramValue = 0;
+					try {
+						paramValue = Integer.parseInt(paramValueStr);
+						generatedMessage.setWPARAM(paramValue);
+					} catch (NumberFormatException e) {
+						generatedMessage.setWPARAMasWindowDesc(paramValueStr);
+					}
+				}
+			}
+		}
+		if (generatedMessage != null) {
+			int delay = Integer.parseInt(genMsgElement
+					.getAttributeValue("delay"));
+			generatedMessage.setDelay(delay);
+		} else {
+			currentToken.invalidateReplay();
+		}
+		currentToken.addReplayEvent(generatedMessage);
+	}
+
+	@SuppressWarnings("unchecked")
+	private void generateReplaySequence(Element genMsgElement) {
+		List<Element> genMsgSeqChildren = genMsgElement.getChildren();
+		List<WindowsMessage> generatedMessageSeq = new LinkedList<WindowsMessage>();
+		if (genMsgSeqChildren.size() == 1) {
+			String obj = genMsgSeqChildren.get(0).getAttributeValue("seqObj");
+			generatedMessageSeq = getStoredSeqVariable(obj);
+		} else {
+			boolean msgsGenerated = false;
+			int constMsgType = 0;
+			for (Element genMsgSeqChild : genMsgSeqChildren) {
+				Element termElement = (Element) genMsgSeqChild.getChildren()
+						.get(0);
+				if (genMsgSeqChild.getName().equals("type")) {
+					// note: cannot easily be extracted because of mulitple
+					// return values
+					if (termElement.getName().equals("seqValue")) {
+						String obj = termElement.getAttributeValue("seqObj");
+						List<WindowsMessage> seqVar = getStoredSeqVariable(obj);
+						for (WindowsMessage msg : seqVar) {
+							generatedMessageSeq.add(new WindowsMessage(msg
+									.getType()));
+						}
+						msgsGenerated = true;
+					} else { // constValue type
+						constMsgType = Integer.parseInt(getTermValue(null,
+								termElement));
+					}
+				} else if (genMsgSeqChild.getName().equals("target")) {
+					msgsGenerated = createSequenceTarget(generatedMessageSeq,
+							msgsGenerated, constMsgType, termElement);
+				} else if (genMsgSeqChild.getName().equals("LPARAM")) {
+					msgsGenerated = createSequenceLParam(generatedMessageSeq,
+							msgsGenerated, constMsgType, termElement);
+				} else if (genMsgSeqChild.getName().equals("WPARAM")) {
+					msgsGenerated = createSequenceWParam(generatedMessageSeq,
+							msgsGenerated, constMsgType, termElement);
+				}
+			}
+		}
+		currentToken.addReplaySequence(generatedMessageSeq);
+	}
+
+	private WindowsMessage getCurrentSeqMsg(
+			List<WindowsMessage> generatedMessageSeq, boolean msgsGenerated,
+			int constMsgType, Iterator<WindowsMessage> seqIterator) {
+		WindowsMessage currentSeqMsg = null;
+		if (msgsGenerated) {
+			currentSeqMsg = seqIterator.next();
+		} else {
+			currentSeqMsg = new WindowsMessage(constMsgType);
+			generatedMessageSeq.add(currentSeqMsg);
+		}
+		return currentSeqMsg;
+	}
+
+	private WindowsMessage getStoredMessageVariable(
+			WindowsMessage currentMessage, String obj)
+			throws InvalidParameterException {
+		WindowsMessage varMessage = null;
+		if (obj.equals("this")) {
+			if (currentMessage == null) {
+				throw new InvalidParameterException(
+						"Failure obtaining term value for rule "
+								+ currentRuleName
+								+ ": \"this\" is not a valid name for generating runtime messages.");
+			}
+			varMessage = currentMessage;
+		} else {
+			Object tmp = messageStorage.get(obj);
+			if (tmp instanceof WindowsMessage) {
+				varMessage = (WindowsMessage) tmp;
+			} else {
+				throw new InvalidParameterException(
+						"Failure obtaining term value for rule "
+								+ currentRuleName + ": No message \"" + obj
+								+ "\" stored.");
+			}
+		}
+		return varMessage;
+	}
+
+	@SuppressWarnings("unchecked")
+	private List<WindowsMessage> getStoredSeqVariable(String obj)
+			throws InvalidParameterException {
+		List<WindowsMessage> varMsgSeq = null;
+		Object tmp = messageStorage.get(obj);
+		if (tmp instanceof List<?>) {
+			varMsgSeq = (List<WindowsMessage>) tmp;
+		} else {
+			throw new InvalidParameterException(
+					"Failure obtaining term value for rule " + currentRuleName
+							+ ": No sequence \"" + obj + "\" store.");
+		}
+		return varMsgSeq;
+	}
+
+	private String getTermValue(WindowsMessage currentMessage,
+			Element termElement) {
+		String value = null;
+		WindowsMessage varMessage = null;
+		if (termElement.getName().equals("constValue")) {
+			value = termElement.getAttributeValue("value");
+		} else if (termElement.getName().equals("paramValue")) {
+			String objectName = termElement.getAttributeValue("obj");
+			varMessage = getStoredMessageVariable(currentMessage, objectName);
+			if (varMessage != null) {
+				String param = termElement.getAttributeValue("param");
+				value = varMessage.getParameter(param);
+			}
+		} else if (termElement.getName().equals("winInfoValue")) {
+			String objectName = termElement.getAttributeValue("obj");
+			varMessage = getStoredMessageVariable(currentMessage, objectName);
+			if (varMessage != null) {
+				String paramString = termElement.getAttributeValue("winParam");
+				if (paramString.equals("class")) {
+					value = varMessage.getWindowClass();
+				} else if (paramString.equals("resourceId")) {
+					value = "" + varMessage.getWindowResourceId();
+				} else if (paramString.equals("hwnd")) {
+					value = "" + varMessage.getHwnd();
+				}
+			}
+		} else if (termElement.getName().equals("msgInfoValue")) {
+			String objectName = termElement.getAttributeValue("obj");
+			varMessage = getStoredMessageVariable(currentMessage, objectName);
+			if (varMessage != null) {
+				String paramString = termElement.getAttributeValue("msgParam");
+				if (paramString.equals("type")) {
+					value = "" + varMessage.getType();
+				} else if (paramString.equals("target")) {
+					value = varMessage.getXmlWindowDescription();
+				}
+			}
+		}
+		return value;
+	}
+
+	private List<String> getTermValueSeq(WindowsMessage currentMessage,
+			Element termElement) {
+		List<String> values = new LinkedList<String>();
+		if (termElement.getName().equals("seqValue")) {
+			String obj = termElement.getAttributeValue("seqObj");
+			String param = termElement.getAttributeValue("param");
+			List<WindowsMessage> seqVar = getStoredSeqVariable(obj);
+
+			for (WindowsMessage msg : seqVar) {
+				// msg.getParameter returns null, if parameter is not found,
+				// therefore the List can contain null-values
+				values.add(msg.getParameter(param));
+			}
+		}
+		return values;
+	}
+
+	@SuppressWarnings("unchecked")
+	private void handleStorage(Element messageElement,
+			WindowsMessage currentMessage) {
+		for (Element childElement : (List<Element>) messageElement.getChildren(
+				"store", rulesNamespace)) {
+			String identifier = childElement.getAttributeValue("var");
+			messageStorage.put(identifier, currentMessage);
+			resolveHwnd(currentMessage, childElement);
+		}
+		for (Element childElement : (List<Element>) messageElement.getChildren(
+				"storeSeq", rulesNamespace)) {
+			String identifier = childElement.getAttributeValue("varSeq");
+			Object tmp = messageStorage.get(identifier);
+			List<WindowsMessage> storedSequence;
+			if (tmp == null || tmp instanceof WindowsMessage) {
+				storedSequence = new LinkedList<WindowsMessage>();
+				storedSequence.add(currentMessage);
+				messageStorage.put(identifier, storedSequence);
+			} else if (tmp instanceof List<?>) {
+				storedSequence = (List<WindowsMessage>) tmp;
+				storedSequence.add(currentMessage);
+				messageStorage.put(identifier, storedSequence);
+			}
+			resolveHwnd(currentMessage, childElement);
+		}
+	}
+
+	private boolean matchMultipleMessages(Element messageElement,
+			Element nextMessageElement) {
+		boolean isMatch = false;
+		boolean isCurrentMatch = false;
+		boolean nextMatchFound = false;
+		WindowsMessage currentMessage = null;
+		WindowsMessage nextMessage = null;
+
+		int type = Integer.parseInt(messageElement.getAttributeValue("type"));
+
+		int nextType = -1;
+		if (nextMessageElement != null) {
+			nextType = Integer.parseInt(nextMessageElement
+					.getAttributeValue("type"));
+		}
+
+		while (!nextMatchFound && sequenceIterator.hasNext()) {
+			currentMessage = sequenceIterator.next();
+			if (type == currentMessage.getType()) {
+				isCurrentMatch = evalEqualRestrictions(currentMessage,
+						messageElement);
+				isMatch = isMatch || isCurrentMatch;
+
+				if (isCurrentMatch) {
+					handleStorage(messageElement, currentMessage);
+					currentToken.setTarget(currentMessage
+							.getXmlWindowDescription());
+					currentToken
+							.setTargetShort(currentMessage.getParentNames());
+				}
+			}
+			if (nextMessageElement != null && isMatch) {
+				// peek next message to check if the sequence ends and the next
+				// match is found
+				if (!sequenceIterator.hasNext()) {
+					return false; // sequence is over, but not all messages are
+									// found
+				}
+				nextMessage = sequenceIterator.next();
+				sequenceIterator.previous();
+
+				if (nextType == nextMessage.getType()) {
+					nextMatchFound = evalEqualRestrictions(nextMessage,
+							nextMessageElement);
+				}
+
+			}
+		}
+
+		return isMatch;
+	}
+
+	private boolean matchSingleMessage(Element messageElement) {
+		boolean isMatch = false;
+		WindowsMessage currentMessage = null;
+
+		int type = Integer.parseInt(messageElement.getAttributeValue("type"));
+
+		while (!isMatch && sequenceIterator.hasNext()) {
+			// traverses the messages from the current position forward till a
+			// message with the correct type is found
+			currentMessage = sequenceIterator.next();
+			if (type == currentMessage.getType()) {
+				// message with the correct type found
+				// eval child nodes for further matching/storing
+				isMatch = evalEqualRestrictions(currentMessage, messageElement);
+
+				// in case the message is a match, eval storage children
+				if (isMatch) {
+					handleStorage(messageElement, currentMessage);
+					currentToken.setTarget(currentMessage
+							.getXmlWindowDescription());
+					currentToken
+							.setTargetShort(currentMessage.getParentNames());
+				}
+			}
+		}
+
+		return isMatch;
+	}
+
+	@SuppressWarnings("unchecked")
+	private void resolveHwnd(WindowsMessage currentMessage, Element childElement) {
+		List<Element> resolveElements = childElement.getChildren("resolveHwnd",
+				rulesNamespace);
+		for (Element resolveElement : resolveElements) {
+			String param = resolveElement.getAttributeValue("param");
+			String storeParam = resolveElement.getAttributeValue("storeParam");
+			int paramHwnd = Integer
+					.parseInt(currentMessage.getParameter(param));
+			WindowTreeNode node = WindowTree.getInstance().find(paramHwnd);
+			if (node != null) {
+				currentMessage.addParameter(storeParam,
+						node.xmlRepresentation());
+			}
+		}
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/LogParser.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/LogParser.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/LogParser.java	(revision 1)
@@ -0,0 +1,179 @@
+package de.ugoe.cs.eventbench;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.security.InvalidParameterException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.eventbench.data.WindowTree;
+import de.ugoe.cs.eventbench.data.WindowsMessage;
+import de.ugoe.cs.eventbench.messagehandler.HandlerCreate;
+import de.ugoe.cs.eventbench.messagehandler.HandlerDestroy;
+import de.ugoe.cs.eventbench.messagehandler.HandlerSetText;
+import de.ugoe.cs.eventbench.messagehandler.MessageHandler;
+import de.ugoe.cs.eventbench.windowsdefs.MessageDefs;
+import de.ugoe.cs.util.StringTools;
+import de.ugoe.cs.util.console.Console;
+
+public class LogParser extends DefaultHandler {
+	
+	private MessageHandler currentHandler;
+	
+	private WindowsMessage currentMessage;
+	
+	private SequenceSplitter sequenceSplitter;
+	
+	private List<List<Event<WindowsMessage>>> sequences;
+	
+	private SortedMap<Integer, Integer> typeCounter;
+	
+	private boolean countMessageOccurences;
+	
+	public LogParser() {
+		this(false);
+	}
+	
+	public LogParser(boolean countMessageOccurences) {
+		sequenceSplitter = new SequenceSplitter();
+		sequences = new LinkedList<List<Event<WindowsMessage>>>();
+		currentHandler = null;
+		this.countMessageOccurences = countMessageOccurences;
+		if( countMessageOccurences) {
+			typeCounter = new TreeMap<Integer, Integer>();
+		}
+		
+	}
+	
+	public List<List<Event<WindowsMessage>>> getSequences() {
+		return sequences;
+	}
+	
+	@Override
+	public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+		if( qName.equals("session") ) {
+			Console.traceln("start of session");
+			sequenceSplitter = new SequenceSplitter();
+		}
+		else if( qName.equals("msg") ) {
+			String msgType = atts.getValue("type");
+			int msgInt = -1;
+			try {
+				msgInt = Integer.parseInt(msgType);
+				
+				if( countMessageOccurences ) {
+					Integer currentCount = typeCounter.get(msgInt);
+					if( currentCount==null ) {
+						typeCounter.put(msgInt, 1);
+					} else {
+						typeCounter.put(msgInt, currentCount+1);
+					}
+				}
+				
+				if( msgInt==MessageDefs.WM_CREATE ) {
+					currentHandler = new HandlerCreate();
+					currentHandler.onStartElement();
+				}
+				else if( msgInt==MessageDefs.WM_DESTROY ) {
+					currentHandler = new HandlerDestroy();
+					currentHandler.onStartElement();
+				}
+				else if( msgInt==MessageDefs.WM_SETTEXT ) {
+					currentHandler = new HandlerSetText();
+					currentHandler.onStartElement();
+				} else {
+					currentMessage = new WindowsMessage(msgInt);
+				}
+			} catch(NumberFormatException e) {
+				System.err.println("Invalid message type: type not a number");
+				e.printStackTrace();
+			}
+		}
+		else if( qName.equals("param") ) {
+			if( currentHandler!=null ) {
+				currentHandler.onParameter(atts.getValue("name"), atts.getValue("value"));
+			} else {
+				currentMessage.addParameter(atts.getValue("name"), atts.getValue("value"));
+			}
+		}
+	}
+	
+	@Override
+	public void endElement(String uri, String localName, String qName) throws SAXException {
+		if( qName.equals("msg") ) {
+			if( currentHandler!=null ) {
+				currentHandler.onEndElement();
+				currentHandler = null;
+			} else {
+				try {
+					currentMessage.setTarget(WindowTree.getInstance());
+					sequenceSplitter.addMessage(currentMessage);
+				} catch (InvalidParameterException e) {
+					Console.traceln(e.getMessage() + " WindowsMessage " + currentMessage + " ignored.");
+				}				
+			}
+		}
+		else if(qName.equals("session")) {
+			sequenceSplitter.endSession();
+			sequences.add(sequenceSplitter.getSequence());
+			Console.traceln("end of session");
+		}
+	}
+	
+	public void parseFile(String filename) {
+		if( filename==null ) {
+			throw new InvalidParameterException("filename must not be null");
+		}
+		
+		SAXParserFactory spf = SAXParserFactory.newInstance();
+		spf.setValidating(true);
+		
+		SAXParser saxParser = null;
+		InputSource inputSource = null;
+		try {
+			saxParser = spf.newSAXParser();
+			inputSource = new InputSource(new FileReader(filename));
+		} catch (ParserConfigurationException e) {
+			e.printStackTrace();
+		} catch (SAXException e) {
+			e.printStackTrace();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		}
+		if( inputSource!=null ) {
+	        inputSource.setSystemId("file://" + new File(filename).getAbsolutePath());
+	        try {
+	        	if( saxParser==null) {
+	        		throw new RuntimeException("SAXParser creation failed");
+	        	}
+				saxParser.parse(inputSource, this);
+	        } catch (SAXParseException e) {
+	        	Console.printerrln("Failure parsing file in line " + e.getLineNumber() + ", column " + e.getColumnNumber() +".");
+	        	e.printStackTrace();
+			} catch (SAXException e) {
+				e.printStackTrace();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		if( countMessageOccurences ) {
+			Console.println("Message statistics:");
+			Console.println(typeCounter.toString().replace(" ", StringTools.ENDLINE).replaceAll("[\\{\\}]",""));
+		}
+	}
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/LogPreprocessor.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/LogPreprocessor.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/LogPreprocessor.java	(revision 1)
@@ -0,0 +1,127 @@
+package de.ugoe.cs.eventbench;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.commons.codec.binary.Base64;
+
+import de.ugoe.cs.util.StringTools;
+import de.ugoe.cs.util.console.Console;
+
+public class LogPreprocessor {
+	
+	private boolean sessionOpen = false;
+	private boolean msgIncomplete = false;
+	
+	private boolean base64;
+	
+	public LogPreprocessor() {
+		this(false);
+	}
+	
+	public LogPreprocessor(boolean base64) {
+		this.base64 = base64;
+	}
+	
+	public void convertToXml(String source, String target) throws IOException, FileNotFoundException {
+		FileWriter targetFile = new FileWriter(target);
+		targetFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE);
+		targetFile.write("<log>" + StringTools.ENDLINE);
+		processFile(source, targetFile);
+		if( sessionOpen ) {
+			targetFile.write(" </session>" + StringTools.ENDLINE);
+		}
+		targetFile.write("</log>");
+		targetFile.close();
+	}
+	
+	
+	public void convertDirToXml(String path, String target) throws IOException, FileNotFoundException {
+		FileWriter targetFile = new FileWriter(target);
+		targetFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE);
+		targetFile.write("<log>" + StringTools.ENDLINE);
+		File folder = new File(path);
+		if( !folder.isDirectory() ) {
+			throw new IOException(path + " is not a directory");
+		}
+		String absolutPath = folder.getAbsolutePath();
+		for( String filename : folder.list() ) {
+			String source = absolutPath + "/" + filename;
+			Console.traceln("Processing file: " + source);
+			processFile(source, targetFile);
+		}
+		
+		if( sessionOpen ) {
+			targetFile.write(" </session>" + StringTools.ENDLINE);
+		}
+		targetFile.write("</log>");
+		targetFile.close();
+	}
+
+	private void processFile(String source, FileWriter targetFile)
+			throws FileNotFoundException, IOException {
+		File f = new File(source);
+		FileReader reader = new FileReader(f);
+		char[] buffer = new char[(int) f.length()];
+		reader.read(buffer);
+		reader.close();
+		String[] lines = (new String(buffer)).split("\n");
+		String incompleteLine = "";
+		// Open source and read line by line
+		for( String currentLine : lines ) {
+			if( currentLine.contains("UL: <session>")) {
+				if( sessionOpen) {
+					targetFile.write(" </session>" + StringTools.ENDLINE);
+					targetFile.write(" <session>" + StringTools.ENDLINE);
+				} else {
+					targetFile.write(" <session>" + StringTools.ENDLINE);
+					sessionOpen = true;
+				}
+			} else if( currentLine.contains("UL: </session>")) {
+				if( sessionOpen) {
+					targetFile.write(" </session>" + StringTools.ENDLINE);
+					sessionOpen = false;
+				}
+			} else if( msgIncomplete || currentLine.contains("UL: ")) {
+				
+				String currentContent;
+				String actualLine;
+				if( msgIncomplete ) {
+					actualLine = currentLine;
+				} else {
+					String[] splitResult = currentLine.split("UL: ");
+					actualLine = splitResult[1];
+				}
+				if( base64 ) {
+					Base64 decoder = new Base64();
+					byte[] decoded = decoder.decode(actualLine);
+					currentContent = new String(decoded, "UTF-16LE");
+					currentContent = currentContent.substring(0, currentContent.length()-1);
+				} else {
+					currentContent = actualLine;
+				}
+				if( msgIncomplete ) {
+					incompleteLine += currentContent;
+					if( incompleteLine.contains("</msg>") ) {
+						msgIncomplete = false;
+						targetFile.write(incompleteLine + StringTools.ENDLINE);
+						incompleteLine = "";
+					}
+				} else {
+					if( currentContent.contains("<msg") && sessionOpen ) {
+						if( currentContent.contains("</msg>") ) {
+							targetFile.write("  " + currentContent + StringTools.ENDLINE);
+						} else {
+							msgIncomplete = true;
+							incompleteLine += currentContent;
+						}
+					}
+				}
+			}
+		}
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/ReplayGenerator.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/ReplayGenerator.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/ReplayGenerator.java	(revision 1)
@@ -0,0 +1,88 @@
+package de.ugoe.cs.eventbench;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.data.IReplayable;
+import de.ugoe.cs.eventbench.data.ReplayableEvent;
+import de.ugoe.cs.util.StringTools;
+import de.ugoe.cs.util.console.Console;
+
+public class ReplayGenerator {
+		
+	public void createLogfileMultipleSessions(List<List<ReplayableEvent<?>>> sequences, String filename) {
+		FileWriter writer = openReplayFile(filename);
+		if( writer!=null ) {		
+			try {
+				writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE);
+				writer.write("<log>" + StringTools.ENDLINE);
+
+				for( List<ReplayableEvent<?>> actions : sequences ) {
+					writeSession(actions, writer);
+				}
+				
+				writer.write("</log>" + StringTools.ENDLINE);
+				writer.close();
+			} catch (IOException e) {
+				Console.printerrln("Unable to write replay file " + filename);
+			}
+		}
+	}
+	
+	public void createLogfileSingleSession(List<ReplayableEvent<?>> actions, String filename) {
+		FileWriter writer = openReplayFile(filename);
+		if( writer!=null ) {		
+			try {
+				writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE);
+				writer.write("<log>" + StringTools.ENDLINE);
+	
+				writeSession(actions, writer);
+				
+				writer.write("</log>" + StringTools.ENDLINE);
+				writer.close();
+			} catch (IOException e) {
+				Console.printerrln("Unable to write replay file " + filename);
+			}
+		}
+	}
+
+	private FileWriter openReplayFile(String filename) {
+		File file = new File(filename);
+		boolean fileCreated;
+		try {
+			fileCreated = file.createNewFile();
+			if( !fileCreated ) {
+				Console.traceln("Created logfile " + filename);
+			} else {
+				Console.traceln("Overwrote existing logfile " + filename);
+			}
+		} catch (IOException e) {
+			Console.printerrln("Unable to create file " + filename);
+			Console.printStacktrace(e);
+		}
+		FileWriter writer = null;
+		try {
+			writer = new FileWriter(file);
+		} catch (IOException e) {
+			Console.printerrln("Unable to open file for writing (read-only file):" + filename);
+			Console.printStacktrace(e);
+		}
+		return writer;
+	}
+	
+	private void writeSession(List<ReplayableEvent<?>> actions, FileWriter writer)
+			throws IOException {
+		writer.write(" <session>" + StringTools.ENDLINE);
+		for( ReplayableEvent<?> currentAction : actions ) {
+			
+			List<? extends IReplayable> replayables = currentAction.getReplayMessages();
+			for( IReplayable replayble : replayables ) {
+				writer.write(replayble.getReplayXml()+StringTools.ENDLINE);
+			}
+		}
+		writer.write(" </session>" + StringTools.ENDLINE);
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/Runner.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/Runner.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/Runner.java	(revision 1)
@@ -0,0 +1,17 @@
+package de.ugoe.cs.eventbench;
+
+import de.ugoe.cs.util.console.CommandExecuter;
+import de.ugoe.cs.util.console.TextConsole;
+
+public class Runner {
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		CommandExecuter.getInstance().addCommandPackage("de.ugoe.cs.eventbench.commands");
+		TextConsole textConsole = new TextConsole();
+		textConsole.run(true);
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/SequenceSplitter.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/SequenceSplitter.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/SequenceSplitter.java	(revision 1)
@@ -0,0 +1,155 @@
+package de.ugoe.cs.eventbench;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.eventbench.data.WindowsMessage;
+import de.ugoe.cs.eventbench.windowsdefs.MessageDefs;
+import de.ugoe.cs.util.console.Console;
+
+public class SequenceSplitter {
+
+	private List<WindowsMessage> currentSequence;
+	
+	private int openDowns;
+	
+	private boolean initMessages;
+	
+	private EventGenerator tokenGenerator;
+	
+	private List<Event<WindowsMessage>> actionSequence;
+	
+	public SequenceSplitter() {
+		currentSequence = new LinkedList<WindowsMessage>();
+		openDowns = 0;
+		initMessages = true;
+		tokenGenerator = new EventGenerator();
+		actionSequence = new LinkedList<Event<WindowsMessage>>();
+	}
+	
+	public void addMessage(WindowsMessage msg) {
+		if( startOfSequence(msg) ) {
+			if( !initMessages ) {
+				Event<WindowsMessage> currentAction = tokenGenerator.generateEvent(currentSequence);
+				if( currentAction!=null ) {
+					actionSequence.add(currentAction);
+				}
+				if( isKeyMessage(msg.getType()) && openDowns>0 ) {
+					Console.traceln("Key message found with open down mouse messages - will probabably result in a faulty sequence.");
+				}
+			} else {
+				initMessages = false;
+			}
+			currentSequence = new LinkedList<WindowsMessage>();
+		} 
+		if( isUpMessage(msg.getType()) ) {
+			if( openDowns>0 ) { 
+				openDowns--;
+			}
+		}
+		currentSequence.add(msg);
+	}
+	
+	public List<Event<WindowsMessage>> getSequence() {
+		return actionSequence;
+	}
+	
+	public void endSession() {
+		Event<WindowsMessage> currentAction = tokenGenerator.generateEvent(currentSequence);
+		if( currentAction!=null ) {
+			actionSequence.add(currentAction);
+		}
+	}
+
+	private boolean startOfSequence(WindowsMessage msg) {
+		boolean isStart = false;
+		int msgType = msg.getType();
+		if( isKeyMessage(msgType) ) {
+			isStart = true;
+		}
+		if( isDownMessage(msgType) ) {
+			openDowns++;
+			if( openDowns==1 ) {
+				isStart = true;
+			}
+		}
+		if( isDblclkMessage(msgType) ) {
+			openDowns++;
+		}
+		return isStart;
+	}
+
+	private boolean isKeyMessage(int msgType) {
+		boolean isKeyMsg = false;
+		switch (msgType) {
+			case MessageDefs.WM_KEYDOWN:
+			case MessageDefs.WM_KEYUP:
+			case MessageDefs.WM_SYSKEYDOWN:
+			case MessageDefs.WM_SYSKEYUP:
+				isKeyMsg = true;
+				break;
+			default:
+					break;
+		}
+		return isKeyMsg;
+	}
+	
+	private boolean isDownMessage(int msgType) {
+		boolean isDownMsg = false;
+		switch (msgType) {
+			case MessageDefs.WM_LBUTTONDOWN:
+			case MessageDefs.WM_RBUTTONDOWN:
+			case MessageDefs.WM_MBUTTONDOWN:
+			case MessageDefs.WM_XBUTTONDOWN:
+			case MessageDefs.WM_NCLBUTTONDOWN:
+			case MessageDefs.WM_NCRBUTTONDOWN:
+			case MessageDefs.WM_NCMBUTTONDOWN:
+			case MessageDefs.WM_NCXBUTTONDOWN:
+				isDownMsg = true;
+				break;
+			default:
+				break;
+		}
+		return isDownMsg;
+	}
+
+	private boolean isDblclkMessage(int msgType) {
+		boolean isDblclkMsg = false;
+		switch (msgType) {
+			case MessageDefs.WM_LBUTTONDBLCLK:
+			case MessageDefs.WM_RBUTTONDBLCLK:
+			case MessageDefs.WM_MBUTTONDBLCLK:
+			case MessageDefs.WM_XBUTTONDBLCLK:
+			case MessageDefs.WM_NCLBUTTONDBLCLK:
+			case MessageDefs.WM_NCRBUTTONDBLCLK:
+			case MessageDefs.WM_NCMBUTTONDBLCLK:
+			case MessageDefs.WM_NCXBUTTONDBLCLK:
+				isDblclkMsg = true;
+				break;
+			default:
+				break;
+		}
+		return isDblclkMsg;
+	}
+	
+	private boolean isUpMessage(int msgType) {
+		boolean isUpMsg = false;
+		switch (msgType) {
+			case MessageDefs.WM_LBUTTONUP:
+			case MessageDefs.WM_RBUTTONUP:
+			case MessageDefs.WM_MBUTTONUP:
+			case MessageDefs.WM_XBUTTONUP:
+			case MessageDefs.WM_NCLBUTTONUP:
+			case MessageDefs.WM_NCRBUTTONUP:
+			case MessageDefs.WM_NCMBUTTONUP:
+			case MessageDefs.WM_NCXBUTTONUP:
+				isUpMsg = true;
+				break;
+			default:
+				break;
+		}
+		return isUpMsg;
+	}
+	
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDcalcEntropy.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDcalcEntropy.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDcalcEntropy.java	(revision 1)
@@ -0,0 +1,43 @@
+package de.ugoe.cs.eventbench.commands;
+import java.security.InvalidParameterException;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.data.GlobalDataContainer;
+import de.ugoe.cs.eventbench.markov.MarkovModel;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+
+
+public class CMDcalcEntropy implements Command {
+
+	@Override
+	public void help() {
+		Console.println("Usage: calcEntropy <modelname>");
+	}
+
+	@Override
+	public void run(List<Object> parameters) {
+		String modelname = "";
+		try {
+			modelname = (String) parameters.get(0);
+		} catch (Exception e) {
+			throw new InvalidParameterException();
+		}
+		
+		MarkovModel model = null; 
+		Object dataObject = GlobalDataContainer.getInstance().getData(modelname);
+		if( dataObject==null ) {
+			Console.println("Model " + modelname + "not found in storage.");
+		}
+		else if( !(dataObject instanceof MarkovModel) ) {
+			Console.println("Object " + modelname + " is not a markov model!");
+		} else {
+			model = (MarkovModel) dataObject;
+			double entropy = model.calcEntropy();
+			if( Double.isNaN(entropy) ) {
+				Console.println("entropy: " + entropy);
+			}
+		}
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDconvertDirToXml.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDconvertDirToXml.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDconvertDirToXml.java	(revision 1)
@@ -0,0 +1,41 @@
+package de.ugoe.cs.eventbench.commands;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.security.InvalidParameterException;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.LogPreprocessor;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+
+public class CMDconvertDirToXml implements Command {
+
+	@Override
+	public void help() {
+		Console.println("Usage: convertToXml <sourceFolder> <targetFile> {<base64>}");
+	}
+
+	@Override
+	public void run(List<Object> parameters) {
+		if( parameters.size() < 2 ) {
+			throw new InvalidParameterException();
+		}
+		String path = (String) parameters.get(0);
+		String target = (String) parameters.get(1);
+		boolean base64 = false;
+		if( parameters.size() == 3 ) {
+			base64 = Boolean.parseBoolean((String) parameters.get(2));
+		}
+		
+		try {
+			new LogPreprocessor(base64).convertDirToXml(path, target);
+		} catch (FileNotFoundException e) {
+			Console.println(e.getMessage());
+		} catch (IOException e) {
+			Console.println(e.getMessage());
+		}
+		
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDconvertToXml.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDconvertToXml.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDconvertToXml.java	(revision 1)
@@ -0,0 +1,41 @@
+package de.ugoe.cs.eventbench.commands;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.security.InvalidParameterException;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.LogPreprocessor;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+
+public class CMDconvertToXml implements Command {
+
+	@Override
+	public void help() {
+		Console.println("Usage: convertToXml <sourceFile> <targetFile> {<base64>}");
+	}
+
+	@Override
+	public void run(List<Object> parameters) {
+		if( parameters.size() < 2 ) {
+			throw new InvalidParameterException();
+		}
+		String source = (String) parameters.get(0);
+		String target = (String) parameters.get(1);
+		boolean base64 = false;
+		if( parameters.size() == 3 ) {
+			base64 = Boolean.parseBoolean((String) parameters.get(2));
+		}
+		
+		try {
+			new LogPreprocessor(base64).convertToXml(source, target);
+		} catch (FileNotFoundException e) {
+			Console.println(e.getMessage());
+		} catch (IOException e) {
+			Console.println(e.getMessage());
+		}
+		
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateRandomReplay.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateRandomReplay.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateRandomReplay.java	(revision 1)
@@ -0,0 +1,60 @@
+package de.ugoe.cs.eventbench.commands;
+
+import java.security.InvalidParameterException;
+import java.util.LinkedList;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.ReplayGenerator;
+import de.ugoe.cs.eventbench.data.GlobalDataContainer;
+import de.ugoe.cs.eventbench.data.ReplayableEvent;
+import de.ugoe.cs.eventbench.markov.MarkovModel;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+
+public class CMDgenerateRandomReplay implements Command {
+
+	@Override
+	public void help() {
+		Console.println("Usage: generateRandomReplay <modelName> <filename> {<numSessions>}");
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public void run(List<Object> parameters) {
+		String modelname;
+		String filename;
+		int numSessions = 1;
+		try {
+			modelname = (String) parameters.get(0);
+			filename = (String) parameters.get(1);
+			if( parameters.size()<3 ) {
+				numSessions = Integer.parseInt((String) parameters.get(2));
+			}
+		}
+		catch (Exception e) {
+			throw new InvalidParameterException();
+		}
+		
+		MarkovModel model = null; 
+		Object dataObject = GlobalDataContainer.getInstance().getData(modelname);
+		if( dataObject==null ) {
+			Console.println("Model " + modelname + " not found in storage.");
+		}
+		else if( !(dataObject instanceof MarkovModel) ) {
+			Console.println("Object " + modelname + " not of type MarkovModel!");
+		} else {
+			model = (MarkovModel) dataObject;
+			List<List<ReplayableEvent<?>>> sequences = new LinkedList<List<ReplayableEvent<?>>>();
+			try {
+				for( int i=0 ; i<numSessions ; i++ ) {
+					sequences.add((List<ReplayableEvent<?>>) model.randomSequence());
+				}
+			} catch (ClassCastException e) {
+				Console.println("Modeled events don't support replay.");
+			}
+			ReplayGenerator generator = new ReplayGenerator();
+			generator.createLogfileMultipleSessions(sequences, filename);
+		}
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateReplayfile.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateReplayfile.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateReplayfile.java	(revision 1)
@@ -0,0 +1,49 @@
+package de.ugoe.cs.eventbench.commands;
+
+import java.security.InvalidParameterException;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.ReplayGenerator;
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.eventbench.data.GlobalDataContainer;
+import de.ugoe.cs.eventbench.data.ReplayableEvent;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+
+public class CMDgenerateReplayfile implements Command {
+
+	@Override
+	public void help() {
+		Console.println("Usage: generateReplayfile <filename>");		
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public void run(List<Object> parameters) {
+		if( parameters.size() < 1 ) {
+			throw new InvalidParameterException();
+		}
+		String filename = (String) parameters.get(0);
+		
+		List<List<ReplayableEvent<?>>> sequences = null;
+		Object dataObject = GlobalDataContainer.getInstance().getData("sequences");
+			
+		try {
+			sequences = (List<List<ReplayableEvent<?>>>) dataObject;
+			ReplayGenerator generator = new ReplayGenerator();
+			if( sequences.size()>0 ) {
+				if( sequences.get(0).get(0) instanceof Event ) {
+					generator.createLogfileMultipleSessions(sequences, filename);
+				} else {
+					Console.traceln("Illegal use of \"sequences\" parameter in the GlobalDataContainer.");
+					Console.traceln("The parameter should always be of type List<List<Event>>!");
+				}
+			}
+		}
+		catch(ClassCastException e) {
+			Console.printerrln("Sequences need to be loaded first using parseXML");
+		}
+		
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDparseXML.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDparseXML.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDparseXML.java	(revision 1)
@@ -0,0 +1,42 @@
+package de.ugoe.cs.eventbench.commands;
+
+import java.security.InvalidParameterException;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.LogParser;
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.eventbench.data.GlobalDataContainer;
+import de.ugoe.cs.eventbench.data.WindowsMessage;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+
+public class CMDparseXML implements Command {
+
+	@Override
+	public void help() {
+		Console.println("Usage: parseXML <filename> {<countMessageOccurences}");
+	}
+
+	@Override
+	public void run(List<Object> parameters) {
+		String filename;
+		boolean countMessageOccurences = false;
+		
+		try {
+			filename = (String) parameters.get(0);
+			if( parameters.size()==2 ) {
+				countMessageOccurences = Boolean.parseBoolean((String) parameters.get(1));
+			}
+		} catch (Exception e) {
+			throw new InvalidParameterException();
+		}
+		
+		LogParser parser = new LogParser(countMessageOccurences);
+		parser.parseFile(filename);
+		
+		List<List<Event<WindowsMessage>>> sequences = parser.getSequences();
+		
+		GlobalDataContainer.getInstance().addData("sequences", sequences);		
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDprintDot.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDprintDot.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDprintDot.java	(revision 1)
@@ -0,0 +1,40 @@
+package de.ugoe.cs.eventbench.commands;
+
+import java.security.InvalidParameterException;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.data.GlobalDataContainer;
+import de.ugoe.cs.eventbench.markov.DotPrinter;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+
+public class CMDprintDot implements Command {
+
+	@Override
+	public void help() {
+		Console.println("Usage: printDot <modelname>");
+	}
+
+	@Override
+	public void run(List<Object> parameters) {
+		String modelname = "";
+		try {
+			modelname = (String) parameters.get(0);
+		} catch (Exception e) {
+			throw new InvalidParameterException();
+		}
+		
+		DotPrinter model = null; 
+		Object dataObject = GlobalDataContainer.getInstance().getData(modelname);
+		if( dataObject==null ) {
+			Console.println("Model " + modelname + "not found in storage.");
+		}
+		else if( !(dataObject instanceof DotPrinter) ) {
+			Console.println("Object " + modelname + " does not implement DotPrinter!");
+		} else {
+			model = (DotPrinter) dataObject;
+			model.printDot();
+		}
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDshowMarkovModel.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDshowMarkovModel.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDshowMarkovModel.java	(revision 1)
@@ -0,0 +1,86 @@
+package de.ugoe.cs.eventbench.commands;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.security.InvalidParameterException;
+import java.util.List;
+
+import javax.swing.JFrame;
+
+import org.apache.commons.collections15.Transformer;
+
+import de.ugoe.cs.eventbench.data.GlobalDataContainer;
+import de.ugoe.cs.eventbench.markov.MarkovModel;
+import de.ugoe.cs.eventbench.markov.MarkovModel.MarkovEdge;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+import edu.uci.ics.jung.algorithms.layout.Layout;
+import edu.uci.ics.jung.algorithms.layout.ISOMLayout;
+import edu.uci.ics.jung.graph.Graph;
+import edu.uci.ics.jung.visualization.BasicVisualizationServer;
+import edu.uci.ics.jung.visualization.decorators.ToStringLabeller;
+import edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position;
+
+public class CMDshowMarkovModel implements Command {
+
+	@Override
+	public void help() {
+		Console.println("Usage: showMarkovModel <modelName> {<showNodeNames>}");
+	}
+
+	@Override
+	public void run(List<Object> parameters) {
+		String modelname;
+		boolean showNodeNames = false;
+		try {
+			modelname = (String) parameters.get(0);
+			if( parameters.size()==2 ) {
+				showNodeNames = Boolean.parseBoolean((String) parameters.get(1));
+			}
+		} catch (Exception e) {
+			throw new InvalidParameterException();
+		}
+		
+		Object dataObject = GlobalDataContainer.getInstance().getData(modelname);
+		if( dataObject==null ) {
+			Console.printerrln("No model with name " + modelname + "found");
+		} else {
+			MarkovModel mm = (MarkovModel) dataObject;
+			
+			Graph<String, MarkovEdge> graph = mm.getGraph();
+			Layout<String, MarkovEdge> layout = new ISOMLayout<String, MarkovEdge>(graph);
+			layout.setSize(new Dimension(1000,800)); // sets the initial size of the space
+			// The BasicVisualizationServer<V,E> is parameterized by the edge types
+			BasicVisualizationServer<String,MarkovEdge> vv =
+			new BasicVisualizationServer<String,MarkovEdge>(layout);
+			vv.setPreferredSize(new Dimension(1100,850)); //Sets the viewing area size
+
+			
+			if( showNodeNames ) {
+				final Rectangle rect = new Rectangle(240, 20);
+				
+				Transformer<String, Shape> vertexShapeTransformer =
+					new Transformer<String, Shape>() {
+						public Shape transform(String s) {
+							return rect;
+						}
+				};
+				vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
+				vv.getRenderContext().setVertexShapeTransformer(vertexShapeTransformer);
+				vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
+			}
+			
+			
+			vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<MarkovModel.MarkovEdge>());
+			
+			JFrame frame = new JFrame("Markov Model");
+			frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+			frame.getContentPane().add(vv);
+			frame.pack();
+			frame.setVisible(true);
+		}
+	}
+	
+	
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDtrainMarkovModel.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDtrainMarkovModel.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDtrainMarkovModel.java	(revision 1)
@@ -0,0 +1,53 @@
+package de.ugoe.cs.eventbench.commands;
+
+
+import java.security.InvalidParameterException;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.eventbench.data.GlobalDataContainer;
+import de.ugoe.cs.eventbench.markov.MarkovModel;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+
+public class CMDtrainMarkovModel implements Command {
+
+	@Override
+	public void help() {
+		Console.println("Usage: trainMarkovModel <modelName>");
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public void run(List<Object> parameters) {
+		String modelname;
+		try {
+			modelname = (String) parameters.get(0);
+		} catch (Exception e) {
+			throw new InvalidParameterException();
+		}
+		
+		List<List<Event<?>>> sequences = null;
+		Object dataObject = GlobalDataContainer.getInstance().getData("sequences");
+			
+		try {
+			sequences = (List<List<Event<?>>>) dataObject;
+			if( sequences.size()>0 ) {
+				if( sequences.get(0).get(0) instanceof Event ) {
+					MarkovModel model = new MarkovModel();
+					model.train(sequences);
+					if( GlobalDataContainer.getInstance().addData(modelname, model) ) {
+						Console.traceln("Old model overwritten");
+					}
+				} else {
+					Console.traceln("Illegal use of \"sequences\" parameter in the GlobalDataContainer.");
+					Console.traceln("The parameter should always be of type List<List<Event>>!");
+				}
+			}
+		}
+		catch(ClassCastException e) {
+			Console.println("Sequences need to be loaded first using parseXML");
+		}
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDtrainPPM.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDtrainPPM.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDtrainPPM.java	(revision 1)
@@ -0,0 +1,56 @@
+package de.ugoe.cs.eventbench.commands;
+
+import java.security.InvalidParameterException;
+import java.util.List;
+import java.util.Random;
+
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.eventbench.data.GlobalDataContainer;
+import de.ugoe.cs.eventbench.ppm.PredictionByPartialMatch;
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+
+public class CMDtrainPPM implements Command {
+
+	@Override
+	public void help() {
+		Console.println("Usage: trainPPM <modelName>");
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public void run(List<Object> parameters) {
+		String modelname;
+		try {
+			modelname = (String) parameters.get(0);
+		} catch (Exception e) {
+			throw new InvalidParameterException();
+		}
+		
+		List<List<Event<?>>> sequences = null;
+		Object dataObject = GlobalDataContainer.getInstance().getData("sequences");
+			
+		try {
+			sequences = (List<List<Event<?>>>) dataObject;
+			if( sequences.size()>0 ) {
+				if( sequences.get(0).get(0) instanceof Event ) {
+					PredictionByPartialMatch model = new PredictionByPartialMatch();
+					model.train(sequences);
+					if( GlobalDataContainer.getInstance().addData(modelname, model) ) {
+						Console.traceln("Old model overwritten");
+					}
+					// TODO TMP!!
+					model.printRandomWalk(new Random());
+					
+				} else {
+					Console.traceln("Illegal use of \"sequences\" parameter in the GlobalDataContainer.");
+					Console.traceln("The parameter should always be of type List<List<Event>>!");
+				}
+			}
+		}
+		catch(ClassCastException e) {
+			Console.println("Sequences need to be loaded first using parseXML");
+		}
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/GlobalDataContainer.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/GlobalDataContainer.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/GlobalDataContainer.java	(revision 1)
@@ -0,0 +1,41 @@
+package de.ugoe.cs.eventbench.data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GlobalDataContainer {
+	
+	private static GlobalDataContainer theInstance= null;
+	
+	private Map<String, Object> dataObjects;
+	
+	public static GlobalDataContainer getInstance() {
+		if( theInstance==null ) {
+			theInstance = new GlobalDataContainer();
+		}
+		return theInstance;
+	}
+	
+	private GlobalDataContainer() {
+		dataObjects = new HashMap<String, Object>();
+	}
+	
+	public boolean addData(String key, Object data) {
+		Object previousEntry = dataObjects.put(key, data);
+		return previousEntry!=null;
+	}
+	
+	public boolean removeData(String key) {
+		Object previousEntry = dataObjects.remove(key);
+		return previousEntry==null;
+	}
+	
+	public Object getData(String key) {
+		return dataObjects.get(key);
+	}
+	
+	public void reset() {
+		dataObjects = new HashMap<String, Object>();
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/WindowTree.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/WindowTree.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/WindowTree.java	(revision 1)
@@ -0,0 +1,163 @@
+package de.ugoe.cs.eventbench.data;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * This class provides an the interfaces for window trees.
+ * </p>
+ * <p>
+ * The window tree represents the hierarchical structure of the windows
+ * "as it is" currently during a session. It may change during the session due
+ * to creation and destruction of windows.
+ * </p>
+ * <p>
+ * The class is implemented as a singleton. The rational behind implementing
+ * this class as a singleton is to ease the access of all class that may request
+ * information about the windows during the parsing of a session. As the tree
+ * may change during the session, it does not make sense to preserve it after a
+ * session. Thus, it can just be deleted. Therefore, as long as only one session
+ * is parsed at a time, a single instance is sufficient.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ */
+public class WindowTree {
+
+	/**
+	 * <p>
+	 * Handle to the window instance.
+	 * </p>
+	 */
+	private static WindowTree theInstance = null;
+
+	/**
+	 * <p>
+	 * Obtain a handle to the window instance.
+	 * </p>
+	 * 
+	 * @return
+	 */
+	public static WindowTree getInstance() {
+		if (theInstance == null) {
+			theInstance = new WindowTree();
+		}
+		return theInstance;
+	}
+
+	/**
+	 * <p>
+	 * Resets the tree. Should be used between sessions.
+	 * </p>
+	 */
+	public static void resetTree() {
+		theInstance = null;
+	}
+
+	/**
+	 * <p>
+	 * Map of all windows that are part of the tree for efficient searching. The
+	 * keys of the map are the hwnd's of the windows.
+	 * </p>
+	 */
+	private Map<Integer, WindowTreeNode> nodes;
+
+	/**
+	 * <p>
+	 * Creates a new WindowTree.
+	 * </p>
+	 * <p>
+	 * Private, as the class is a singleton.
+	 * </p>
+	 */
+	private WindowTree() {
+		nodes = new HashMap<Integer, WindowTreeNode>();
+	}
+
+	/**
+	 * <p>
+	 * Adds a new window to the tree.
+	 * </p>
+	 * 
+	 * @param parentHwnd
+	 *            hwnd of the parent window
+	 * @param childHwnd
+	 *            hwnd of the window to be created
+	 * @param childWindowName
+	 *            resource id of the window to be created
+	 * @param resourceId
+	 *            resource id of the window to be created
+	 * @param className
+	 *            class name of the window to be created
+	 */
+	public void add(int parentHwnd, int childHwnd, String childWindowName,
+			int resourceId, String className, boolean isModal) {
+		WindowTreeNode parent = nodes.get(parentHwnd);
+		WindowTreeNode child = nodes.get(childHwnd);
+		if (child == null) {
+			if (parent != null) {
+				child = parent.addChild(childHwnd, childWindowName, resourceId,
+						className, isModal);
+			} else {
+				child = new WindowTreeNode(childHwnd, null, childWindowName,
+						resourceId, className, isModal);
+			}
+			nodes.put(childHwnd, child);
+		}
+	}
+
+	/**
+	 * <p>
+	 * Removes a window (defined by its hwnd) from the tree. All children of the
+	 * window will be removed recursively.
+	 * </p>
+	 * 
+	 * @param hwnd
+	 *            hwnd of the window to be removed
+	 * @return number of windows that were removed
+	 */
+	public int remove(int hwnd) {
+		int removedCounter = 0;
+		WindowTreeNode node = nodes.get(hwnd);
+		if (node != null) {
+			List<WindowTreeNode> nodesToBeRemoved = node.remove();
+			for (int i = 0; i < nodesToBeRemoved.size(); i++) {
+				WindowTreeNode nodeToBeRemoved = nodesToBeRemoved.get(i);
+				nodesToBeRemoved.addAll(nodeToBeRemoved.getChildren());
+				nodes.remove(nodeToBeRemoved.getHwnd());
+				removedCounter++;
+			}
+			nodes.remove(hwnd);
+			removedCounter++;
+		}
+		return removedCounter;
+	}
+
+	/**
+	 * <p>
+	 * Searches the tree for a window with the specified hwnd and returns its
+	 * {@link WindowTreeNode}.
+	 * </p>
+	 * 
+	 * @param hwnd
+	 *            hwnd that is looked for
+	 * @return {@link WindowTreeNode} of the window with the given hwnd if
+	 *         found, null otherwise
+	 */
+	public WindowTreeNode find(int hwnd) {
+		return nodes.get(hwnd);
+	}
+	
+	/**
+	 * <p>
+	 * Returns the number of nodes contained in the WindowTree.
+	 * </p>
+	 * 
+	 * @return number of nodes
+	 */
+	public int size() {
+		return nodes.size();
+	}
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/WindowTreeNode.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/WindowTreeNode.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/WindowTreeNode.java	(revision 1)
@@ -0,0 +1,280 @@
+package de.ugoe.cs.eventbench.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import de.ugoe.cs.util.StringTools;
+
+/**
+ * <p>
+ * This class implements a node in the {@link WindowTree} that is maintained
+ * during parsing a session.
+ * </p>
+ * <p>
+ * The window tree is structure that contains the hierarchy of the windows of a
+ * application as well as basic information about each window: the hwnd; its
+ * name; its resource id; its class name.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ */
+public class WindowTreeNode {
+
+	/**
+	 * <p>
+	 * Name of the window. May change over time.
+	 * </p>
+	 */
+	private String windowName;
+
+	/**
+	 * <p>
+	 * Handle of the window. Used as unique identifier during its existence.
+	 * </p>
+	 */
+	private final int hwnd;
+
+	/**
+	 * <p>
+	 * Resource id of the window.
+	 * </p>
+	 */
+	private final int resourceId;
+
+	/**
+	 * <p>
+	 * Class name of the window.
+	 * </p>
+	 */
+	private final String className;
+
+	/**
+	 * <p>
+	 * True, if the window is modal.
+	 * </p>
+	 */
+	private final boolean isModal;
+
+	/**
+	 * <p>
+	 * Parent of the window. <code>null</code> if the window has no parent.
+	 * </p>
+	 */
+	private WindowTreeNode parent;
+
+	/**
+	 * <p>
+	 * List of the windows children. May be empty.
+	 * </p>
+	 */
+	private List<WindowTreeNode> children;
+	
+	/**
+	 * <p>
+	 * Creates a new WindowTreeNode.
+	 * </p>
+	 * <p>
+	 * The constructor is protected WindowTreeNode may only be created from the
+	 * WindowTree.
+	 * </p>
+	 * 
+	 * @param hwnd
+	 *            hwnd of the window
+	 * @param parent
+	 *            reference to the parent's WindowTreeNode
+	 * @param windowName
+	 *            name of the window
+	 * @param resourceId
+	 *            resource id of the window
+	 * @param className
+	 *            class name of the window
+	 * @param isModal
+	 *            modality of the window
+	 */
+	protected WindowTreeNode(int hwnd, WindowTreeNode parent,
+			String windowName, int resourceId, String className, boolean isModal) {
+		this.hwnd = hwnd;
+		this.parent = parent;
+		this.windowName = windowName;
+		this.resourceId = resourceId;
+		this.className = className;
+		this.isModal = isModal;
+		children = new ArrayList<WindowTreeNode>();
+	}
+
+	/**
+	 * <p>
+	 * Returns a reference to the WindowTreeNode of the parent.
+	 * </p>
+	 * 
+	 * @return WindowTreeNode of the parent
+	 */
+	public WindowTreeNode getParent() {
+		return parent;
+	}
+
+	/**
+	 * <p>
+	 * Returns the list of the windows children.
+	 * </p>
+	 * 
+	 * @return list of the windows children
+	 */
+	public List<WindowTreeNode> getChildren() {
+		return children;
+	}
+
+	/**
+	 * <p>
+	 * Returns the name of the window.
+	 * </p>
+	 * 
+	 * @return name of the window
+	 */
+	public String getName() {
+		return windowName;
+	}
+
+	/**
+	 * <p>
+	 * Returns the hwnd of the window.
+	 * </p>
+	 * 
+	 * @return hwnd of the window
+	 */
+	public int getHwnd() {
+		return hwnd;
+	}
+
+	/**
+	 * <p>
+	 * Returns the resource id of the window.
+	 * </p>
+	 * 
+	 * @return resource id of the window
+	 */
+	public int getResourceId() {
+		return resourceId;
+	}
+
+	/**
+	 * <p>
+	 * Returns the class name of the window.
+	 * </p>
+	 * 
+	 * @return
+	 */
+	public String getClassName() {
+		return className;
+	}
+
+	/**
+	 * <p>
+	 * Sets the name of the window.
+	 * </p>
+	 * 
+	 * @param text
+	 *            new name of the window
+	 */
+	public void setName(String text) {
+		windowName = text;
+	}
+
+	/**
+	 * <p>
+	 * Removes a the window and all its children from the {@link WindowTree}.
+	 * </p>
+	 * 
+	 * @return list of the children of the window for further clean up.
+	 */
+	public List<WindowTreeNode> remove() {
+		if (parent != null) {
+			parent.removeChild(this);
+		}
+		return children;
+	}
+
+	/**
+	 * <p>
+	 * Removes a child window.
+	 * </p>
+	 * 
+	 * @param child
+	 *            reference to the child window to be removed
+	 */
+	public void removeChild(WindowTreeNode child) {
+		children.remove(child);
+	}
+
+	/**
+	 * <p>
+	 * Adds a new child window and creates WindowTreeNode for it.
+	 * </p>
+	 * 
+	 * @param childHwnd
+	 *            hwnd of the child window
+	 * @param childWindowName
+	 *            name of the child window
+	 * @param resourceId
+	 *            resource id of the child window
+	 * @param className
+	 *            class name of the child window
+	 * @param isModal
+	 *            modality of the child window
+	 * @return reference to the WindowTreeNode created for the child window
+	 */
+	public WindowTreeNode addChild(int childHwnd, String childWindowName,
+			int resourceId, String className, boolean isModal) {
+		WindowTreeNode child = new WindowTreeNode(childHwnd, this,
+				childWindowName, resourceId, className, isModal);
+		children.add(child);
+		return child;
+	}
+
+	/**
+	 * <p>
+	 * Returns a string identfier of the window:<br>
+	 * {@code [resourceId;"windowName";"className";modality]}
+	 * </p>
+	 * 
+	 * @return identifier string of the window
+	 */
+	@Override
+	public String toString() {
+		return "[" + resourceId + ";\"" + windowName + "\";\"" + className
+				+ "\";" + isModal + "]";
+	}
+
+	/**
+	 * <p>
+	 * Returns an XML representation of the window, including its parents. It is
+	 * defined as follows:<br>
+	 * <code>
+	 * parent#xmlRepresentation()<br>
+	 * &lt;window name="this.windowname" class="this.className" resourceId="this.resourceId" isModal="this.isModel"/&gt;
+	 * </code>
+	 * </p>
+	 * 
+	 * @return xml representation of the window
+	 */
+	public String xmlRepresentation() {
+		String xmlString = "";
+		if (parent != null) {
+			xmlString = parent.xmlRepresentation();
+		}
+		xmlString += "<window name=\"" + StringTools.xmlEntityReplacement(windowName) + "\" class=\""
+				+ StringTools.xmlEntityReplacement(className) + "\" resourceId=\"" + resourceId + "\" isModal=\""
+				+ isModal + "\"/>";
+		return xmlString;
+	}
+	
+	public String getParentNames() {
+		String parentNames = "";
+		if (parent != null ) {
+			parentNames = parent.getParentNames()+".";
+		}
+		parentNames += windowName;
+		return parentNames;
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/WindowsMessage.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/WindowsMessage.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/WindowsMessage.java	(revision 1)
@@ -0,0 +1,204 @@
+package de.ugoe.cs.eventbench.data;
+
+import java.security.InvalidParameterException;
+import java.util.HashMap;
+import java.util.Map;
+
+import de.ugoe.cs.eventbench.data.IReplayable;
+import de.ugoe.cs.util.StringTools;
+
+public class WindowsMessage implements IReplayable {
+	final int type;
+	private String windowClass = "";
+	private int resourceId = 0;
+	private String xmlWindowDescription = "";
+	private String parentNames = null;
+
+	private long LPARAM = 0;
+	private long WPARAM = 0;
+
+	private String LPARAMasWindowDesc = null;
+	private String WPARAMasWindowDesc = null;
+
+	private int delay = 0;
+	
+	private Map<String, String> params = new HashMap<String, String>();
+
+	public WindowsMessage(int type) {
+		this.type = type;
+	}
+
+	public void addParameter(String type, String value) {
+		params.put(type, value);
+		if (type.equals("LPARAM")) {
+			LPARAM = Long.parseLong(value);
+		} else if (type.equals("WPARAM")) {
+			WPARAM = Long.parseLong(value);
+		}
+	}
+
+	public int getType() {
+		return type;
+	}
+
+	public String getParameter(String type) {
+		return params.get(type);
+	}
+
+	public String getWindowClass() {
+		return windowClass;
+	}
+
+	public int getHwnd() {
+		int hwnd = -1;
+		String hwndString = getParameter("window.hwnd"); // possible, as
+															// "window.hwnd" is
+															// mandatory
+		if (hwndString != null) {
+			hwnd = Integer.parseInt(hwndString);
+		}
+		return hwnd;
+	}
+
+	public int getWindowResourceId() {
+		return resourceId;
+	}
+
+	@Override
+	public boolean equals(Object other) {
+		if( other==this) {
+			return true;
+		}
+		boolean isEqual = false;
+		if (other instanceof WindowsMessage) {
+			isEqual = ((WindowsMessage) other).type == this.type
+					&& ((WindowsMessage) other).xmlWindowDescription
+							.equals(this.xmlWindowDescription)
+					&& ((WindowsMessage) other).params.equals(this.params);
+		}
+		return isEqual;
+	}
+
+	@Override
+	public int hashCode() {
+		int multiplier = 17;
+		int hash = 42;
+
+		hash = multiplier * hash + type;
+		hash = multiplier * hash + xmlWindowDescription.hashCode();
+		hash = multiplier * hash + params.hashCode();
+
+		return hash;
+	}
+
+	@Override
+	public String toString() {
+		return "msg[target=" + getParameter("window.hwnd") + ";type=" + type
+				+ "]";
+	}
+
+	public void setTarget(WindowTree windowTree)
+			throws InvalidParameterException {
+		int hwnd = Integer.parseInt(getParameter("window.hwnd"));
+		WindowTreeNode node = windowTree.find(hwnd);
+		if (node == null) {
+			throw new InvalidParameterException("No window with HWND " + hwnd
+					+ " found in window tree!");
+		} else {
+			windowClass = node.getClassName();
+			resourceId = node.getResourceId();
+			xmlWindowDescription = node.xmlRepresentation();
+			parentNames = node.getParentNames();
+		}
+	}
+
+	public void setLPARAM(long paramValue) {
+		LPARAM = paramValue;
+	}
+
+	public void setWPARAM(long paramValue) {
+		WPARAM = paramValue;
+	}
+
+	public long getLPARAM() {
+		return LPARAM;
+	}
+
+	public long getWPARAM() {
+		return WPARAM;
+	}
+
+	public void setLPARAMasWindowDesc(String windowDesc) {
+		LPARAMasWindowDesc = windowDesc;
+	}
+
+	public void setWPARAMasWindowDesc(String windowDesc) {
+		WPARAMasWindowDesc = windowDesc;
+	}
+
+	public String getLPARAMasWindowDesc() {
+		return LPARAMasWindowDesc;
+	}
+
+	public String getWPARAMasWindowDesc() {
+		return WPARAMasWindowDesc;
+	}
+
+	public String getXmlWindowDescription() {
+		return xmlWindowDescription;
+	}
+
+	public void setXmlWindowDescription(String xmlWindowDescription) {
+		this.xmlWindowDescription = xmlWindowDescription;
+	}
+
+	public int getDelay() {
+		return delay;
+	}
+
+	public void setDelay(int delay) {
+		this.delay = delay;
+	}
+
+	public String getParentNames() {
+		return parentNames;
+	}
+
+	public int getNumParams() {
+		return params.size();
+	}
+	
+	public String getReplayXml() {
+		StringBuilder currentMsgStr = new StringBuilder(400);
+		currentMsgStr.append("  <msg type=\""+type+"\" ");
+		currentMsgStr.append("LPARAM=\""+LPARAM+"\" ");
+		currentMsgStr.append("WPARAM=\""+WPARAM+"\" ");
+		currentMsgStr.append("delay=\""+delay+"\">");
+		if( LPARAMasWindowDesc!=null ) {
+			currentMsgStr.append(StringTools.ENDLINE);
+			currentMsgStr.append("   <LPARAM>");
+			currentMsgStr.append(StringTools.ENDLINE);
+			currentMsgStr.append(LPARAMasWindowDesc);
+			currentMsgStr.append(StringTools.ENDLINE);
+			currentMsgStr.append("</LPARAM>");
+		} 
+		if( WPARAMasWindowDesc!=null ) {
+			currentMsgStr.append(StringTools.ENDLINE);
+			currentMsgStr.append("   <WPARAM>");
+			currentMsgStr.append(StringTools.ENDLINE);
+			currentMsgStr.append(WPARAMasWindowDesc);
+			currentMsgStr.append(StringTools.ENDLINE);
+			currentMsgStr.append("   </WPARAM>");
+		}
+		currentMsgStr.append(StringTools.ENDLINE);
+		currentMsgStr.append(xmlWindowDescription);
+		currentMsgStr.append(StringTools.ENDLINE);
+		currentMsgStr.append("  </msg>");
+		currentMsgStr.append(StringTools.ENDLINE);
+		return currentMsgStr.toString();
+	}
+	
+	public String getTarget() {
+		return xmlWindowDescription;
+	}
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/HandlerCreate.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/HandlerCreate.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/HandlerCreate.java	(revision 1)
@@ -0,0 +1,63 @@
+package de.ugoe.cs.eventbench.messagehandler;
+
+import de.ugoe.cs.eventbench.data.WindowTree;
+
+public class HandlerCreate extends MessageHandler {
+
+	public HandlerCreate() {
+		super();
+	}
+
+	private String windowName;
+	private int hwnd;
+	private int parentHwnd;
+	private int resourceId;
+	private String className;
+	private boolean isModal;
+	
+	@Override
+	public void onEndElement() {
+		if( hwnd!=0 ) {
+			WindowTree.getInstance().add(parentHwnd, hwnd, windowName, resourceId, className, isModal);
+		}
+	}
+
+	@Override
+	public void onParameter(String name, String value) {
+		if( name.equals("window.hwnd") ) {
+			hwnd = Integer.parseInt(value);
+		}
+		else if( name.equals("window.name") ) {
+			windowName = value;
+		}
+		else if( name.equals("window.parent.hwnd") ) {
+			parentHwnd = Integer.parseInt(value);
+		}
+		else if( name.equals("window.resourceId") ) {
+			resourceId = Integer.parseInt(value);
+		}
+		else if( name.equals("window.class") ) {
+			if( value.startsWith("Afx:") ) {
+				className = "Afx:";
+			} else {
+				className = value;
+			}
+		}
+		else if( name.equals("window.ismodal") ) {
+			if( value.equals("true") || value.equals("1") ) {
+				isModal = true;
+			}
+		}
+	}
+
+	@Override
+	public void onStartElement() {
+		windowName = "";
+		hwnd = 0;
+		parentHwnd = 0;
+		resourceId = 0;
+		className = "";
+		isModal = false;
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/HandlerDestroy.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/HandlerDestroy.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/HandlerDestroy.java	(revision 1)
@@ -0,0 +1,32 @@
+package de.ugoe.cs.eventbench.messagehandler;
+
+import de.ugoe.cs.eventbench.data.WindowTree;
+
+public class HandlerDestroy extends MessageHandler {
+
+	public HandlerDestroy() {
+		super();
+	}
+
+	private int hwnd;
+	
+	@Override
+	public void onEndElement() {
+		if( hwnd!=0 ) {
+			WindowTree.getInstance().remove(hwnd);
+		}
+	}
+
+	@Override
+	public void onParameter(String name, String value) {
+		if( name.equals("window.hwnd") ) {
+			hwnd = Integer.parseInt(value);
+		}
+	}
+
+	@Override
+	public void onStartElement() {
+		hwnd = 0;
+	}
+
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/HandlerSetText.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/HandlerSetText.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/HandlerSetText.java	(revision 1)
@@ -0,0 +1,37 @@
+package de.ugoe.cs.eventbench.messagehandler;
+
+import de.ugoe.cs.eventbench.data.WindowTree;
+import de.ugoe.cs.eventbench.data.WindowTreeNode;
+
+public class HandlerSetText extends MessageHandler {
+
+	public HandlerSetText() {
+		super();
+	}
+
+	private String windowName;
+	private int hwnd;
+
+	@Override
+	public void onEndElement() {
+		if (hwnd != 0) {
+			WindowTreeNode node = WindowTree.getInstance().find(hwnd);
+			node.setName(windowName);
+		}
+	}
+
+	@Override
+	public void onParameter(String name, String value) {
+		if (name.equals("window.hwnd")) {
+			hwnd = Integer.parseInt(value);
+		} else if (name.equals("window.newText")) {
+			windowName = value;
+		}
+	}
+
+	@Override
+	public void onStartElement() {
+		windowName = "";
+		hwnd = 0;
+	}
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/MessageHandler.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/MessageHandler.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/messagehandler/MessageHandler.java	(revision 1)
@@ -0,0 +1,11 @@
+package de.ugoe.cs.eventbench.messagehandler;
+
+
+public class MessageHandler {
+		
+	protected MessageHandler() {}
+	
+	public void onStartElement() {}
+	public void onParameter(String name, String value) {}
+	public void onEndElement() {}
+}
Index: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windowsdefs/MessageDefs.java
===================================================================
--- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windowsdefs/MessageDefs.java	(revision 1)
+++ trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windowsdefs/MessageDefs.java	(revision 1)
@@ -0,0 +1,157 @@
+package de.ugoe.cs.eventbench.windowsdefs;
+
+public interface MessageDefs {
+	
+	public static final int WM_NULL = 0;
+	public static final int WM_CREATE = 1;
+	public static final int WM_DESTROY = 2;
+	public static final int WM_MOVE = 3;
+	public static final int WM_SIZE = 5;
+	public static final int WM_ACTIVATE = 6;
+	public static final int WM_SETFOCUS = 7;
+	public static final int WM_KILLFOCUS = 8;
+	public static final int WM_ENABLE = 10;
+	public static final int WM_SETREDRAW = 11;
+	public static final int WM_SETTEXT = 12;
+	public static final int WM_GETTEXT = 13;
+	public static final int WM_GETTEXTLENGTH = 14;
+	public static final int WM_PAINT = 15;
+	public static final int WM_CLOSE = 16;
+	public static final int WM_QUERYENDSESSION = 17;
+	public static final int WM_QUIT = 18;
+	public static final int WM_QUERYOPEN = 19;
+	public static final int WM_ERASEBKGND = 20;
+	public static final int WM_SYSCOLORCHANGE = 21;
+	public static final int WM_ENDSESSION = 22;
+	public static final int WM_SHOWWINDOW = 24;
+	public static final int WM_CTLCOLOR = 25;
+	public static final int WM_WININICHANGE = 26;
+	public static final int WM_DEVMODECHANGE = 27;
+	public static final int WM_ACTIVATEAPP = 28;
+	public static final int WM_FONTCHANGE = 29;
+	public static final int WM_TIMECHANGE = 30;
+	public static final int WM_CANCELMODE = 31;
+	public static final int WM_SETCURSOR = 32;
+	public static final int WM_MOUSEACTIVATE = 33;
+	public static final int WM_CHILDACTIVATE = 34;
+	public static final int WM_QUEUESYNC = 35;
+	public static final int WM_GETMINMAXINFO = 36;
+	public static final int WM_PAINTICON = 38;
+	public static final int WM_ICONERASEBKGND = 39;
+	public static final int WM_NEXTDLGCTL = 40;
+	public static final int WM_SPOOLERSTATUS = 42;
+	public static final int WM_DRAWITEM = 43;
+	public static final int WM_MEASUREITEM = 44;
+	public static final int WM_DELETEITEM = 45;
+	public static final int WM_VKEYTOITEM = 46;
+	public static final int WM_CHARTOITEM = 47;
+	public static final int WM_SETFONT = 48;
+	public static final int WM_GETFONT = 49;
+	public static final int WM_SETHOTKEY = 50;
+	public static final int WM_GETHOTKEY = 51;
+	public static final int WM_QUERYDRAGICON = 55;
+	public static final int WM_COMPAREITEM = 57;
+	public static final int WM_GETOBJECT = 61;
+	public static final int WM_COMPACTING = 65;
+	public static final int WM_COMMNOTIFY = 68;
+	public static final int WM_WINDOWPOSCHANGING = 70;
+	public static final int WM_WINDOWPOSCHANGED = 71;
+	public static final int WM_POWER = 72;
+	public static final int WM_COPYDATA = 74;
+	public static final int WM_CANCELJOURNAL = 75;
+	public static final int WM_NOTIFY = 78;
+	public static final int WM_INPUTLANGCHANGEREQUEST = 80;
+	public static final int WM_INPUTLANGCHANGE = 81;
+	public static final int WM_TCARD = 82;
+	public static final int WM_HELP = 83;
+	public static final int WM_USERCHANGED = 84;
+	public static final int WM_NOTIFYFORMAT = 85;
+	public static final int WM_CONTEXTMENU = 123;
+	public static final int WM_STYLECHANGING = 124;
+	public static final int WM_STYLECHANGED = 125;
+	public static final int WM_DISPLAYCHANGE = 126;
+	public static final int WM_GETICON = 127;
+	public static final int WM_SETICON = 128;
+	public static final int WM_NCCREATE = 129;
+	public static final int WM_NCDESTROY = 130;
+	public static final int WM_NCCALCSIZE = 131;
+	public static final int WM_NCHITTEST = 132;
+	public static final int WM_NCPAINT = 133;
+	public static final int WM_NCACTIVATE = 134;
+	public static final int WM_GETDLGCODE = 135;
+	public static final int WM_SYNCPAINT = 136;
+	public static final int WM_NCMOUSEMOVE = 160;
+	public static final int WM_NCLBUTTONDOWN = 161;
+	public static final int WM_NCLBUTTONUP = 162;
+	public static final int WM_NCLBUTTONDBLCLK = 163;
+	public static final int WM_NCRBUTTONDOWN = 164;
+	public static final int WM_NCRBUTTONUP = 165;
+	public static final int WM_NCRBUTTONDBLCLK = 166;
+	public static final int WM_NCMBUTTONDOWN = 167;
+	public static final int WM_NCMBUTTONUP = 168;
+	public static final int WM_NCMBUTTONDBLCLK = 169;
+	public static final int WM_NCXBUTTONDOWN = 171;
+	public static final int WM_NCXBUTTONUP = 172;
+	public static final int WM_NCXBUTTONDBLCLK = 173;
+	public static final int WM_INPUT = 255;
+	public static final int WM_KEYDOWN = 256;
+	public static final int WM_KEYFIRST = 256;
+	public static final int WM_KEYUP = 257;
+	public static final int WM_CHAR = 258;
+	public static final int WM_DEADCHAR = 259;
+	public static final int WM_SYSKEYDOWN = 260;
+	public static final int WM_SYSKEYUP = 261;
+	public static final int WM_SYSCHAR = 262;
+	public static final int WM_SYSDEADCHAR = 263;
+	public static final int WM_KEYLAST = 264;
+	public static final int WM_WNT_CONVERTREQUESTEX = 265;
+	public static final int WM_CONVERTREQUEST = 266;
+	public static final int WM_CONVERTRESULT = 267;
+	public static final int WM_INTERIM = 268;
+	public static final int WM_IME_STARTCOMPOSITION = 269;
+	public static final int WM_IME_ENDCOMPOSITION = 270;
+	public static final int WM_IME_COMPOSITION = 271;
+	public static final int WM_IME_KEYLAST = 271;
+	public static final int WM_INITDIALOG = 272;
+	public static final int WM_COMMAND = 273;
+	public static final int WM_SYSCOMMAND = 274;
+	public static final int WM_TIMER = 275;
+	public static final int WM_HSCROLL = 276;
+	public static final int WM_VSCROLL = 277;
+	public static final int WM_INITMENU = 278;
+	public static final int WM_INITMENUPOPUP = 279;
+	public static final int WM_MENUSELECT = 287;
+	public static final int WM_MENUCHAR = 288;
+	public static final int WM_ENTERIDLE = 289;
+	public static final int WM_MENURBUTTONUP = 290;
+	public static final int WM_MENUDRAG = 291;
+	public static final int WM_MENUGETOBJECT = 292;
+	public static final int WM_UNINTMENUPOPUP = 293;
+	public static final int WM_MENUCOMMAND = 294;
+	public static final int WM_CHANGEUISTATE = 295;
+	public static final int WM_UPDATEUISTATE = 296;
+	public static final int WM_QUERYUISTATE = 297;
+	public static final int WM_CTLCOLORMSGBOX = 306;
+	public static final int WM_CTLCOLOREDIT = 307;
+	public static final int WM_CTLCOLORLISTBOX = 308;
+	public static final int WM_CTLCOLORBTN = 309;
+	public static final int WM_CTLCLOLORDLG = 310;
+	public static final int WM_CTLCOLORSCROLLBAR = 311;
+	public static final int WM_CTLCOLORSTATIC = 312;
+	public static final int WM_MOUSEFIRST = 512;
+	public static final int WM_MOUSEMOVE = 512;
+	public static final int WM_LBUTTONDOWN = 513;
+	public static final int WM_LBUTTONUP = 514;
+	public static final int WM_LBUTTONDBLCLK = 515;
+	public static final int WM_RBUTTONDOWN = 516;
+	public static final int WM_RBUTTONUP = 517;
+	public static final int WM_RBUTTONDBLCLK = 518;
+	public static final int WM_MBUTTONDOWN = 519;
+	public static final int WM_MBUTTONUP = 520;
+	public static final int WM_MBUTTONDBLCLK = 521;
+	public static final int WM_MOUSELAST = 521;
+	public static final int WM_MOUSEWHEEL = 522;
+	public static final int WM_XBUTTONDOWN = 523;
+	public static final int WM_XBUTTONUP = 524;
+	public static final int WM_XBUTTONDBLCLK = 525;
+}
Index: trunk/EventBenchCore/.classpath
===================================================================
--- trunk/EventBenchCore/.classpath	(revision 1)
+++ trunk/EventBenchCore/.classpath	(revision 1)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="lib" path="lib/Jama-1.0.2.jar"/>
+	<classpathentry kind="lib" path="lib/colt-1.2.0.jar"/>
+	<classpathentry kind="lib" path="lib/concurrent-1.3.4.jar"/>
+	<classpathentry kind="lib" path="lib/j3d-core-1.3.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-3d-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-3d-demos-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-algorithms-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-api-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-graph-impl-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-io-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-jai-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-jai-samples-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-samples-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/jung-visualization-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/stax-api-1.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/vecmath-1.3.1.jar"/>
+	<classpathentry kind="lib" path="lib/wstx-asl-3.2.6.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/JavaHelperLib"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: trunk/EventBenchCore/.project
===================================================================
--- trunk/EventBenchCore/.project	(revision 1)
+++ trunk/EventBenchCore/.project	(revision 1)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>EventBenchCore</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: trunk/EventBenchCore/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/EventBenchCore/.settings/org.eclipse.jdt.core.prefs	(revision 1)
+++ trunk/EventBenchCore/.settings/org.eclipse.jdt.core.prefs	(revision 1)
@@ -0,0 +1,12 @@
+#Wed Jan 26 14:52:29 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/Event.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/Event.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/Event.java	(revision 1)
@@ -0,0 +1,130 @@
+package de.ugoe.cs.eventbench.data;
+
+
+
+public class Event<T> {
+
+	/**
+	 * <p>
+	 * Type of the event.
+	 * </p>
+	 */
+	private String type;
+	
+	/**
+	 * </p>
+	 * Target of the event.
+	 */
+	private String target = null;
+	
+	/**
+	 * <p>
+	 * Short description of the event target.
+	 * </p>
+	 */
+	private String targetShort = null;
+
+
+	
+
+	private String idInfo = null;
+	
+	public Event(String type) {
+		this.type = type;
+	}
+
+	@Override
+	public boolean equals(Object other) {
+		if( this==other ) {
+			return true;
+		}
+		if (other instanceof Event<?>) {
+			Event<?> otherToken = (Event<?>) other;
+			return otherToken.type.equals(this.type)
+					&& otherToken.target.equals(this.target);
+		} else {
+			return false;
+		}
+	}
+
+	public String getIdInfo() {
+		return idInfo;
+	}
+
+	public String getShortId() {
+		String shortId = null;
+		if (targetShort!=null) {
+			shortId = targetShort+"."+getType();
+			if (idInfo!=null) {
+				shortId += "."+idInfo;
+			}
+		}
+		return shortId;
+	}
+
+	public String getStandardId() {
+		String id = target + "." + getType();
+		if ( idInfo!=null ) {
+			id += "." + idInfo;
+		}
+		return id;
+	}
+
+	public String getTarget() {
+		return target;
+	}
+	
+	public String getTargetShort() {
+		return targetShort;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	@Override
+	public int hashCode() {
+		int multiplier = 17;
+		int hash = 42;
+		hash = multiplier * hash + type.hashCode();
+		if( target!=null ) {
+			hash = multiplier * hash + target.hashCode();
+		}
+
+		return hash;
+	}
+
+	public void setIdInfo(String info) {
+		idInfo = info;
+	}
+	
+	/**
+	 * <p>
+	 * Sets the target of the event. Once set, the target cannot be changed.
+	 * </p> 
+	 * @param target target of the event
+	 * @return true, if target was changed, false otherwise
+	 */
+	public boolean setTarget(String target) {
+		if( this.target!=null ) {
+			return false;
+		}
+		this.target = target;
+		return true;
+	}
+	
+	/**
+	 * <p>
+	 * Sets the short description of the event target. Once set, the target cannot be changed.
+	 * </p> 
+	 * @param targetShort short target description
+	 * @return true, if target was changed, false otherwise
+	 */
+	public boolean setTargetShort(String targetShort) {
+		if( this.targetShort!=null ) {
+			return false;
+		}
+		this.targetShort = targetShort;
+		return true;
+	}
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/IReplayable.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/IReplayable.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/IReplayable.java	(revision 1)
@@ -0,0 +1,8 @@
+package de.ugoe.cs.eventbench.data;
+
+public interface IReplayable {
+	
+	String getReplayXml();
+	
+	String getTarget();
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/ReplayableEvent.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/ReplayableEvent.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/ReplayableEvent.java	(revision 1)
@@ -0,0 +1,46 @@
+package de.ugoe.cs.eventbench.data;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class ReplayableEvent<T extends IReplayable> extends Event<T> {
+
+	private List<T> replayEvents = new LinkedList<T>();;
+
+	private boolean replayValid = true;
+	
+	public ReplayableEvent(String type) {
+		super(type);
+	}
+	
+	public void addReplaySequence(List<T> generatedReplaySeq) {
+		replayEvents.addAll(generatedReplaySeq);
+	}
+
+	public void addReplayEvent(T replayable) {
+		replayEvents.add(replayable);
+	}
+	
+	/**
+	 * <p>
+	 * Returns a the list of replay events.
+	 * </p> 
+	 * <p>
+	 * The return value is a copy of the list used internally!
+	 * </p>
+	 * @return list of replay events. 
+	 */
+	public List<T> getReplayMessages() {
+		return new LinkedList<T>(replayEvents);
+	}
+	
+	public boolean hasValidReplay() {
+		return replayValid;
+	}
+
+	public void invalidateReplay() {
+		replayValid = false;
+	}
+
+
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/DotPrinter.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/DotPrinter.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/DotPrinter.java	(revision 1)
@@ -0,0 +1,5 @@
+package de.ugoe.cs.eventbench.markov;
+
+public interface DotPrinter {
+	public abstract void printDot();
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/IMemory.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/IMemory.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/IMemory.java	(revision 1)
@@ -0,0 +1,40 @@
+package de.ugoe.cs.eventbench.markov;
+
+import java.util.List;
+
+/**
+ * <p>
+ * This interface defines basic functions for classes that implement a memory
+ * about the recent events of a sequences.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ * @version 1.0
+ * 
+ * @param <T>
+ *            Type of the sequence elements that are memorized.
+ */
+public interface IMemory<T> {
+
+	/**
+	 * Adds an element to the end of the memory.
+	 * 
+	 * @param element
+	 *            Element to be added.
+	 */
+	public void add(T element);
+
+	/**
+	 * <p>
+	 * Returns the last <code>num</code> memorized elements. If the history is
+	 * shorter than <code>num</code>, the length of the returned
+	 * {@link java.util.List} may be less than <code>num</code>.
+	 * </p>
+	 * 
+	 * @param num
+	 *            Number of states from the end of the memory to be returned.
+	 * @return {@link java.util.List} of memorized elements.
+	 */
+	public List<T> getLast(int num);
+
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/IncompleteMemory.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/IncompleteMemory.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/IncompleteMemory.java	(revision 1)
@@ -0,0 +1,33 @@
+package de.ugoe.cs.eventbench.markov;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class IncompleteMemory<T> implements IMemory<T> {
+
+	private int length;
+	
+	private List<T> history;
+	
+	public IncompleteMemory(int length) {
+		this.length = length;
+		history = new LinkedList<T>();
+	}
+	
+	@Override
+	public void add(T state) {
+		if( history.size()==length ) {
+			history.remove(0);
+		}
+		history.add(state);
+	}
+
+	@Override
+	public List<T> getLast(int num) {
+		return new LinkedList<T>(history); // defensive copy
+	}
+
+	public int getLength() {
+		return history.size();
+	}
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/MarkovModel.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/MarkovModel.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/MarkovModel.java	(revision 1)
@@ -0,0 +1,242 @@
+package de.ugoe.cs.eventbench.markov;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+
+import Jama.Matrix;
+
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.util.console.Console;
+import edu.uci.ics.jung.graph.Graph;
+import edu.uci.ics.jung.graph.SparseMultigraph;
+import edu.uci.ics.jung.graph.util.EdgeType;
+
+public class MarkovModel implements DotPrinter {
+
+	private State initialState;
+	private State endState;
+	
+	private List<State> states;
+	private List<String> stateIdList;
+	
+	private Random r;
+	
+	final static int MAX_STATDIST_ITERATIONS = 1000;
+	
+	/**
+	 * <p>
+	 * Default constructor. Creates a new random number generator.
+	 * </p>
+	 */
+	public MarkovModel() {
+		this(new Random());
+	}
+	
+	/**
+	 * <p>
+	 * Creates a new {@link MarkovModel} with a predefined random number generator.
+	 * </p>
+	 * 
+	 * @param r random number generator
+	 */
+	public MarkovModel(Random r) {
+		this.r = r; // defensive copy would be better, but constructor Random(r) does not seem to exist.
+	}
+	
+	public void printRandomWalk() {
+		State currentState = initialState;
+		IMemory<State> history = new IncompleteMemory<State>(5); // this is NOT used here, just for testing ...
+		history.add(currentState);
+		Console.println(currentState.getId());
+		while(!currentState.equals(endState)) {
+			currentState = currentState.getNextState();
+			Console.println(currentState.getId());
+			history.add(currentState);
+		}
+	}
+	
+	public List<? extends Event<?>> randomSequence() {
+		List<Event<?>> sequence = new LinkedList<Event<?>>();
+		State currentState = initialState;
+		if( currentState.getAction()!=null ) {
+			sequence.add(currentState.getAction());
+		}
+		System.out.println(currentState.getId());
+		while(!currentState.equals(endState)) {
+			currentState = currentState.getNextState();
+			if( currentState.getAction()!=null ) {
+				sequence.add(currentState.getAction());
+			}
+			System.out.println(currentState.getId());
+		}
+		return sequence;
+	}
+	
+	public void printDot() {
+		int numUnprintableStates = 0;
+		System.out.println("digraph model {");
+		for( State state : states ) {
+			if( state instanceof DotPrinter ) {
+				((DotPrinter) state).printDot();
+			} else {
+				numUnprintableStates++;
+			}
+		}
+		System.out.println('}');
+		if( numUnprintableStates>0 ) {
+			Console.println("" + numUnprintableStates + "/" + states.size() + "were unprintable!");
+		}
+	}
+	
+	public Graph<String, MarkovEdge> getGraph() {
+		Graph<String, MarkovEdge> graph = new SparseMultigraph<String, MarkovEdge>();
+		
+		for( State state : states) {
+			try {
+				SimpleState simpleState = (SimpleState) state;
+				String from = simpleState.getShortId();
+				for( int i=0 ; i<simpleState.toStates.size() ; i++ ) {
+					SimpleState toState = (SimpleState) simpleState.toStates.get(i);
+					String to = toState.getShortId();
+					MarkovEdge prob = new MarkovEdge(simpleState.transitionProbs.get(i));
+					graph.addEdge(prob, from, to, EdgeType.DIRECTED);
+				}
+			} catch (ClassCastException e) {
+				// TODO: handle exception
+			}
+		}
+		
+		return graph;
+	}
+	
+	static public class MarkovEdge {
+		double weight;
+		MarkovEdge(double weight) { this.weight = weight; }
+		public String toString() { return ""+weight; }
+	}
+	
+	/////////////////////////////////////////////////////////////////////////////////////
+	// Code to learn type1 model: states are wndid.action and transitions are unlabled //
+	/////////////////////////////////////////////////////////////////////////////////////
+	
+	public void train(List<List<Event<?>>> sequences) {
+		Event<?> fromElement = null;
+		Event<?> toElement = null;
+		SimpleState fromState;
+		SimpleState toState;
+		
+		states = new ArrayList<State>();
+		stateIdList = new ArrayList<String>();
+		initialState = new SimpleState("GLOBALSTARTSTATE", null);
+		initialState.setRandom(r);
+		states.add(initialState);
+		stateIdList.add("GLOBALSTARTSTATE");
+		endState = new SimpleState("GLOBALENDSTATE", null);
+		endState.setRandom(r);
+		states.add(endState);
+		stateIdList.add("GLOBALENDSTATE");
+		for( List<Event<?>> sequence : sequences ) {
+			for( int i=0; i<sequence.size() ; i++ ) {
+				if( i==0 ) {
+					fromState = (SimpleState) initialState;
+				} else {
+					fromElement = sequence.get(i-1);
+					fromState = findOrCreateSimpleState(fromElement);
+				}
+				
+				toElement = sequence.get(i);
+				toState = findOrCreateSimpleState(toElement);
+				
+				fromState.incTransTo(toState);
+				
+				if( i==sequence.size()-1 ) {
+					toState.incTransTo(endState);
+				}
+			}
+		}
+	}
+	
+	private SimpleState findOrCreateSimpleState(Event<?> action) {
+		SimpleState state = null;
+		String id = action.getStandardId();
+		String idShort = action.getShortId();
+		int index = stateIdList.indexOf(id);
+		if( index!=-1 ) {
+			state = (SimpleState) states.get(index);
+		} else {
+			state = new SimpleState(id, action, idShort);
+			state.setRandom(r);
+			states.add(state);
+			stateIdList.add(id);
+		}
+		return state;
+	}
+	
+	///////////////////////////////////////////////////////////
+	
+	// states must be SimpleState, this functions will throw bad cast exceptions
+	public double calcEntropy() {
+		int numStates = states.size();
+		// create transmission matrix
+		Matrix transmissionMatrix = new Matrix(numStates, numStates);
+		for( int i=0 ; i<numStates ; i++ ) {
+			State tmpState = states.get(i);
+			if( SimpleState.class.isInstance(tmpState) ) {
+				SimpleState currentState = (SimpleState) tmpState;
+				for( int j=0 ; j<numStates ; j++ ) {
+					double prob = currentState.getProb(states.get(j));
+					transmissionMatrix.set(i, j, prob);
+				}
+			} else {
+				Console.printerr("Error calculating entropy. Only allowed for first-order markov models.");
+				return Double.NaN;
+			}
+		}
+		
+		// Add transition from endState to startState. This makes the markov chain irreducible and recurrent. 
+		int startStateIndex = states.indexOf(initialState);
+		int endStateIndex = states.indexOf(endState);
+		if( startStateIndex==-1 ) {
+			Console.printerrln("Error calculating entropy. Initial state of markov chain not found.");
+			return Double.NaN;
+		}
+		if( endStateIndex==-1 ) {
+			Console.printerrln("Error calculating entropy. End state of markov chain not found.");
+			return Double.NaN;
+		}
+		transmissionMatrix.set(endStateIndex, startStateIndex, 1);
+		
+		// Calculate stationary distribution by raising the power of the transmission matrix.
+		// The rank of the matrix should fall to 1 and each two should be the vector of the
+		// stationory distribution. 
+		int iter = 0;
+		int rank = transmissionMatrix.rank();
+		Matrix stationaryMatrix = (Matrix) transmissionMatrix.clone();
+		while( iter<MAX_STATDIST_ITERATIONS && rank>1 ) {
+			stationaryMatrix = stationaryMatrix.times(stationaryMatrix);
+			rank = stationaryMatrix.rank();
+			iter++;
+		}
+		
+		if( rank!=1 ) {
+			Console.traceln("rank: " + rank);
+			Console.printerrln("Unable to calculate stationary distribution.");
+			return Double.NaN;
+		}
+		
+		double entropy = 0.0;
+		for( int i=0 ; i<numStates ; i++ ) {
+			for( int j=0 ; j<numStates ; j++ ) {
+				if( transmissionMatrix.get(i,j)!=0 ) {
+					double tmp = stationaryMatrix.get(i, 0);
+					tmp *= transmissionMatrix.get(i, j);
+					tmp *= Math.log(transmissionMatrix.get(i,j))/Math.log(2);
+					entropy -= tmp;
+				}
+			}
+		}
+		return entropy;
+	}
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/SimpleState.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/SimpleState.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/SimpleState.java	(revision 1)
@@ -0,0 +1,100 @@
+package de.ugoe.cs.eventbench.markov;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import de.ugoe.cs.eventbench.data.Event;
+
+
+/**
+ * This class implements a simple first-order markov state. 
+ * Transitions are unlabled.
+ * @author Steffen Herbold
+ */
+public class SimpleState extends State implements DotPrinter {
+	
+	List<Double> transitionProbs;
+	List<State> toStates;
+	
+	// members for learning
+	private int transitionsObserved;
+	
+	private String idShort = null;
+	
+	public SimpleState(String id, Event<?> action) {
+		super(id, action);
+		transitionsObserved = 0;
+		toStates = new ArrayList<State>();
+		transitionProbs = new ArrayList<Double>();
+	}
+	
+	public SimpleState(String id, Event<?> action, String idShort) {
+		this(id, action);
+		this.idShort = idShort;
+	}
+	
+	@Override
+	public State getNextState() {
+		double randVal = rand.nextDouble();
+		double probSum = 0;
+		int index = 0;
+		while( index<transitionProbs.size() && probSum+transitionProbs.get(index) < randVal ) {
+			probSum += transitionProbs.get(index);
+			index++;
+		}
+		return toStates.get(index);
+	}
+	
+	public void incTransTo(State state) {
+		int index = toStates.indexOf(state);
+		if( index==-1 ) {
+			toStates.add(state);
+			transitionProbs.add(0.0);
+			index = toStates.size()-1;
+		}
+		// update trans probs
+		for( int i=0 ; i<toStates.size() ; i++ ) {
+			double currentProb = transitionProbs.get(i);
+			double newProb = 0.0;
+			if( i!=index ) {
+				newProb = (currentProb*transitionsObserved)/(transitionsObserved+1);
+			} else {
+				newProb = ((currentProb*transitionsObserved)+1)/(transitionsObserved+1);
+			}
+			transitionProbs.set(i, newProb);
+		}
+		transitionsObserved++;
+	}
+	
+	// get the transition probability to the given state
+	public double getProb(State state) {
+		double prob = 0.0;
+		int index = toStates.indexOf(state);
+		if( index>=0 ) {
+			prob = transitionProbs.get(index);
+		}
+		return prob;
+	}
+	
+	public String getShortId() {
+		String shortId;
+		if( idShort!=null ) {
+			shortId = idShort;
+		} else {
+			shortId = getId();
+		}
+		return shortId;
+	}
+
+	@Override
+	public void printDot() {
+		final String thisSaneId = getShortId().replace("\"", "\\\"").replaceAll("[\r\n]","");
+		System.out.println(" " + hashCode() + " [label=\""+thisSaneId+"\"];");
+		for(int i=0 ; i<toStates.size() ; i++ ) {
+			System.out.print(" "+hashCode()+" -> " + toStates.get(i).hashCode() + " ");
+			System.out.println("[label=\"" + transitionProbs.get(i) + "\"];");
+		}
+		
+	}
+	
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/State.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/State.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/markov/State.java	(revision 1)
@@ -0,0 +1,97 @@
+package de.ugoe.cs.eventbench.markov;
+
+import java.util.Random;
+
+import de.ugoe.cs.eventbench.data.Event;
+
+public abstract class State {
+	
+	/**
+	 * {@link Event} associated with the state. 
+	 */
+	private Event<?> action;
+	
+	/**
+	 * Identifier of the state
+	 */
+	private String id;
+	
+	/**
+	 * Random number generator used for state transmissions. 
+	 */
+	protected Random rand;
+	
+	/**
+	 * State transmission function to be used by models. 
+	 * @return
+	 */
+	public abstract State getNextState();
+	
+	/**
+	 * Creates a new State object. The id should be unique.
+	 * @param id identifier string of the state
+	 */
+	protected State(String id, Event<?> action) {
+		this.id = id;
+		this.action = action;
+	}
+
+	/**
+	 * Dummy method for history-less state implementations.
+	 */
+	public void setHistoryObject() {}
+	
+	/**
+	 * Defines a random number generator to be used by getNextState.
+	 * @param r Random number generator
+	 */
+	public void setRandom(Random r) {
+		rand = r;
+	}
+	
+	/**
+	 * Returns the id of the state. 
+	 * @return id of the state
+	 */
+	public String getId() {
+		return id;
+	}
+	
+	/**
+	 * The {@link Event} associated with this state. 
+	 * @return {@link Event} associated with this state
+	 */
+	public Event<?> getAction() {
+		return action;
+	}
+	
+	/**
+	 * Two states are equal if their id string is equal.
+	 */
+	@Override
+	public boolean equals(Object other) {
+		if( other==this ) {
+			return true;
+		}
+		boolean isEqual = false;
+		if( other instanceof State ) {
+			isEqual = id.equals(((State) other).id);
+		}
+		return isEqual;
+	}
+	
+	
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode() {
+		int multiplier = 37;
+		int hash = 42;
+		
+		hash = multiplier*hash + id.hashCode();
+		
+		return hash;
+	}
+	
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/PredictionByPartialMatch.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/PredictionByPartialMatch.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/PredictionByPartialMatch.java	(revision 1)
@@ -0,0 +1,106 @@
+package de.ugoe.cs.eventbench.ppm;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.eventbench.markov.IncompleteMemory;
+import de.ugoe.cs.util.console.Console;
+
+public class PredictionByPartialMatch {
+	
+	private String initialSymbol = "GLOBALSTARTSTATE";
+	private String endSymbol = "GLOBALENDSTATE";
+	
+	private int maxOrder = 3;
+	
+	private Trie<String> trie;
+	
+	private Set<String> knownSymbols;
+	
+	// the training is basically the generation of the trie
+	public void train(List<List<Event<?>>> sequences) {
+		trie = new Trie<String>();
+		knownSymbols = new LinkedHashSet<String>();
+		knownSymbols.add(initialSymbol);
+		knownSymbols.add(endSymbol);
+		
+		for(List<Event<?>> sequence : sequences) {
+			IncompleteMemory<String> latestActions = new IncompleteMemory<String>(maxOrder); // TODO need to check if it should be maxOrder+1
+			latestActions.add(initialSymbol);
+			for(Event<?> currentAction : sequence) {
+				String currentId = currentAction.getStandardId();
+				latestActions.add(currentId);
+				knownSymbols.add(currentId);
+				if( latestActions.getLength()==maxOrder ) { // FIXME needs special case for sequences shorter than maxOrder
+					trie.add(latestActions.getLast(maxOrder));
+				}
+			}
+			latestActions.add(endSymbol);
+			if( latestActions.getLength()==maxOrder ) { // FIXME needs special case for sequences shorter than maxOrder
+				trie.add(latestActions.getLast(maxOrder));
+			}
+		}
+	}
+	
+	public void printRandomWalk(Random r) {
+		IncompleteMemory<String> context = new IncompleteMemory<String>(maxOrder-1);
+		
+		context.add(initialSymbol);
+		
+		String currentState = initialSymbol;
+		
+		Console.println(currentState);
+		while(!endSymbol.equals(currentState)) {
+			double randVal = r.nextDouble();
+			double probSum = 0.0;
+			List<String> currentContext = context.getLast(maxOrder);
+			for( String symbol : knownSymbols ) {
+				probSum += getProbability(currentContext, symbol);
+				if( probSum>=randVal ) {
+					currentContext.add(symbol);
+					currentState = symbol;
+					Console.println(currentState);
+					break;
+				}
+			}
+		}
+	}
+	
+	private double getProbability(List<String> context, String symbol) {
+		double result = 0.0; 
+		int countContextSymbol = 0;
+		List<String> contextSuffix = trie.getContextSuffix(context);
+		if( contextSuffix.isEmpty() ) {
+			result = 1.0d / knownSymbols.size(); 
+		} else {
+			countContextSymbol = trie.getCount(contextSuffix, symbol);
+			List<String> followers = trie.getFollowingSymbols(contextSuffix);
+			int countContextFollowers = 0;
+			for( String follower : followers ) {
+				countContextFollowers += trie.getCount(contextSuffix, follower);
+			}
+			
+			if( followers.isEmpty() ) {
+				throw new AssertionError("Invalid return value of getContextSuffix!");
+			}
+			if( countContextSymbol!=0 ) {
+				result = ((double) countContextSymbol) / (followers.size()+countContextFollowers);
+			} else { // escape
+				double probEscape = ((double) followers.size()) / (followers.size()+countContextFollowers);
+				contextSuffix.remove(0);
+				double probSuffix = getProbability(contextSuffix, symbol);
+				result = probEscape*probSuffix;
+			}
+		}
+
+		return result;
+	}
+	
+	@Override
+	public String toString() {
+		return trie.toString();
+	}
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/Trie.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/Trie.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/Trie.java	(revision 1)
@@ -0,0 +1,100 @@
+package de.ugoe.cs.eventbench.ppm;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class Trie<T> {
+	
+	private List<TrieNode<T>> children = new LinkedList<TrieNode<T>>();
+	
+
+	public void add(List<T> subsequence) {
+		if( !subsequence.isEmpty() ) {
+			subsequence = new LinkedList<T>(subsequence);  // copy list!
+			T firstSymbol = subsequence.get(0);
+			getChildCreate(firstSymbol).add(subsequence);
+		}
+	}
+
+	// FIXME clones of TrieNode.getChildCreate
+	protected TrieNode<T>  getChildCreate(T symbol) {
+		TrieNode<T> node = getChild(symbol);
+		if( node==null ) {
+			node = new TrieNode<T>(symbol);
+			children.add(node);
+		}
+		return node;
+	}
+	
+	// FIXME clones of TrieNode.getChild
+	protected TrieNode<T> getChild(T symbol) {
+		for( TrieNode<T> child : children ) {
+			if( child.getSymbol().equals(symbol) ) {
+				return child;
+			}
+		}
+		return null;
+	}
+
+	public int getCount(List<T> sequence) {
+		int count = 0;
+		TrieNode<T> node = find(sequence);
+		if( node!=null ) {
+			count = node.getCount();
+		}
+		return count;
+	}
+	
+	public int getCount(List<T> sequence, T follower) {
+		List<T> tmpSequence = new LinkedList<T>(sequence);
+		tmpSequence.add(follower);
+		return getCount(tmpSequence);
+		
+	}
+	
+	public TrieNode<T> find(List<T> sequence) {
+		TrieNode<T> result = null;
+		if( !sequence.isEmpty() ) {
+			TrieNode<T> node = getChild(sequence.get(0));
+			if( node!=null ) {
+				result = node.find(sequence);
+			}
+		}
+		return result;
+	}
+	
+	public List<T> getFollowingSymbols(List<T> sequence) {
+		List<T> result = null;
+		TrieNode<T> node = find(sequence);
+		if( node!=null ) {
+			result = node.getFollowingSymbols();
+		}
+		return result;
+	}
+	
+	public List<T> getContextSuffix(List<T> context) {
+		List<T> contextSuffix = new LinkedList<T>(context);
+		boolean suffixFound = false;
+		
+		while(!suffixFound) {
+			if( contextSuffix.isEmpty() ) {
+				suffixFound = true; // suffix is the empty word
+			} else {
+				TrieNode<T> node = find(contextSuffix);
+				if( node!=null ) {
+					if( !node.getFollowingSymbols().isEmpty() ) {
+						suffixFound = true;
+					}
+				}
+				contextSuffix.remove(0);
+			}
+		}
+		
+		return contextSuffix;
+	}
+	
+	@Override
+	public String toString() {
+		return children.toString();
+	}
+}
Index: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/TrieNode.java
===================================================================
--- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/TrieNode.java	(revision 1)
+++ trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/TrieNode.java	(revision 1)
@@ -0,0 +1,99 @@
+package de.ugoe.cs.eventbench.ppm;
+
+import java.security.InvalidParameterException;
+import java.util.LinkedList;
+import java.util.List;
+
+import de.ugoe.cs.util.StringTools;
+
+
+class TrieNode<T> {
+	
+	private int count;
+	private final T symbol;
+	
+	private List<TrieNode<T>> children;
+	
+	public TrieNode(T symbol) {
+		if( symbol==null ) {
+			throw new InvalidParameterException("symbol must not be null.");
+		}
+		this.symbol = symbol;
+		count = 0;
+		children = new LinkedList<TrieNode<T>>();
+	}
+
+	public void add(List<T> subsequence) {
+		if( !subsequence.isEmpty() ) {
+			if( !symbol.equals(subsequence.get(0)) ) { // should be guaranteed by the recursion/TrieRoot!
+				throw new AssertionError("Invalid trie operation!");
+			}
+			count++;
+			subsequence.remove(0);
+			if( !subsequence.isEmpty() ) {
+				T nextSymbol = subsequence.get(0);
+				getChildCreate(nextSymbol).add(subsequence);
+			}
+		}
+	}
+	
+	public T getSymbol() {
+		return symbol;
+	}
+	
+	public int getCount() {
+		return count;
+	}
+	
+	protected TrieNode<T>  getChildCreate(T symbol) {
+		TrieNode<T> node = getChild(symbol);
+		if( node==null ) {
+			node = new TrieNode<T>(symbol);
+			children.add(node);
+		}
+		return node;
+	}
+	
+	protected TrieNode<T> getChild(T symbol) {
+		for( TrieNode<T> child : children ) {
+			if( child.getSymbol().equals(symbol) ) {
+				return child;
+			}
+		}
+		return null;
+	}
+	
+
+	
+	public TrieNode<T> find(List<T> subsequence) {
+		TrieNode<T> result = null;
+		if( subsequence.isEmpty() ) {
+			result = this;
+		} else {
+			TrieNode<T> node = getChild(subsequence.get(0));
+			if( node!=null ) {
+				subsequence.remove(0);
+				result = node.find(subsequence);
+			}
+		}
+		return result;
+	}
+	
+	public List<T> getFollowingSymbols() {
+		List<T> followingSymbols = new LinkedList<T>();
+		for( TrieNode<T> child : children ) {
+			followingSymbols.add(child.getSymbol());
+		}
+		return followingSymbols;
+	}
+	
+	@Override
+	public String toString() {
+		String str = symbol.toString()+" #"+count;
+		if( !children.isEmpty() ) {
+			str += StringTools.ENDLINE + children.toString();
+		}
+		return str; 
+	}
+
+}
Index: trunk/JavaHelperLib/.classpath
===================================================================
--- trunk/JavaHelperLib/.classpath	(revision 1)
+++ trunk/JavaHelperLib/.classpath	(revision 1)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: trunk/JavaHelperLib/.project
===================================================================
--- trunk/JavaHelperLib/.project	(revision 1)
+++ trunk/JavaHelperLib/.project	(revision 1)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>JavaHelperLib</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: trunk/JavaHelperLib/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/JavaHelperLib/.settings/org.eclipse.jdt.core.prefs	(revision 1)
+++ trunk/JavaHelperLib/.settings/org.eclipse.jdt.core.prefs	(revision 1)
@@ -0,0 +1,12 @@
+#Thu Jan 06 10:47:41 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Index: trunk/JavaHelperLib/src/de/ugoe/cs/util/ArrayTools.java
===================================================================
--- trunk/JavaHelperLib/src/de/ugoe/cs/util/ArrayTools.java	(revision 1)
+++ trunk/JavaHelperLib/src/de/ugoe/cs/util/ArrayTools.java	(revision 1)
@@ -0,0 +1,32 @@
+package de.ugoe.cs.util;
+
+final public class ArrayTools {
+	
+	/**
+	 * <p>
+	 * Finds the first occurence of an object inside an array.
+	 * </p>
+	 * <p>
+	 * In case {@code other==null}, the first occurence of a {@code null} value in the array is returned.
+	 * </p>
+	 *  
+	 * @param array the array
+	 * @param other the object
+	 * @return index of the object if found, -1 otherwise
+	 */
+	public static int findIndex(Object[] array, Object other) {
+		int retVal = -1;
+		for( int i=0 ; i<array.length && retVal==-1 ; i++ ) {
+			if( other!=null ) {
+				if( array[i]!=null && array[i].equals(other) ) {
+					retVal = i;
+				}
+			} else {
+				if( array[i]==null ) {
+					retVal = i;
+				}
+			}
+		}
+		return retVal;
+	}
+}
Index: trunk/JavaHelperLib/src/de/ugoe/cs/util/StringTools.java
===================================================================
--- trunk/JavaHelperLib/src/de/ugoe/cs/util/StringTools.java	(revision 1)
+++ trunk/JavaHelperLib/src/de/ugoe/cs/util/StringTools.java	(revision 1)
@@ -0,0 +1,28 @@
+package de.ugoe.cs.util;
+
+final public class StringTools {
+
+	public final static String ENDLINE = System.getProperty("line.separator");
+	
+	/**
+	 * <p>
+	 * Replaces all occurences of {@literal &, <, >, ', and "} with their
+	 * respective XML entites {@literal &amp;, &lt;, &gt;, &apos;, and &quot;}
+	 * without destroying already existing entities.
+	 * </p>
+	 * 
+	 * @param str
+	 *            String where the XML entites are to be replaced
+	 * @return new String, where the XML entites are used instead of the
+	 *         literals
+	 */
+	public static String xmlEntityReplacement(String str) {
+		String result = str;
+		result = result.replaceAll("&(?!(?:lt|gt|apos|quot|amp);)", "&amp;");
+		result = result.replaceAll("<", "&lt;");
+		result = result.replaceAll(">", "&gt;");
+		result = result.replaceAll("'", "&apos;");
+		result = result.replaceAll("\"", "&quot;");
+		return result;
+	}
+}
Index: trunk/JavaHelperLib/src/de/ugoe/cs/util/console/Command.java
===================================================================
--- trunk/JavaHelperLib/src/de/ugoe/cs/util/console/Command.java	(revision 1)
+++ trunk/JavaHelperLib/src/de/ugoe/cs/util/console/Command.java	(revision 1)
@@ -0,0 +1,32 @@
+package de.ugoe.cs.util.console;
+
+import java.util.List;
+
+/**
+ * <p>
+ * Defines the interface for a command. The class names of the commands must be
+ * of the form {@code CMD<commandname>}, otherwise they cannot be used by the
+ * {@link CommandExecuter}.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ */
+public interface Command {
+
+	/**
+	 * <p>
+	 * Executes a command.
+	 * </p>
+	 * 
+	 * @param parameters
+	 *            parameters for the command.
+	 */
+	public void run(List<Object> parameters);
+
+	/**
+	 * <p>
+	 * Sends information about how to use a command to the console.
+	 * </p>
+	 */
+	public void help();
+}
Index: trunk/JavaHelperLib/src/de/ugoe/cs/util/console/CommandExecuter.java
===================================================================
--- trunk/JavaHelperLib/src/de/ugoe/cs/util/console/CommandExecuter.java	(revision 1)
+++ trunk/JavaHelperLib/src/de/ugoe/cs/util/console/CommandExecuter.java	(revision 1)
@@ -0,0 +1,152 @@
+package de.ugoe.cs.util.console;
+
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * <p>
+ * Executes commands. The commands have to implement the {@link Command}
+ * interface and be in packages registered using addCommandPackage().
+ * Additionally, default commands are implemented in the
+ * de.ugoe.cs.util.console.defaultcommands package.
+ * </p>
+ * <p>
+ * This class is implemented as a <i>Singleton</i>. 
+ * </p>
+ * 
+ * @author Steffen Herbold
+ */
+public class CommandExecuter {
+
+	/**
+	 * <p>
+	 * Handle of the CommandExecuter instance.
+	 * </p>
+	 */
+	private final static CommandExecuter theInstance = new CommandExecuter();
+
+	/**
+	 * <p>
+	 * Prefix of all command classes.
+	 * </p>
+	 */
+	private static final String cmdPrefix = "CMD";
+	
+	/**
+	 * <p>
+	 * Name of the package for default commands.
+	 * </p>
+	 */
+	private static final String defaultPackage = "de.ugoe.cs.util.console.defaultcommands";
+
+	/**
+	 * <p>
+	 * List of packages in which commands may be defined. The exec methods trys
+	 * to load command from these packages in the order they have been added.
+	 * </p>
+	 * <p>
+	 * The defaultcommands package has always lowest priority, unless it is
+	 * specificially added.
+	 * </p>
+	 */
+	private List<String> commandPackageList;
+
+	/**
+	 * <p>
+	 * Returns the instance of CommandExecuter. If no instances exists yet, a
+	 * new one is created.
+	 * </p>
+	 * 
+	 * @return the instance of CommandExecuter
+	 */
+	public static synchronized CommandExecuter getInstance() {
+		return theInstance;
+	}
+
+	/**
+	 * <p>
+	 * Creates a new CommandExecuter. Private to prevent multiple instances
+	 * (Singleton).
+	 * </p>
+	 */
+	private CommandExecuter() {
+		commandPackageList = new ArrayList<String>();
+	}
+
+	/**
+	 * <p>
+	 * Adds a package that will be used by exec to load command from.
+	 * </p>
+	 * 
+	 * @param pkg
+	 *            package where commands are located
+	 */
+	public void addCommandPackage(String pkg) {
+		commandPackageList.add(pkg);
+	}
+
+	/**
+	 * <p>
+	 * Executes the command defined by string. A command has the following form
+	 * (mix of EBNF and natural language):
+	 * </p>
+	 * <code>
+	 * &lt;command&gt; := &lt;commandname&gt;&lt;whitespace&gt;{&lt;parameter&gt;}<br>
+	 * &lt;commandname&gt; := String without whitespaces. Has to be a valid Java class name<br>
+	 * &lt;parameter&gt; := &lt;string&gt;|&lt;stringarray&gt;<br>
+	 * &lt;string&gt; := &lt;stringwithoutwhitespaces&gt;|&lt;stringwithwhitespaces&gt;
+	 * &lt;stringwithoutwhitespaces&gt; := a string without whitespaces<br>
+	 * &lt;stringwithoutwhitespaces&gt; := a string, that can have whitespaces, but must be in double quotes<br>
+	 * &lt;stringarray&gt; := "["&lt;string&gt;{&lt;whitespace&gt;&lt;string&gt;"]"
+	 * </code>
+	 * 
+	 * @param command
+	 *            the command as a string
+	 */
+	public void exec(String command) {
+		Command cmd = null;
+		CommandParser parser = new CommandParser();
+		parser.parse(command);
+		for (int i = 0; cmd == null && i < commandPackageList.size(); i++) {
+			cmd = loadCMD(commandPackageList.get(i)+"."+cmdPrefix+parser.getCommandName());
+		}
+		if (cmd == null) { // check if command is available as default command
+			cmd = loadCMD(defaultPackage+"."+cmdPrefix+parser.getCommandName());
+		}
+		if (cmd == null) {
+			Console.println("Unknown command");
+		} else {
+			try {
+				cmd.run(parser.getParameters());
+			} catch (InvalidParameterException e) {
+				cmd.help();
+			}
+		}
+	}
+
+	/**
+	 * Helper method that loads a class and tries to cast it to {@link Command}.
+	 * 
+	 * @param className qualified name of the class (including package name)
+	 * @return if class is available and implement {@link Command} and instance of the class, null otherwise
+	 */
+	private Command loadCMD(String className) {
+		Command cmd = null;
+		try {
+			Class<?> cmdClass = Class.forName(className);
+			cmd = (Command) cmdClass.newInstance();
+		} catch (NoClassDefFoundError e) {
+			String[] splitResult = e.getMessage().split("CMD");
+			String correctName = splitResult[splitResult.length-1].replace(")", "");
+			Console.traceln("Did you mean " + correctName + "?");
+		} catch (ClassNotFoundException e) {
+		} catch (IllegalAccessException e) {
+		} catch (InstantiationException e) {
+		} catch (ClassCastException e) {
+			Console.traceln(className + "found, but does not implement Command");
+		}
+		return cmd;
+	}
+}
Index: trunk/JavaHelperLib/src/de/ugoe/cs/util/console/CommandParser.java
===================================================================
--- trunk/JavaHelperLib/src/de/ugoe/cs/util/console/CommandParser.java	(revision 1)
+++ trunk/JavaHelperLib/src/de/ugoe/cs/util/console/CommandParser.java	(revision 1)
@@ -0,0 +1,199 @@
+package de.ugoe.cs.util.console;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * Helper class to parse command strings and create parameters.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ */
+public class CommandParser {
+
+	/**
+	 * <p>
+	 * Name of the command.
+	 * </p>
+	 */
+	private String commandName;
+
+	/**
+	 * <p>
+	 * Parameters of the command as a {@link List}. The parameters can either be
+	 * {@link String} or {@link String} arrays.
+	 * </p>
+	 */
+	private List<Object> parameters;
+
+	/**
+	 * <p>
+	 * Creates a new CommandParser.
+	 * </p>
+	 */
+	public CommandParser() {
+		commandName = "";
+		parameters = new ArrayList<Object>();
+	}
+
+	/**
+	 * <p>
+	 * Returns the name of the command.
+	 * </p>
+	 * 
+	 * @return name of the command
+	 */
+	public String getCommandName() {
+		return commandName;
+	}
+
+	/**
+	 * <p>
+	 * Returns the {@link List} of parameters
+	 * </p>
+	 * 
+	 * @return
+	 */
+	public List<Object> getParameters() {
+		return parameters;
+	}
+
+	/**
+	 * <p>
+	 * Parses a command after the following EBNF (mixed with natural language):
+	 * </p>
+	 * <code>
+	 * &lt;command&gt; :=
+	 * &lt;commandname&gt;&lt;whitespace&gt;{&lt;parameter&gt;}<br>
+	 * &lt;commandname&gt; := String without whitespaces. Has to be a valid Java
+	 * class name<br>
+	 * &lt;parameter&gt; := &lt;string&gt;|&lt;stringarray&gt;<br>
+	 * &lt;string&gt; :=
+	 * &lt;stringwithoutwhitespaces&gt;|&lt;stringwithwhitespaces&gt;
+	 * &lt;stringwithoutwhitespaces&gt; := a string without whitespaces<br>
+	 * &lt;stringwithoutwhitespaces&gt; := a string, that can have whitespaces,
+	 * but must be in double quotes<br>
+	 * &lt;stringarray&gt; :=
+	 * "["&lt;string&gt;{&lt;whitespace&gt;&lt;string&gt;"]"
+	 * </code>
+	 * 
+	 * @param command
+	 *            the command as a string
+	 */
+	public void parse(String command) {
+		if (command == null || command.equals("")) {
+			return;
+		}
+		String[] splitResult = command.split(" ");
+		commandName = splitResult[0];
+		char[] commandChars = command.substring(commandName.length())
+				.toCharArray();
+		boolean startParameter = true;
+		boolean isArray = false;
+		boolean startArrayparameter = false;
+		boolean isString = false;
+		int bufferPos = 0;
+		char[] buffer = new char[1024];
+		boolean quote = false;
+		List<String> arrayBuffer = null;
+		for (int i = 0; i < commandChars.length; i++) {
+			if (i < commandChars.length && startParameter
+					&& commandChars[i] == '[') {
+				isArray = true;
+				startArrayparameter = true;
+				arrayBuffer = new ArrayList<String>();
+				startParameter = false;
+				i++; // skip [
+			}
+			if (i < commandChars.length && startParameter
+					&& commandChars[i] == '\'') {
+				isString = true;
+				quote = true;
+				startParameter = false;
+				i++; // skip '
+			}
+			if (i < commandChars.length && startParameter
+					&& !Character.isWhitespace(commandChars[i])) {
+				isString = true;
+				startParameter = false;
+			}
+			if (isArray) {
+				if (i < commandChars.length && commandChars[i] == ']') {
+					if (bufferPos > 0) {
+						buffer[bufferPos] = '\0';
+						arrayBuffer.add((new String(buffer)).trim());
+					}
+					parameters.add(arrayBuffer.toArray(new String[0]));
+					isArray = false;
+					isString = false;
+					bufferPos = 0;
+					buffer = new char[128];
+					startArrayparameter = false;
+					startParameter = true;
+					i++; // skip ]
+				}
+				if (i < commandChars.length && startArrayparameter
+						&& !Character.isWhitespace(commandChars[i])) {
+					buffer = new char[128];
+					bufferPos = 0;
+					quote = commandChars[i] == '\'';
+					if (quote) {
+						i++; // skip '
+					}
+					startArrayparameter = false;
+				}
+				if (i < commandChars.length && quote && commandChars[i] == '\'') {
+					// end of parameter with '
+					i++; // skip '
+					startArrayparameter = true;
+					buffer[bufferPos] = '\0';
+					arrayBuffer.add((new String(buffer)).trim());
+				}
+				if (i < commandChars.length && !quote
+						&& Character.isWhitespace(commandChars[i])) {
+					startArrayparameter = true;
+					buffer[bufferPos] = '\0';
+					arrayBuffer.add((new String(buffer)).trim());
+				}
+				if (i < commandChars.length && !startArrayparameter
+						&& !startParameter) {
+					buffer[bufferPos] = commandChars[i];
+					bufferPos++;
+				}
+			}
+			if (isString) {
+				if ((quote && commandChars[i] == '\'')
+						|| (!quote && Character.isWhitespace(commandChars[i]))) {
+					// end of parameter with '
+					if (quote) {
+						i++; // skip '
+					}
+					if (bufferPos > 0) {
+						buffer[bufferPos] = '\0';
+					}
+					parameters.add((new String(buffer).trim()));
+					isArray = false;
+					isString = false;
+					bufferPos = 0;
+					buffer = new char[128];
+					startArrayparameter = false;
+					startParameter = true;
+				}
+				if (!startParameter) {
+					buffer[bufferPos] = commandChars[i];
+					bufferPos++;
+				}
+			}
+		}
+		if (bufferPos > 0) {
+			if (isArray) {
+				arrayBuffer.add((new String(buffer)).trim());
+				parameters.add(arrayBuffer);
+			}
+			if (isString) {
+				parameters.add((new String(buffer)).trim());
+			}
+		}
+	}
+}
Index: trunk/JavaHelperLib/src/de/ugoe/cs/util/console/Console.java
===================================================================
--- trunk/JavaHelperLib/src/de/ugoe/cs/util/console/Console.java	(revision 1)
+++ trunk/JavaHelperLib/src/de/ugoe/cs/util/console/Console.java	(revision 1)
@@ -0,0 +1,218 @@
+package de.ugoe.cs.util.console;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import de.ugoe.cs.util.StringTools;
+
+
+/**
+ * <p>
+ * This class provides an interface for communication with the user without have
+ * to rely on a specific user interface. Thus, it can be used to decouple the
+ * programs logic from its user interface.
+ * </p>
+ * <p>
+ * {@link Command} objects can be used to execute behavior.
+ * </p>
+ * <p>
+ * To send output to the user interface, the Observer pattern is used. The
+ * Console is an observable, the concrete user interfaces are the observers. The
+ * interface for the observers is {@link ConsoleObserver}.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ */
+public final class Console {
+
+	/**
+	 * <p>
+	 * List of observers.
+	 * </p>
+	 */
+	private List<ConsoleObserver> observers;
+
+	/**
+	 * <p>
+	 * Handle of the Console instance.
+	 * </p>
+	 */
+	private static Console theInstance = null;
+
+	/**
+	 * <p>
+	 * Returns the instance of Console. If no instances exists yet, a new one is
+	 * created.
+	 * </p>
+	 * 
+	 * @return instance of this class
+	 */
+	public static Console getInstance() {
+		if (theInstance == null) {
+			theInstance = new Console();
+		}
+		return theInstance;
+	}
+
+	/**
+	 * <p>
+	 * Creates a new Console. Private to prevent multiple instances (Singleton).
+	 * </p>
+	 */
+	private Console() {
+		observers = new ArrayList<ConsoleObserver>();
+	}
+
+	/**
+	 * <p>
+	 * Register a new observer.
+	 * </p>
+	 * 
+	 * @param observer
+	 *            observer to be added
+	 */
+	public void registerObserver(ConsoleObserver observer) {
+		observers.add(observer);
+	}
+
+	/**
+	 * <p>
+	 * Remove an observer. If the observer is not found, nothing is done.
+	 * </p>
+	 * 
+	 * @param observer
+	 *            observer to be removed
+	 */
+	public void deleteObserver(ConsoleObserver observer) {
+		observers.remove(observer);
+	}
+
+	/**
+	 * <p>
+	 * Sends a message to all observers containing the message that was passed
+	 * to this function.
+	 * </p>
+	 * 
+	 * @param msg
+	 *            message that is send to the console
+	 */
+	public static void print(String msg) {
+		if (theInstance == null) {
+			getInstance();
+		}
+		for (ConsoleObserver observer : theInstance.observers) {
+			observer.updateText(msg);
+		}
+	}
+
+	/**
+	 * <p>
+	 * Sends a message to all observers containing the message that was passed
+	 * to this function and adds an endline to the message.
+	 * </p>
+	 * 
+	 * @param msg
+	 *            message that is send to the observers
+	 */
+	public static void println(String msg) {
+		if (theInstance == null) {
+			getInstance();
+		}
+		for (ConsoleObserver observer : theInstance.observers) {
+			observer.updateText(msg
+					+ StringTools.ENDLINE);
+		}
+	}
+
+	/**
+	 * <p>
+	 * Sends an error message to all observers containing the message that was
+	 * passed to this function.
+	 * </p>
+	 * 
+	 * @param errMsg
+	 *            message that is send to the observers
+	 */
+	public static void printerr(String errMsg) {
+		if (theInstance == null) {
+			getInstance();
+		}
+		for (ConsoleObserver observer : theInstance.observers) {
+			observer.errStream(errMsg);
+		}
+	}
+
+	/**
+	 * <p>
+	 * Sends an error message to all observers containing the message that was
+	 * passed to this function and adds an endline to the message.
+	 * </p>
+	 * 
+	 * @param errMsg
+	 *            message that is send to the observers
+	 */
+	public static void printerrln(String errMsg) {
+		if (theInstance == null) {
+			getInstance();
+		}
+		for (ConsoleObserver observer : theInstance.observers) {
+			observer.errStream(errMsg
+					+ StringTools.ENDLINE);
+		}
+	}
+
+	/**
+	 * <p>
+	 * Sends an exception to all observers to print its stack trace.
+	 * </p>
+	 * 
+	 * @param e
+	 *            exception whose stack trace is to be printed
+	 */
+	public static void printStacktrace(Exception e) {
+		if (theInstance == null) {
+			getInstance();
+		}
+		for (ConsoleObserver observer : theInstance.observers) {
+			observer.printStacktrace(e);
+		}
+	}
+
+	/**
+	 * <p>
+	 * Sends a debug message to all observers containing the message that was
+	 * passed to this function.
+	 * </p>
+	 * 
+	 * @param traceMsg
+	 *            message that is send to the observers
+	 */
+	public static void trace(String traceMsg) {
+		if (theInstance == null) {
+			getInstance();
+		}
+		for (ConsoleObserver observer : theInstance.observers) {
+			observer.trace(traceMsg);
+		}
+	}
+
+	/**
+	 * <p>
+	 * Sends a debug message to all observers containing the message that was
+	 * passed to this function and adds an endline to the message.
+	 * </p>
+	 * 
+	 * @param traceMsg
+	 *            message that is send to the observers
+	 */
+	public static void traceln(String traceMsg) {
+		if (theInstance == null) {
+			getInstance();
+		}
+		for (ConsoleObserver observer : theInstance.observers) {
+			observer.trace(traceMsg
+					+ StringTools.ENDLINE);
+		}
+	}
+
+}
Index: trunk/JavaHelperLib/src/de/ugoe/cs/util/console/ConsoleObserver.java
===================================================================
--- trunk/JavaHelperLib/src/de/ugoe/cs/util/console/ConsoleObserver.java	(revision 1)
+++ trunk/JavaHelperLib/src/de/ugoe/cs/util/console/ConsoleObserver.java	(revision 1)
@@ -0,0 +1,53 @@
+package de.ugoe.cs.util.console;
+
+/**
+ * <p>
+ * Observer for Console.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ */
+public interface ConsoleObserver {
+
+	/**
+	 * <p>
+	 * If a new message is send to the console, all observers are updated using
+	 * this method.
+	 * </p>
+	 * 
+	 * @param newMessage
+	 *            message that was send to the console.
+	 */
+	public void updateText(String newMessage);
+
+	/**
+	 * <p>
+	 * Send messages to the error stream of all observers.
+	 * </p>
+	 * 
+	 * @param errMessage
+	 *            error message
+	 */
+	public void errStream(String errMessage);
+
+	/**
+	 * <p>
+	 * Send messages to the trace stream of all observers.
+	 * </p>
+	 * 
+	 * @param traceMesssage
+	 *            error message
+	 */
+	public void trace(String traceMessage);
+
+	/**
+	 * <p>
+	 * Prints the stack trace of an exception.
+	 * </p>
+	 * 
+	 * @param e
+	 *            exception whose stack trace is to be printed
+	 */
+	public void printStacktrace(Exception e);
+
+}
Index: trunk/JavaHelperLib/src/de/ugoe/cs/util/console/TextConsole.java
===================================================================
--- trunk/JavaHelperLib/src/de/ugoe/cs/util/console/TextConsole.java	(revision 1)
+++ trunk/JavaHelperLib/src/de/ugoe/cs/util/console/TextConsole.java	(revision 1)
@@ -0,0 +1,119 @@
+package de.ugoe.cs.util.console;
+
+import java.io.IOException;
+
+/**
+ * <p>
+ * Implements a simple console observer that prints normal text to
+ * <code>stdout</code>, errors to <code>stderr</code> and reads from
+ * <code>stdin</code>.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ */
+public class TextConsole implements ConsoleObserver {
+
+	/**
+	 * <p>
+	 * In the debug mode, trace messages will be printed.
+	 * </p>
+	 */
+	private boolean debugMode = true;
+
+	/**
+	 * <p>
+	 * Creates a new text console and automatically registers it as observer.
+	 * </p>
+	 */
+	public TextConsole() {
+		Console.getInstance().registerObserver(this);
+	}
+
+	/**
+	 * <p>
+	 * Prints messages to <code>stdout</code>.
+	 * </p>
+	 * 
+	 * @see ConsoleObserver#updateText(java.lang.String)
+	 */
+	public void updateText(String newMessage) {
+		System.out.print(newMessage);
+	}
+
+	/**
+	 * <p>
+	 * Prints messages to <code>stderr</code>.
+	 * </p>
+	 * 
+	 * @see ConsoleObserver#errStream(String)
+	 */
+	@Override
+	public void errStream(String errMessage) {
+		System.err.print(errMessage);
+	}
+
+	/**
+	 * <p>
+	 * Prints the stackrace of an exception to <code>stderr</code>
+	 * </p>
+	 * 
+	 * @see ConsoleObserver#printStacktrace(Exception)
+	 */
+	@Override
+	public void printStacktrace(Exception e) {
+		e.printStackTrace();
+	}
+
+	/**
+	 * <p>
+	 * Prints messages to <code>stdout</code>. These messages are only printed,
+	 * if the console is run in debug mode.
+	 * </p>
+	 */
+	@Override
+	public void trace(String traceMessage) {
+		if (debugMode) {
+			System.out.print(traceMessage);
+		}
+	}
+
+	/**
+	 * <p>
+	 * Starts a new TextConsole. If the text console is started, it can be used
+	 * not only to print message, but also to execute commands by reading
+	 * <code>stdin</code>.
+	 * </p>
+	 * 
+	 * @param debugMode
+	 *            true, if the application is to run in debug mode, i.e. trace
+	 *            messages will be printed
+	 */
+	public void run(boolean debugMode) {
+		this.debugMode = debugMode;
+		CommandExecuter exec = CommandExecuter.getInstance();
+		while (true) {
+			System.out.print("> ");
+			String command = getCommand().trim();
+			if (!command.equals("")) {
+				exec.exec(command);
+			}
+		}
+	}
+
+	/**
+	 * <p>
+	 * Reads a new command from <code>stdin</code>.
+	 * </p>
+	 * 
+	 * @return a string with a command
+	 */
+	protected String getCommand() {
+		byte[] buffer = new byte[1024];
+		try {
+			System.in.read(buffer);
+		} catch (IOException e) {
+
+		}
+		return new String(buffer);
+	}
+}
Index: trunk/JavaHelperLib/src/de/ugoe/cs/util/console/defaultcommands/CMDexec.java
===================================================================
--- trunk/JavaHelperLib/src/de/ugoe/cs/util/console/defaultcommands/CMDexec.java	(revision 1)
+++ trunk/JavaHelperLib/src/de/ugoe/cs/util/console/defaultcommands/CMDexec.java	(revision 1)
@@ -0,0 +1,70 @@
+package de.ugoe.cs.util.console.defaultcommands;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.security.InvalidParameterException;
+import java.util.List;
+
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.CommandExecuter;
+import de.ugoe.cs.util.console.Console;
+
+/**
+ * <p>
+ * Implements a command to execute batchs of {@link Command}s, defined by batch
+ * file, to allow scripted executions.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ */
+public class CMDexec implements Command {
+
+	/**
+	 * <p>
+	 * Executes a batch of {@link Command}s that are listed line by line in the
+	 * given file.
+	 * </p>
+	 * <p>
+	 * Usage: <code>exec filename</code>
+	 * </p>
+	 * 
+	 * @see de.ugoe.cs.util.console.commands.Command#run(java.util.List)
+	 */
+	public void run(List<Object> parameters) {
+		String script;
+		try {
+			script = (String) parameters.get(0);
+		} catch (Exception e) {
+			throw new InvalidParameterException();
+		}
+		try {
+			String[] commands;
+			File f = new File(script);
+			FileReader reader = new FileReader(f);
+			char[] buffer = new char[(int) f.length()];
+			reader.read(buffer);
+			commands = (new String(buffer)).split("\n");
+			for (String command : commands) {
+				Console.println(command);
+				CommandExecuter.getInstance().exec(command);
+			}
+			reader.close();
+		} catch (FileNotFoundException e) {
+			Console.printerrln(e.getMessage());
+		} catch (IOException e) {
+			Console.printerrln(e.getMessage());
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see databasebuilder.console.commands.Command#help()
+	 */
+	@Override
+	public void help() {
+		Console.println("Usage: exec filename");
+	}
+}
Index: trunk/JavaHelperLib/src/de/ugoe/cs/util/console/defaultcommands/CMDexit.java
===================================================================
--- trunk/JavaHelperLib/src/de/ugoe/cs/util/console/defaultcommands/CMDexit.java	(revision 1)
+++ trunk/JavaHelperLib/src/de/ugoe/cs/util/console/defaultcommands/CMDexit.java	(revision 1)
@@ -0,0 +1,39 @@
+package de.ugoe.cs.util.console.defaultcommands;
+
+import java.util.List;
+
+import de.ugoe.cs.util.console.Command;
+import de.ugoe.cs.util.console.Console;
+
+/**
+ * <p>
+ * Implements a command to terminate an application.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ *
+ */
+public class CMDexit implements Command {
+
+	/* (non-Javadoc)
+	 * @see databasebuilder.console.commands.Command#help()
+	 */
+	@Override
+	public void help() {
+		Console.println("Usage: exit");
+	}
+	
+	/**
+	 * <p>
+	 * Terminates the programm.
+	 * </p>
+	 * <p>
+	 * Usage: <code>exit</code>
+	 * </p>
+	 */
+	@Override
+	public void run(List<Object> parameters) {
+		System.exit(0);
+	}
+
+}
