From c6ef2f2ccf47ee80f8cca548819a5ef7f3c811e0 Mon Sep 17 00:00:00 2001
From: Nils Christian Ehmke <nie@informatik.uni-kiel.de>
Date: Mon, 8 Dec 2014 10:36:34 +0100
Subject: [PATCH] Added JavaDoc and comments.

---
 .gitignore                                    |  1 +
 .../java/kieker/gui/model/DataSource.java     | 10 +++++++-
 .../java/kieker/gui/model/ExecutionEntry.java |  2 +-
 .../java/kieker/gui/model/Properties.java     | 23 +++++++++++++++++-
 .../java/kieker/gui/model/RecordEntry.java    |  2 +-
 .../importer/ImportAnalysisConfiguration.java | 24 ++++++++++++++++++-
 .../gui/model/importer/filter/Cloner.java     |  2 +-
 .../importer/filter/TraceReconstructor.java   | 11 ++++-----
 src/main/java/kieker/gui/view/MainWindow.java | 18 ++++++++++++++
 9 files changed, 80 insertions(+), 13 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1e25d969..929d53bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@
 /.gradle/2.1/taskArtifacts/taskArtifacts.bin
 /.project
 /.settings/org.eclipse.jdt.core.prefs
+/bin/
diff --git a/src/main/java/kieker/gui/model/DataSource.java b/src/main/java/kieker/gui/model/DataSource.java
index 12107d94..a9b718ae 100644
--- a/src/main/java/kieker/gui/model/DataSource.java
+++ b/src/main/java/kieker/gui/model/DataSource.java
@@ -23,17 +23,25 @@ import java.util.List;
 import kieker.gui.model.importer.ImportAnalysisConfiguration;
 import teetime.framework.Analysis;
 
