From 16c239f1c6a02e23350eef9d4b53bdbfaf207995 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 18 Jul 2024 14:34:18 +0200 Subject: [PATCH] Made Javadoc review. --- src/fr/devinsy/logar/app/ExtractOptions.java | 44 +++++++ src/fr/devinsy/logar/app/Logar.java | 29 ++++- src/fr/devinsy/logar/app/LogarUtils.java | 1 + src/fr/devinsy/logar/app/Stats.java | 3 + .../logar/app/anonymizer/Anonymizer.java | 1 + .../logar/app/anonymizer/Ipv4Generator.java | 9 ++ src/fr/devinsy/logar/app/log/Log.java | 119 ++++++++++++++++++ src/fr/devinsy/logar/app/log/LogFile.java | 4 + .../logar/app/log/parser/LineParser.java | 17 +++ src/fr/devinsy/logar/stats/Ip.java | 13 ++ src/fr/devinsy/logar/stats/IpUserAgent.java | 18 +++ src/fr/devinsy/logar/stats/IpUserAgents.java | 21 ++++ src/fr/devinsy/logar/stats/Ips.java | 6 + src/fr/devinsy/logar/stats/UserAgent.java | 24 ++++ .../devinsy/logar/stats/UserAgentStator.java | 47 +++++++ src/fr/devinsy/logar/stats/UserAgents.java | 12 ++ src/fr/devinsy/logar/util/Chrono.java | 2 + src/fr/devinsy/logar/util/Files.java | 5 + src/fr/devinsy/logar/util/LineIterator.java | 9 +- 19 files changed, 376 insertions(+), 8 deletions(-) diff --git a/src/fr/devinsy/logar/app/ExtractOptions.java b/src/fr/devinsy/logar/app/ExtractOptions.java index e96fb45..98246e0 100644 --- a/src/fr/devinsy/logar/app/ExtractOptions.java +++ b/src/fr/devinsy/logar/app/ExtractOptions.java @@ -41,41 +41,85 @@ public class ExtractOptions this.userAgent = OnOffOption.OFF; } + /** + * Gets the datetime. + * + * @return the datetime + */ public OnOffOption getDatetime() { return this.datetime; } + /** + * Gets the ip. + * + * @return the ip + */ public OnOffOption getIp() { return this.ip; } + /** + * Gets the user. + * + * @return the user + */ public OnOffOption getUser() { return this.user; } + /** + * Gets the user agent. + * + * @return the user agent + */ public OnOffOption getUserAgent() { return this.userAgent; } + /** + * Sets the datetime. + * + * @param datetime + * the new datetime + */ public void setDatetime(final OnOffOption datetime) { this.datetime = datetime; } + /** + * Sets the ip. + * + * @param ip + * the new ip + */ public void setIp(final OnOffOption ip) { this.ip = ip; } + /** + * Sets the user. + * + * @param user + * the new user + */ public void setUser(final OnOffOption user) { this.user = user; } + /** + * Sets the user agent. + * + * @param userAgent + * the new user agent + */ public void setUserAgent(final OnOffOption userAgent) { this.userAgent = userAgent; diff --git a/src/fr/devinsy/logar/app/Logar.java b/src/fr/devinsy/logar/app/Logar.java index e6e6438..fbb4110 100644 --- a/src/fr/devinsy/logar/app/Logar.java +++ b/src/fr/devinsy/logar/app/Logar.java @@ -67,6 +67,7 @@ public final class Logar * @param source * the source * @throws IOException + * Signals that an I/O exception has occurred. */ public static void anonymize(final File source) throws IOException { @@ -81,6 +82,7 @@ public final class Logar * @param mapFile * the map file * @throws IOException + * Signals that an I/O exception has occurred. */ public static void anonymize(final File source, final File mapFile) throws IOException { @@ -122,7 +124,10 @@ public final class Logar * the source * @param target * the target + * @param dry + * the dry * @throws IOException + * Signals that an I/O exception has occurred. */ public static void archive(final File source, final File target, final OnOffOption dry) throws IOException { @@ -131,11 +136,16 @@ public final class Logar } /** - * Test archive access files. + * Archive access files. * * @param source * the source + * @param target + * the target + * @param dry + * the dry * @throws IOException + * Signals that an I/O exception has occurred. */ public static void archiveAccessFiles(final File source, final File target, final OnOffOption dry) throws IOException { @@ -235,6 +245,8 @@ public final class Logar * the source * @param target * the target + * @param dry + * the dry * @throws IOException * Signals that an I/O exception has occurred. */ @@ -329,11 +341,12 @@ public final class Logar } /** - * Check access files. + * Check log file. * * @param file - * the source + * the file * @throws IOException + * Signals that an I/O exception has occurred. */ public static void checkLogFile(final File file) throws IOException { @@ -391,11 +404,12 @@ public final class Logar } /** - * Check. + * Check log files. * * @param source * the source * @throws IOException + * Signals that an I/O exception has occurred. */ public static void checkLogFiles(final File source) throws IOException { @@ -424,6 +438,7 @@ public final class Logar * @param source * the source * @throws IOException + * Signals that an I/O exception has occurred. */ public static void checkSort(final File source) throws IOException { @@ -499,6 +514,8 @@ public final class Logar * * @param source * the source + * @param options + * the options * @throws IOException * Signals that an I/O exception has occurred. */ @@ -640,7 +657,7 @@ public final class Logar } /** - * Stats user agents. + * Stat user agents. * * @param source * the source @@ -753,6 +770,7 @@ public final class Logar * @param source * the source * @throws IOException + * Signals that an I/O exception has occurred. */ public static void testConcate(final File source) throws IOException { @@ -770,6 +788,7 @@ public final class Logar * @param file * the file * @throws IOException + * Signals that an I/O exception has occurred. */ public static void testConcateFile(final File file) throws IOException { diff --git a/src/fr/devinsy/logar/app/LogarUtils.java b/src/fr/devinsy/logar/app/LogarUtils.java index b4ceb03..6f985f1 100644 --- a/src/fr/devinsy/logar/app/LogarUtils.java +++ b/src/fr/devinsy/logar/app/LogarUtils.java @@ -53,6 +53,7 @@ public final class LogarUtils * the file * @return the string * @throws IOException + * Signals that an I/O exception has occurred. */ public static String sha1sum(final File file) throws IOException { diff --git a/src/fr/devinsy/logar/app/Stats.java b/src/fr/devinsy/logar/app/Stats.java index eeb82f8..56a39a8 100644 --- a/src/fr/devinsy/logar/app/Stats.java +++ b/src/fr/devinsy/logar/app/Stats.java @@ -171,6 +171,9 @@ public final class Stats this.lineCount += 1; } + /** + * Inc success file count. + */ public void incSuccessFileCount() { this.successFileCount += 1; diff --git a/src/fr/devinsy/logar/app/anonymizer/Anonymizer.java b/src/fr/devinsy/logar/app/anonymizer/Anonymizer.java index 71e5e8a..e6dbc73 100644 --- a/src/fr/devinsy/logar/app/anonymizer/Anonymizer.java +++ b/src/fr/devinsy/logar/app/anonymizer/Anonymizer.java @@ -68,6 +68,7 @@ public final class Anonymizer * @param source * the source * @throws IOException + * Signals that an I/O exception has occurred. */ public void anonymize(final File source) throws IOException { diff --git a/src/fr/devinsy/logar/app/anonymizer/Ipv4Generator.java b/src/fr/devinsy/logar/app/anonymizer/Ipv4Generator.java index e7745e0..e3e6654 100644 --- a/src/fr/devinsy/logar/app/anonymizer/Ipv4Generator.java +++ b/src/fr/devinsy/logar/app/anonymizer/Ipv4Generator.java @@ -156,6 +156,15 @@ public final class Ipv4Generator return result; } + /** + * Gets the ipv 4 min value part. + * + * @param length + * the length + * @param column + * the column + * @return the ipv 4 min value part + */ public static int getIpv4MinValuePart(final int length, final int column) { int result; diff --git a/src/fr/devinsy/logar/app/log/Log.java b/src/fr/devinsy/logar/app/log/Log.java index e1572f1..201c537 100644 --- a/src/fr/devinsy/logar/app/log/Log.java +++ b/src/fr/devinsy/logar/app/log/Log.java @@ -74,6 +74,11 @@ public final class Log /** * Instantiates a new log. + * + * @param line + * the line + * @param datetime + * the datetime */ public Log(final String line, final LocalDateTime datetime) { @@ -109,61 +114,121 @@ public final class Log this.datetimeValue, this.level, this.message); } + /** + * Gets the body byte sent. + * + * @return the body byte sent + */ public String getBodyByteSent() { return this.bodyByteSent; } + /** + * Gets the datetime. + * + * @return the datetime + */ public LocalDateTime getDatetime() { return this.datetime; } + /** + * Gets the datetime value. + * + * @return the datetime value + */ public String getDatetimeValue() { return this.datetimeValue; } + /** + * Gets the ip. + * + * @return the ip + */ public String getIp() { return this.ip; } + /** + * Gets the level. + * + * @return the level + */ public String getLevel() { return this.level; } + /** + * Gets the line. + * + * @return the line + */ public String getLine() { return this.line; } + /** + * Gets the message. + * + * @return the message + */ public String getMessage() { return this.message; } + /** + * Gets the referer. + * + * @return the referer + */ public String getReferer() { return this.referer; } + /** + * Gets the request. + * + * @return the request + */ public String getRequest() { return this.request; } + /** + * Gets the status. + * + * @return the status + */ public String getStatus() { return this.status; } + /** + * Gets the user. + * + * @return the user + */ public String getUser() { return this.user; } + /** + * Gets the user agent. + * + * @return the user agent + */ public String getUserAgent() { return this.userAgent; @@ -185,46 +250,100 @@ public final class Log this.message = null; } + /** + * Sets the body byte sent. + * + * @param bodyByteSent + * the new body byte sent + */ public void setBodyByteSent(final String bodyByteSent) { this.bodyByteSent = bodyByteSent; } + /** + * Sets the datetime value. + * + * @param datetimeValue + * the new datetime value + */ public void setDatetimeValue(final String datetimeValue) { this.datetimeValue = datetimeValue; } + /** + * Sets the ip. + * + * @param ip + * the new ip + */ public void setIp(final String ip) { this.ip = ip; } + /** + * Sets the level. + * + * @param level + * the new level + */ public void setLevel(final String level) { this.level = level; } + /** + * Sets the message. + * + * @param message + * the new message + */ public void setMessage(final String message) { this.message = message; } + /** + * Sets the referer. + * + * @param referer + * the new referer + */ public void setReferer(final String referer) { this.referer = referer; } + /** + * Sets the request. + * + * @param request + * the new request + */ public void setRequest(final String request) { this.request = request; } + /** + * Sets the status. + * + * @param status + * the new status + */ public void setStatus(final String status) { this.status = status; } + /** + * Sets the user. + * + * @param user + * the new user + */ public void setUser(final String user) { this.user = user; diff --git a/src/fr/devinsy/logar/app/log/LogFile.java b/src/fr/devinsy/logar/app/log/LogFile.java index c6ab59a..31e4e3b 100644 --- a/src/fr/devinsy/logar/app/log/LogFile.java +++ b/src/fr/devinsy/logar/app/log/LogFile.java @@ -59,6 +59,7 @@ public final class LogFile * the file * @return the parser * @throws IOException + * Signals that an I/O exception has occurred. */ public static LineParser getParser(final File file) throws IOException { @@ -101,6 +102,7 @@ public final class LogFile * the file * @return the type * @throws IOException + * Signals that an I/O exception has occurred. */ public static String getType(final File file) throws IOException { @@ -187,6 +189,8 @@ public final class LogFile * @param file * the file * @return the string + * @throws IOException + * Signals that an I/O exception has occurred. */ private static String readFirstLine(final File file) throws IOException { diff --git a/src/fr/devinsy/logar/app/log/parser/LineParser.java b/src/fr/devinsy/logar/app/log/parser/LineParser.java index 1dd70ee..99262d5 100644 --- a/src/fr/devinsy/logar/app/log/parser/LineParser.java +++ b/src/fr/devinsy/logar/app/log/parser/LineParser.java @@ -26,9 +26,26 @@ import fr.devinsy.logar.app.log.LogType; */ public interface LineParser { + /** + * Gets the mime. + * + * @return the mime + */ String getMime(); + /** + * Gets the type. + * + * @return the type + */ LogType getType(); + /** + * Parses the. + * + * @param line + * the line + * @return the log + */ Log parse(String line); } diff --git a/src/fr/devinsy/logar/stats/Ip.java b/src/fr/devinsy/logar/stats/Ip.java index 455d6b5..e47e944 100644 --- a/src/fr/devinsy/logar/stats/Ip.java +++ b/src/fr/devinsy/logar/stats/Ip.java @@ -43,16 +43,29 @@ public final class Ip this.count = 0; } + /** + * Gets the count. + * + * @return the count + */ public long getCount() { return this.count; } + /** + * Gets the value. + * + * @return the value + */ public String getValue() { return this.value; } + /** + * Inc. + */ public void inc() { this.count += 1; diff --git a/src/fr/devinsy/logar/stats/IpUserAgent.java b/src/fr/devinsy/logar/stats/IpUserAgent.java index 40b4f2c..231221f 100644 --- a/src/fr/devinsy/logar/stats/IpUserAgent.java +++ b/src/fr/devinsy/logar/stats/IpUserAgent.java @@ -47,21 +47,39 @@ public final class IpUserAgent this.count = 0; } + /** + * Gets the count. + * + * @return the count + */ public long getCount() { return this.count; } + /** + * Gets the ip. + * + * @return the ip + */ public String getIp() { return this.ip; } + /** + * Gets the user agent. + * + * @return the user agent + */ public String getUserAgent() { return this.userAgent; } + /** + * Inc. + */ public void inc() { this.count += 1; diff --git a/src/fr/devinsy/logar/stats/IpUserAgents.java b/src/fr/devinsy/logar/stats/IpUserAgents.java index cc25d4b..3f03444 100644 --- a/src/fr/devinsy/logar/stats/IpUserAgents.java +++ b/src/fr/devinsy/logar/stats/IpUserAgents.java @@ -44,11 +44,21 @@ public final class IpUserAgents implements Iterable this.data = new HashMap(); } + /** + * Clear. + */ public void clear() { this.data.clear(); } + /** + * Count by user agent. + * + * @param userAgent + * the user agent + * @return the int + */ public int countByUserAgent(final String userAgent) { int result; @@ -106,6 +116,12 @@ public final class IpUserAgents implements Iterable return result; } + /** + * Put. + * + * @param ipUserAgent + * the ip user agent + */ public void put(final IpUserAgent ipUserAgent) { this.data.put(ipUserAgent.getIp() + ipUserAgent.getUserAgent(), ipUserAgent); @@ -131,6 +147,11 @@ public final class IpUserAgents implements Iterable stat.inc(); } + /** + * Size. + * + * @return the int + */ public int size() { int result; diff --git a/src/fr/devinsy/logar/stats/Ips.java b/src/fr/devinsy/logar/stats/Ips.java index 5b7ed3b..7c9176e 100644 --- a/src/fr/devinsy/logar/stats/Ips.java +++ b/src/fr/devinsy/logar/stats/Ips.java @@ -40,6 +40,12 @@ public final class Ips extends HashMap super(); } + /** + * Put. + * + * @param ip + * the ip + */ public void put(final String ip) { Ip stat = get(ip); diff --git a/src/fr/devinsy/logar/stats/UserAgent.java b/src/fr/devinsy/logar/stats/UserAgent.java index 35ac1d7..8f5e486 100644 --- a/src/fr/devinsy/logar/stats/UserAgent.java +++ b/src/fr/devinsy/logar/stats/UserAgent.java @@ -45,26 +45,50 @@ public final class UserAgent this.ipLinkCount = 0; } + /** + * Gets the count. + * + * @return the count + */ public long getCount() { return this.count; } + /** + * Gets the ip link count. + * + * @return the ip link count + */ public long getIpLinkCount() { return this.ipLinkCount; } + /** + * Gets the value. + * + * @return the value + */ public String getValue() { return this.value; } + /** + * Inc. + */ public void inc() { this.count += 1; } + /** + * Sets the ip link count. + * + * @param ipLinkCount + * the new ip link count + */ public void setIpLinkCount(final long ipLinkCount) { this.ipLinkCount = ipLinkCount; diff --git a/src/fr/devinsy/logar/stats/UserAgentStator.java b/src/fr/devinsy/logar/stats/UserAgentStator.java index 427fd62..31fc8fa 100644 --- a/src/fr/devinsy/logar/stats/UserAgentStator.java +++ b/src/fr/devinsy/logar/stats/UserAgentStator.java @@ -78,21 +78,41 @@ public final class UserAgentStator } } + /** + * Gets the ips. + * + * @return the ips + */ public Ips getIps() { return this.ips; } + /** + * Gets the ip user agents. + * + * @return the ip user agents + */ public IpUserAgents getIpUserAgents() { return this.ipUserAgents; } + /** + * Gets the log count. + * + * @return the log count + */ public long getLogCount() { return this.logCount; } + /** + * Gets the user agents. + * + * @return the user agents + */ public UserAgents getUserAgents() { return this.userAgents; @@ -114,6 +134,12 @@ public final class UserAgentStator this.ipUserAgents.put(log.getIp(), userAgent); } + /** + * Save ip list. + * + * @param target + * the target + */ public void saveIpList(final File target) { PrintWriter out = null; @@ -136,6 +162,12 @@ public final class UserAgentStator } } + /** + * Save ip user agent list. + * + * @param target + * the target + */ public void saveIpUserAgentList(final File target) { PrintWriter out = null; @@ -158,6 +190,12 @@ public final class UserAgentStator } } + /** + * Save user agent link count. + * + * @param target + * the target + */ public void saveUserAgentLinkCount(final File target) { PrintWriter out = null; @@ -179,6 +217,12 @@ public final class UserAgentStator } } + /** + * Save user agent list. + * + * @param target + * the target + */ public void saveUserAgentList(final File target) { PrintWriter out = null; @@ -201,6 +245,9 @@ public final class UserAgentStator } } + /** + * Shrink. + */ public void shrink() { String[] tokens = { "android", "apple", "chrome", "iphone", "linux", "mac", "mozilla", "opera", "safari", "thunderbird" }; diff --git a/src/fr/devinsy/logar/stats/UserAgents.java b/src/fr/devinsy/logar/stats/UserAgents.java index 32bf27e..e9052ae 100644 --- a/src/fr/devinsy/logar/stats/UserAgents.java +++ b/src/fr/devinsy/logar/stats/UserAgents.java @@ -40,6 +40,12 @@ public final class UserAgents extends HashMap super(); } + /** + * Put. + * + * @param userAgent + * the user agent + */ public void put(final String userAgent) { UserAgent stat = get(userAgent); @@ -52,6 +58,12 @@ public final class UserAgents extends HashMap stat.inc(); } + /** + * Put. + * + * @param userAgent + * the user agent + */ public void put(final UserAgent userAgent) { this.put(userAgent.getValue(), userAgent); diff --git a/src/fr/devinsy/logar/util/Chrono.java b/src/fr/devinsy/logar/util/Chrono.java index 068c8ed..3c7f23f 100644 --- a/src/fr/devinsy/logar/util/Chrono.java +++ b/src/fr/devinsy/logar/util/Chrono.java @@ -87,6 +87,8 @@ public class Chrono /** * Start. + * + * @return the chrono */ public Chrono start() { diff --git a/src/fr/devinsy/logar/util/Files.java b/src/fr/devinsy/logar/util/Files.java index fca5eb9..1ad9279 100644 --- a/src/fr/devinsy/logar/util/Files.java +++ b/src/fr/devinsy/logar/util/Files.java @@ -240,6 +240,11 @@ public class Files extends ArrayList return result; } + /** + * Sort by pathname. + * + * @return the files + */ public Files sortByPathname() { Files result; diff --git a/src/fr/devinsy/logar/util/LineIterator.java b/src/fr/devinsy/logar/util/LineIterator.java index c16a1d3..55d8ac8 100644 --- a/src/fr/devinsy/logar/util/LineIterator.java +++ b/src/fr/devinsy/logar/util/LineIterator.java @@ -78,6 +78,7 @@ public class LineIterator * * @return true, if successful * @throws IOException + * Signals that an I/O exception has occurred. */ public boolean hasNext() throws IOException { @@ -102,8 +103,9 @@ public class LineIterator /** * Next. * - * @return the http log + * @return the string * @throws IOException + * Signals that an I/O exception has occurred. */ public String next() throws IOException { @@ -119,9 +121,10 @@ public class LineIterator } /** - * Read next line. - * + * Sets the ready. + * * @throws IOException + * Signals that an I/O exception has occurred. */ private void setReady() throws IOException {