From 052ba408006efa55225a06b05facba3f3137ffae Mon Sep 17 00:00:00 2001 From: SIMAILA Djalim Date: Wed, 14 Dec 2022 14:17:51 +0100 Subject: [PATCH] finished documentation for classes ArchDistribution, Distribution and AsyncRequestParse --- .../distribution/ArchDistribution.java | 4 +-- .../distribution/Distribution.java | 29 +++++++++++------ .../parser/AsyncRequestsParser.java | 32 ++++++++++++------- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/main/java/fr/packageviewer/distribution/ArchDistribution.java b/src/main/java/fr/packageviewer/distribution/ArchDistribution.java index d42a1d0..118367d 100644 --- a/src/main/java/fr/packageviewer/distribution/ArchDistribution.java +++ b/src/main/java/fr/packageviewer/distribution/ArchDistribution.java @@ -25,8 +25,8 @@ import org.json.*; public class ArchDistribution extends AsyncRequestsParser implements Distribution { /** - * Logger object used to split debug output and the application output - */ + * Logger object used to split debug output and the application output + */ private static final Logger logger = LoggerManager.getLogger("ArchDistribution"); /** diff --git a/src/main/java/fr/packageviewer/distribution/Distribution.java b/src/main/java/fr/packageviewer/distribution/Distribution.java index 1850afb..255f000 100644 --- a/src/main/java/fr/packageviewer/distribution/Distribution.java +++ b/src/main/java/fr/packageviewer/distribution/Distribution.java @@ -10,18 +10,29 @@ import java.util.concurrent.Future; /** * This interface specifies the methods needed by a distribtion to be parsable. * - * @author R.Thomas - * @version 1.0 + * @author R.Thomas + * @version 1.0 */ public interface Distribution { /** - * Search for a package matching a pattern and return a list of packages and - * return a list of string matching this pattern. - * - * @param packageName String, the pattern to search in the repositories - * @return List of SearchedPackage objects - */ + * Search for a package matching a pattern and return a list of packages and + * return a list of string matching this pattern. + * + * @param packageName String, the pattern to search in the repositories + * @return List of SearchedPackage objects + */ Future> searchPackage(String packageName); - + + /** + * This function returns a fully completed package containing all + * information about the package identified by it's exact name passed as + * parametter, the package contains in its dependency list fully formed + * packages that also contains its dependencies, the dependency depth is + * specified by the parametter with the same name. + * + * @param packageName String, The package's exact name + * @param depth int, the depth of the dependency tree + * @return Package, the fully completed package + */ Future getPackageTree(String packageName, int depth); } diff --git a/src/main/java/fr/packageviewer/parser/AsyncRequestsParser.java b/src/main/java/fr/packageviewer/parser/AsyncRequestsParser.java index 722d973..de4defe 100644 --- a/src/main/java/fr/packageviewer/parser/AsyncRequestsParser.java +++ b/src/main/java/fr/packageviewer/parser/AsyncRequestsParser.java @@ -13,7 +13,7 @@ import java.util.logging.Logger; /** * This abstract class defines the method that a distribution will use - * in order to get a package and fill its dependency list. It does all that + * in order to get a package and fill its dependency list. It does all that * in an asyncron manner * * @author R.Thomas @@ -22,22 +22,30 @@ import java.util.logging.Logger; */ public abstract class AsyncRequestsParser { /** - * Logger object used to split debug output and the application output - */ + * Logger object used to split debug output and the application output + */ private static final Logger logger = LoggerManager.getLogger("AsyncRequestsParser"); /** - * This function return a package from the distribution's api in the form - * of a Pair Composed of a Package object, and a set of string containing + * This function returns a package from the distribution's api in the form + * of a Pair Composed of a Package object and a set of string containing * the names of the dependecies of the package. - * - * @param packageName String, The package's exact name - * @return Pair of Package and Set of String - */ + * + * @param packageName String, The package's exact name + * @return Pair of Package and Set of String + */ protected abstract CompletableFuture>> getPackageFromAPI(String name); /** + * This function returns a fully completed package containing all + * information about the package identified by it's exact name passed as + * parametter, the package contains in its dependency list fully formed + * packages that also contains its dependencies, the dependency depth is + * specified by the parametter with the same name. * + * @param packageName String, The package's exact name + * @param depth int, the depth of the dependency tree + * @return Package, the fully completed package */ public CompletableFuture getPackageTree(String packageName, int depth) { // parse the json @@ -53,7 +61,7 @@ public abstract class AsyncRequestsParser { return CompletableFuture.completedFuture(null); } futureRequest.thenAccept(result -> { - if(result==null){ + if (result == null) { logger.fine("Completing callback INVALID for package %s (depth=%s)".formatted(packageName, depth)); futurePackage.complete(null); return; @@ -61,7 +69,6 @@ public abstract class AsyncRequestsParser { Package pack = result.getFirst(); Set dependenciesNames = result.getSecond(); - // if we're at the maximum depth, return the package without its dependencies if (depth == 0) { logger.fine("Completing callback NODEP for package %s (depth=%s)".formatted(packageName, depth)); @@ -93,7 +100,8 @@ public abstract class AsyncRequestsParser { futurePackage.complete(pack); }).exceptionally(error -> { error.printStackTrace(); - logger.warning("Error while manipulating package %s (depth=%s) : \n%s".formatted(packageName, depth, error)); + logger.warning( + "Error while manipulating package %s (depth=%s) : \n%s".formatted(packageName, depth, error)); futurePackage.complete(null); return null; });