+/**
+ * A container for data used within this application.
+ * 
+ * @author Nils Christian Ehmke
+ */
 public final class DataSource {
 
 	private List<RecordEntry> records = Collections.emptyList();
 	private List<ExecutionEntry> traces = Collections.emptyList();
 
 	public void loadMonitoringLogFromFS(final String directory) {
-		final ImportAnalysisConfiguration analysisConfiguration = new ImportAnalysisConfiguration(new File(directory));
+		// Load and analyze the monitoring logs from the given directory
+		final File importDirectory = new File(directory);
+		final ImportAnalysisConfiguration analysisConfiguration = new ImportAnalysisConfiguration(importDirectory);
 		final Analysis analysis = new Analysis(analysisConfiguration);
 		analysis.init();
 		analysis.start();
 
+		// Store the results from the analysis
 		this.records = analysisConfiguration.getRecordsList();
 		this.traces = analysisConfiguration.getTracesList();
 	}
diff --git a/src/main/java/kieker/gui/model/ExecutionEntry.java b/src/main/java/kieker/gui/model/ExecutionEntry.java
index 8a706020..4b14b052 100644
--- a/src/main/java/kieker/gui/model/ExecutionEntry.java
+++ b/src/main/java/kieker/gui/model/ExecutionEntry.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * A simplified representation of an execution within a trace.
+ * A simplified representation of an execution within a trace. As an instance of this class can contain other instances, it can be used to represent a trace tree.
  *
  * @author Nils Christian Ehmke
  */
diff --git a/src/main/java/kieker/gui/model/Properties.java b/src/main/java/kieker/gui/model/Properties.java
index 0b4aaaf9..6661c236 100644
--- a/src/main/java/kieker/gui/model/Properties.java
+++ b/src/main/java/kieker/gui/model/Properties.java
@@ -1,8 +1,29 @@
+/***************************************************************************
+ * Copyright 2014 Kieker Project (http://kieker-monitoring.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ***************************************************************************/
+
 package kieker.gui.model;
 
 import java.util.Observable;
 
-public class Properties extends Observable {
+/**
+ * An observable singleton container for properties used within this application.
+ * 
+ * @author Nils Christian Ehmke
+ */
+public final class Properties extends Observable {
 
 	private static final Properties INSTANCE = new Properties();
 	private boolean shortComponentNames = false;
diff --git a/src/main/java/kieker/gui/model/RecordEntry.java b/src/main/java/kieker/gui/model/RecordEntry.java
index e37b30a6..a4914d32 100644
--- a/src/main/java/kieker/gui/model/RecordEntry.java
+++ b/src/main/java/kieker/gui/model/RecordEntry.java
@@ -26,7 +26,7 @@ public final class RecordEntry {
 	private final long timestamp;
 	private final String type;
 	private final String representation;
-
+ 
 	public RecordEntry(final long timestamp, final String type, final String representation) {
 		this.timestamp = timestamp;
 		this.type = type;
diff --git a/src/main/java/kieker/gui/model/importer/ImportAnalysisConfiguration.java b/src/main/java/kieker/gui/model/importer/ImportAnalysisConfiguration.java
index 8bbb100d..e6286894 100644
--- a/src/main/java/kieker/gui/model/importer/ImportAnalysisConfiguration.java
+++ b/src/main/java/kieker/gui/model/importer/ImportAnalysisConfiguration.java
@@ -1,3 +1,19 @@
+/***************************************************************************
+ * Copyright 2014 Kieker Project (http://kieker-monitoring.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ***************************************************************************/
+
 package kieker.gui.model.importer;
 
 import java.io.File;
@@ -21,7 +37,12 @@ import teetime.stage.InstanceOfFilter;
 import teetime.stage.className.ClassNameRegistryRepository;
 import teetime.stage.io.filesystem.Dir2RecordsFilter;
 
-public class ImportAnalysisConfiguration extends AnalysisConfiguration {
+/**
+ * A configuration for the import and analysis of monitoring logs. 
+ * 
+ * @author Nils Christian Ehmke
+ */
+public final class ImportAnalysisConfiguration extends AnalysisConfiguration {
 
 	private final List<RecordEntry> recordsList = new Vector<>(100000);
 	private final List<ExecutionEntry> tracesList = new Vector<>(100000);
@@ -47,6 +68,7 @@ public class ImportAnalysisConfiguration extends AnalysisConfiguration {
 		pipeFactory.create(distributor.getSecondOutputPort(), traceReconstructor.getInputPort());
 		pipeFactory.create(traceReconstructor.getOutputPort(), traceCollector.getInputPort());
 
+		// Make sure that the producer is executed by the analysis
 		super.addThreadableStage(producer);
 	}
 
diff --git a/src/main/java/kieker/gui/model/importer/filter/Cloner.java b/src/main/java/kieker/gui/model/importer/filter/Cloner.java
index dee505bc..d827eb8c 100644
--- a/src/main/java/kieker/gui/model/importer/filter/Cloner.java
+++ b/src/main/java/kieker/gui/model/importer/filter/Cloner.java
@@ -24,7 +24,7 @@ import teetime.framework.OutputPort;
  *
  * @author Nils Christian Ehmke
  */
-public class Cloner<T> extends AbstractConsumerStage<T> {
+public final class Cloner<T> extends AbstractConsumerStage<T> {
 
 	private final OutputPort<T> firstOutputPort = super.createOutputPort();
 	private final OutputPort<T> secondOutputPort = super.createOutputPort();
diff --git a/src/main/java/kieker/gui/model/importer/filter/TraceReconstructor.java b/src/main/java/kieker/gui/model/importer/filter/TraceReconstructor.java
index 7ae02427..440b4274 100644
--- a/src/main/java/kieker/gui/model/importer/filter/TraceReconstructor.java
+++ b/src/main/java/kieker/gui/model/importer/filter/TraceReconstructor.java
@@ -32,11 +32,10 @@ import teetime.framework.AbstractConsumerStage;
 import teetime.framework.OutputPort;
 
 /**
- * Reconstruct traces based on the incoming instances of {@code IFlowRecord}. Currently only {@link TraceMetadata}, {@link BeforeOperationEvent} and
- * {@link AfterOperationEvent} instances are supported.
+ * Reconstruct traces based on the incoming instances of {@code IFlowRecord}. Currently only {@link TraceMetadata}, {@link BeforeOperationEvent} and {@link AfterOperationEvent} instances are supported.
  *
  * @author Nils Christian Ehmke
- */
+ */ 
 public final class TraceReconstructor extends AbstractConsumerStage<IFlowRecord> {
 
 	private final OutputPort<ExecutionEntry> outputPort = super.createOutputPort();
@@ -73,7 +72,7 @@ public final class TraceReconstructor extends AbstractConsumerStage<IFlowRecord>
 		return this.outputPort;
 	}
 
-	private static class TraceBuffer {
+	private final static class TraceBuffer {
 
 		private final String hostname;
 		private final Deque<BeforeOperationEvent> stack = new LinkedList<>();
@@ -95,12 +94,10 @@ public final class TraceReconstructor extends AbstractConsumerStage<IFlowRecord>
 		private void handleBeforeOperationEventRecord(final BeforeOperationEvent record) {
 			this.stack.push(record);
 
-			final ExecutionEntry newExecutionEntry;
+			final ExecutionEntry newExecutionEntry = new ExecutionEntry(record.getTraceId(), this.hostname, record.getClassSignature(), record.getOperationSignature());
 			if (this.root == null) {
-				newExecutionEntry = new ExecutionEntry(record.getTraceId(), this.hostname, record.getClassSignature(), record.getOperationSignature());
 				this.root = newExecutionEntry;
 			} else {
-				newExecutionEntry = new ExecutionEntry(record.getTraceId(), this.hostname, record.getClassSignature(), record.getOperationSignature());
 				this.header.addExecutionEntry(newExecutionEntry);
 			}
 			this.header = newExecutionEntry;
diff --git a/src/main/java/kieker/gui/view/MainWindow.java b/src/main/java/kieker/gui/view/MainWindow.java
index a185e78c..e3661f11 100644
--- a/src/main/java/kieker/gui/view/MainWindow.java
+++ b/src/main/java/kieker/gui/view/MainWindow.java
@@ -1,3 +1,19 @@
+/***************************************************************************
+ * Copyright 2014 Kieker Project (http://kieker-monitoring.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ***************************************************************************/
+
 package kieker.gui.view;
 
 import java.util.ArrayList;
@@ -47,6 +63,8 @@ import org.eclipse.swt.widgets.Widget;
 import org.eclipse.wb.swt.SWTResourceManager;
 
 /**
+ * The main window of this application. This file should probably be maintained with the Eclipse GUI builder.
+ * 
  * @author Nils Christian Ehmke
  */
 public class MainWindow {
-- 
GitLab