summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-25 05:04:07 +0000
committerPaul Buetow <paul@buetow.org>2008-05-25 05:04:07 +0000
commit62fe28f0b0b0c9ebde18a6dc33907889ff3aa21b (patch)
tree7e473f28a7b80494539aabeb6d04e83eb3090a77
parent067fb8bcf8a2d7689d356a591f8e074e6c4840b1 (diff)
initial javadoc.
-rw-r--r--sources/core/VSMessage.java67
-rw-r--r--sources/core/time/VSLamportTime.java23
-rw-r--r--sources/core/time/VSTime.java10
-rw-r--r--sources/core/time/VSVectorTime.java1
4 files changed, 100 insertions, 1 deletions
diff --git a/sources/core/VSMessage.java b/sources/core/VSMessage.java
index 8ecba27..05c9e6a 100644
--- a/sources/core/VSMessage.java
+++ b/sources/core/VSMessage.java
@@ -4,20 +4,45 @@ import core.time.*;
import events.*;
import prefs.VSPrefs;
+/** This class represents a message which is send from one process to another process in the simulation.
+ */
public class VSMessage extends VSPrefs {
+ /** Each message belongs to a specific protocol. This variable defined the class name of the protocol being used.
+ */
private String protocolClassname;
+ /** The default application preferences.
+ */
private VSPrefs prefs;
+ /** A reference to the process who sent this message.
+ */
private VSProcess sendingProcess;
+ /** The vector time of the sending process after sending. The receiver process will use this vector time in order to update the local vector time.
+ */
private VSVectorTime vectorTime;
+ /** The lamport time of the sending process after sending. The receiver process will use this lamport time in order to update the local vector time.
+ */
private long lamportTime;
+ /** Each message has its own unique ID. The ID will show up in the logging window of the simulator as well.
+ */
private long messageID;
+ /** This counter is used in order to generate unique message ID's.
+ */
private static long messageCounter;
+ /** The constructor of the message.
+ *
+ * @param protocolClassname The classname of the protocol this message
+ * belongs to.
+ */
public VSMessage(String protocolClassname) {
this.protocolClassname = protocolClassname;
this.messageID = ++messageCounter;
}
+ /** Initialized the message.
+ *
+ * @param process The sending process of this message.
+ */
public void init(VSProcess process) {
this.sendingProcess = process;
this.prefs = process.getPrefs();
@@ -25,30 +50,59 @@ public class VSMessage extends VSPrefs {
vectorTime = sendingProcess.getVectorTime().getCopy();
}
+ /**
+ * Getter method.
+ *
+ * @return The protocol name of the message.
+ */
public String getName() {
return VSRegisteredEvents.getName(getProtocolClassname());
}
+ /** Getter method.
+ *
+ * @return The protocol classname of the message.
+ */
public String getProtocolClassname() {
return protocolClassname;
}
+ /** Getter method.
+ *
+ * @return The ID of the message.
+ */
public long getMessageID() {
return messageID;
}
+ /** Getter method.
+ *
+ * @return The process which sent this message.
+ */
public VSProcess getSendingProcess() {
return sendingProcess;
}
+ /** Getter method.
+ *
+ * @return The lamport time of the sending process.
+ */
public long getLamportTime() {
return lamportTime;
}
+ /** Getter method.
+ *
+ * @return The vector time of the sending process.
+ */
public VSVectorTime getVectorTime() {
return vectorTime;
}
+ /** String representation of the message object.
+ *
+ * @return String representation of the message object.
+ */
public String toString() {
StringBuffer buffer = new StringBuffer();
@@ -62,14 +116,27 @@ public class VSMessage extends VSPrefs {
return buffer.toString();
}
+ /** Extended string representation of the message object.
+ *
+ * @return Extended string representation of the message object.
+ */
public String toStringFull() {
return toString() + "; " + super.toString();
}
+ /** Compares two messages.
+ *
+ * @param message The message to compare with.
+ * @return true, if the messages have the same ID. Otherwise false.
+ */
public boolean equals(VSMessage message) {
return messageID == message.getMessageID();
}
+ /** For logging in the simulator's logging window!
+ *
+ * @param message The message to logg.
+ */
public void logg(String message) { }
}
diff --git a/sources/core/time/VSLamportTime.java b/sources/core/time/VSLamportTime.java
index 704b3d5..592507a 100644
--- a/sources/core/time/VSLamportTime.java
+++ b/sources/core/time/VSLamportTime.java
@@ -1,22 +1,45 @@
package core.time;
+/** This class defined how the lamport timestamps are represented.
+ */
public class VSLamportTime implements VSTime {
+ /** Specified the global time of the lamport timestamp. It's used for correct painting in the simulator paint area.
+ */
private long globalTime;
+ /** Specified the process' local lamport time.
+ */
private long lamportTime;
+ /** A simple constructor.
+ *
+ * @param globalTime The global time.
+ * @param lamportTime The local lamport time.
+ */
public VSLamportTime(long globalTime, long lamportTime) {
this.globalTime = globalTime;
this.lamportTime = lamportTime;
}
+ /** Getter method.
+ *
+ * @return The global time.
+ */
public long getGlobalTime() {
return globalTime;
}
+ /** Getter method.
+ *
+ * @return The process' local lamport time.
+ */
public long getLamportTime() {
return lamportTime;
}
+ /** String representation.
+ *
+ * @return The string representation of the lamport time.
+ */
public String toString() {
return "(" + lamportTime + ")";
}
diff --git a/sources/core/time/VSTime.java b/sources/core/time/VSTime.java
index efeda52..ce20ecc 100644
--- a/sources/core/time/VSTime.java
+++ b/sources/core/time/VSTime.java
@@ -1,6 +1,16 @@
package core.time;
+/** This interface is a guidline for general time format classes.
+ */
public interface VSTime {
+ /** Getter method.
+ *
+ * @return The global time.
+ */
public long getGlobalTime();
+ /** String representation.
+ *
+ * @return The representation of the implementing object as a string.
+ */
public String toString();
}
diff --git a/sources/core/time/VSVectorTime.java b/sources/core/time/VSVectorTime.java
index 7d0f371..eb6c0aa 100644
--- a/sources/core/time/VSVectorTime.java
+++ b/sources/core/time/VSVectorTime.java
@@ -3,7 +3,6 @@ package core.time;
import java.util.ArrayList;
public class VSVectorTime extends ArrayList<Long> implements VSTime {
- /* Only needed for painting in the painting panel */
private long globalTime;
public VSVectorTime(long globalTime) {