added documentation for the newly added elements
This commit is contained in:
parent
68df90c73d
commit
d31969b8d0
@ -29,10 +29,20 @@ public class ArchDistribution extends AsyncRequestsParser implements Distributio
|
|||||||
*/
|
*/
|
||||||
private static final Logger logger = LoggerManager.getLogger("ArchDistribution");
|
private static final Logger logger = LoggerManager.getLogger("ArchDistribution");
|
||||||
|
|
||||||
private static String trimAfterCharacters(String str, String trimAfterCharacters){
|
/**
|
||||||
for(char c : trimAfterCharacters.toCharArray()){
|
* This method remove all characters in the first string passed as
|
||||||
|
* parametter after one of the character in the second string if found
|
||||||
|
* in the first string
|
||||||
|
*
|
||||||
|
* @param str String, the string to trim
|
||||||
|
* @param trimAfterCharacters String, the character that delimits our string
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String trimAfterCharacters(String str, String trimAfterCharacters) {
|
||||||
|
for (char c : trimAfterCharacters.toCharArray()) {
|
||||||
int index = str.indexOf(c);
|
int index = str.indexOf(c);
|
||||||
if(index>0)str = str.substring(index);
|
if (index > 0)
|
||||||
|
str = str.substring(index);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -69,8 +79,8 @@ public class ArchDistribution extends AsyncRequestsParser implements Distributio
|
|||||||
// get infos
|
// get infos
|
||||||
|
|
||||||
Set<String> dependenciesNames = new HashSet<>();
|
Set<String> dependenciesNames = new HashSet<>();
|
||||||
for(Object dependency : resultJson.getJSONArray("depends")){
|
for (Object dependency : resultJson.getJSONArray("depends")) {
|
||||||
dependenciesNames.add(trimAfterCharacters((String)dependency, "<>="));
|
dependenciesNames.add(trimAfterCharacters((String) dependency, "<>="));
|
||||||
}
|
}
|
||||||
futureResult.complete(new Pair<>(
|
futureResult.complete(new Pair<>(
|
||||||
new Package(
|
new Package(
|
||||||
@ -78,11 +88,9 @@ public class ArchDistribution extends AsyncRequestsParser implements Distributio
|
|||||||
resultJson.getString("pkgver"),
|
resultJson.getString("pkgver"),
|
||||||
resultJson.getString("repo"),
|
resultJson.getString("repo"),
|
||||||
resultJson.getString("pkgdesc"),
|
resultJson.getString("pkgdesc"),
|
||||||
"arch"
|
"arch"),
|
||||||
),
|
dependenciesNames));
|
||||||
dependenciesNames
|
}).exceptionally(error -> {
|
||||||
));
|
|
||||||
}).exceptionally(error ->{
|
|
||||||
error.printStackTrace();
|
error.printStackTrace();
|
||||||
logger.warning("Error while fetching package %s from the API : \n%s".formatted(packageName, error));
|
logger.warning("Error while fetching package %s from the API : \n%s".formatted(packageName, error));
|
||||||
futureResult.complete(null);
|
futureResult.complete(null);
|
||||||
@ -93,7 +101,6 @@ public class ArchDistribution extends AsyncRequestsParser implements Distributio
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for a package matching a pattern and return a list of packages and
|
* Search for a package matching a pattern and return a list of packages and
|
||||||
* return a list of string matching this pattern.
|
* return a list of string matching this pattern.
|
||||||
@ -120,12 +127,11 @@ public class ArchDistribution extends AsyncRequestsParser implements Distributio
|
|||||||
JSONObject searchResultJson = (JSONObject) searchResultObj;
|
JSONObject searchResultJson = (JSONObject) searchResultObj;
|
||||||
// add package into to list
|
// add package into to list
|
||||||
searchedPackagesList.add(new SearchedPackage(
|
searchedPackagesList.add(new SearchedPackage(
|
||||||
searchResultJson.getString("pkgname"),
|
searchResultJson.getString("pkgname"),
|
||||||
searchResultJson.getString("pkgver"),
|
searchResultJson.getString("pkgver"),
|
||||||
searchResultJson.getString("repo"),
|
searchResultJson.getString("repo"),
|
||||||
searchResultJson.getString("pkgdesc"),
|
searchResultJson.getString("pkgdesc"),
|
||||||
"arch"
|
"arch"));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
futureSearchedPackages.complete(searchedPackagesList);
|
futureSearchedPackages.complete(searchedPackagesList);
|
||||||
}).exceptionally(error -> {
|
}).exceptionally(error -> {
|
||||||
|
@ -38,28 +38,34 @@ public class Package extends SearchedPackage {
|
|||||||
* Second constructor for the Package class, allows to create a package
|
* Second constructor for the Package class, allows to create a package
|
||||||
* without supplying a list of dependencies.
|
* without supplying a list of dependencies.
|
||||||
*
|
*
|
||||||
* @param name String, name of the package
|
* @param name String, name of the package
|
||||||
* @param version String, version of the package
|
* @param version String, version of the package
|
||||||
* @param repo String, repository where the package is located
|
* @param repo String, repository where the package is located
|
||||||
* @param description String, description of the package
|
* @param description String, description of the package
|
||||||
|
* @param distribution String, the distribution where this specific package
|
||||||
|
* belongs
|
||||||
*/
|
*/
|
||||||
public Package(String name, String version, String repo, String description,String distribution) {
|
public Package(String name, String version, String repo, String description, String distribution) {
|
||||||
this(name, version, repo, description, distribution, new ArrayList<>());
|
this(name, version, repo, description, distribution, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main constructor for the Package class
|
* Main constructor for the Package class
|
||||||
*
|
*
|
||||||
* @param name String, name of the package
|
* @param name String, name of the package
|
||||||
* @param version String, version of the package
|
* @param version String, version of the package
|
||||||
* @param repo String, repository where the package is located
|
* @param repo String, repository where the package is located
|
||||||
* @param description String, description of the package
|
* @param description String, description of the package
|
||||||
* @param deps List of Package, dependencies of the package
|
* @param distribution String, the distribution where this specific package
|
||||||
|
* belongs
|
||||||
|
* @param deps List of Package, dependencies of the package
|
||||||
*/
|
*/
|
||||||
public Package(String name, String version, String repo, String description,String distribution, List<Package> deps) {
|
public Package(String name, String version, String repo, String description, String distribution,
|
||||||
|
List<Package> deps) {
|
||||||
super(name, version, repo, description, distribution);
|
super(name, version, repo, description, distribution);
|
||||||
this.deps = deps;
|
this.deps = deps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string reprensentation of the package
|
* Returns a string reprensentation of the package
|
||||||
*
|
*
|
||||||
|
@ -24,6 +24,9 @@ public class SearchedPackage {
|
|||||||
* Description of the package
|
* Description of the package
|
||||||
*/
|
*/
|
||||||
private final String description;
|
private final String description;
|
||||||
|
/**
|
||||||
|
* Distribution where this specific package belongs
|
||||||
|
*/
|
||||||
private final String distribution;
|
private final String distribution;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,7 +65,11 @@ public class SearchedPackage {
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the distribution attribute
|
||||||
|
*
|
||||||
|
* @return String, distribution where this specific package belongs
|
||||||
|
*/
|
||||||
public String getDistribution() {
|
public String getDistribution() {
|
||||||
return distribution;
|
return distribution;
|
||||||
}
|
}
|
||||||
@ -70,11 +77,12 @@ public class SearchedPackage {
|
|||||||
/**
|
/**
|
||||||
* Constructor for the SearchedPackage class
|
* Constructor for the SearchedPackage class
|
||||||
*
|
*
|
||||||
* @param name String, name of the package
|
* @param name String, name of the package
|
||||||
* @param version String, version of the package
|
* @param version String, version of the package
|
||||||
* @param repo String, repository where the package is located
|
* @param repo String, repository where the package is located
|
||||||
* @param description String, description of the package
|
* @param description String, description of the package
|
||||||
*
|
* @param distribution String, the distribution where this specific package
|
||||||
|
* belongs
|
||||||
*/
|
*/
|
||||||
public SearchedPackage(String name, String version, String repo, String description, String distribution) {
|
public SearchedPackage(String name, String version, String repo, String description, String distribution) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -91,6 +99,7 @@ public class SearchedPackage {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SearchedPackage{name=%s,version=%s,repo=%s,description=%s,distribution=%s}".formatted(name, version, repo, description, distribution);
|
return "SearchedPackage{name=%s,version=%s,repo=%s,description=%s,distribution=%s}".formatted(name, version,
|
||||||
|
repo, description, distribution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user