From 683529b21c3e72ea92d1a56e85c35c759b4ac071 Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 21 Mar 2020 14:29:29 +0100 Subject: [PATCH] Add javadoc on some methods --- src/serverP2P/ServerManagementUDP.java | 11 +++++++++-- src/tools/HostItem.java | 6 ++++++ src/tools/Logger.java | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/serverP2P/ServerManagementUDP.java b/src/serverP2P/ServerManagementUDP.java index e5f81db..fbc0795 100644 --- a/src/serverP2P/ServerManagementUDP.java +++ b/src/serverP2P/ServerManagementUDP.java @@ -84,7 +84,7 @@ public class ServerManagementUDP implements Runnable { Payload p = pd.getPayload(); switch (p.getRequestResponseCode()) { case LOAD_REQUEST: - loadRequestManagement(p, pd); + loadRequestManagement(pd); break; case LIST_REQUEST: listRequestManagement(pd); @@ -158,7 +158,11 @@ public class ServerManagementUDP implements Runnable { } } - public void loadRequestManagement(Payload p, ProtocolP2PPacketUDP pd){ + /** Respond to LOAD requests + * @param pd ProtocolP2PPacketUDP + */ + public void loadRequestManagement(ProtocolP2PPacketUDP pd){ + Payload p = pd.getPayload(); logger.writeUDP("Received LOAD_REQUEST", LogLevel.Action); assert p instanceof LoadRequest : "payload must be an instance of LoadRequest"; if (!(p instanceof LoadRequest)) { @@ -208,6 +212,9 @@ public class ServerManagementUDP implements Runnable { } } + /** Respond to LIST requests + * @param pd ProtocolP2PPacketUDP + */ public void listRequestManagement(ProtocolP2PPacketUDP pd) { logger.writeUDP("Received LIST_REQUEST", LogLevel.Action); try { diff --git a/src/tools/HostItem.java b/src/tools/HostItem.java index 76dcb2d..80b4f13 100644 --- a/src/tools/HostItem.java +++ b/src/tools/HostItem.java @@ -127,6 +127,9 @@ public class HostItem { return hostname.hashCode() ^ port; } + /** Get InetAddress associated to this HostItem. + * @return InetAddress + */ public InetAddress getInetAddress() { if (inetAddress == null) { try { @@ -139,6 +142,9 @@ public class HostItem { return inetAddress; } + /** Constructor from Socket. + * @param s socket + */ public HostItem(Socket s) { tcpSocket = s; inetAddress = s.getInetAddress(); diff --git a/src/tools/Logger.java b/src/tools/Logger.java index 4da4848..1fdb4ad 100644 --- a/src/tools/Logger.java +++ b/src/tools/Logger.java @@ -17,6 +17,9 @@ import java.sql.Timestamp; public class Logger { private Path logFile; + /** Constructor with logFile. + * @param logFile name of the file to store logs. + */ public Logger(String logFile) { assert logFile != null : "Logfile name is null"; this.logFile = Paths.get(logFile);