Package org.tweetyproject.web.services
Class Utils
java.lang.Object
org.tweetyproject.web.services.Utils
Utility class providing various helper methods for common operations.
This class includes methods for creating DungTheory from attack relations,
manipulating strings, handling timeouts, and converting time units.
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
checkUserTimeout
(int user_timeout, int server_timeout, TimeUnit unit) Checks and adjusts the user-defined timeout based on the server timeout and time unit.static DungTheory
getDungTheory
(int nr_of_arguments, List<List<Integer>> atttacks) Creates a DungTheory from the given number of arguments and attack relations.static TimeUnit
getTimoutUnit
(String unit) Gets the corresponding TimeUnit based on the provided string representation.static String
returnLowerCase
(String stringInput) Converts the input string to lowercase.static <T> javafx.util.Pair
<T, Long> runServicesWithTimeout
(Future<T> future, long timeout, TimeUnit unit) Runs a service with a specified timeout and returns the result along with the execution time.static String[]
splitStringInput
(String stringInput, String delimiter) Splits the input string using the specified delimiter.
-
Method Details
-
getDungTheory
Creates a DungTheory from the given number of arguments and attack relations.- Parameters:
nr_of_arguments
- The number of arguments in the DungTheory.atttacks
- The attack relations represented as a list of lists of integers.- Returns:
- A DungTheory constructed from the given arguments and attacks.
-
returnLowerCase
-
splitStringInput
Splits the input string using the specified delimiter.- Parameters:
stringInput
- The input string to be split.delimiter
- The delimiter used for splitting the string.- Returns:
- An array of strings resulting from the split operation.
-
getTimoutUnit
-
runServicesWithTimeout
public static <T> javafx.util.Pair<T,Long> runServicesWithTimeout(Future<T> future, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Runs a service with a specified timeout and returns the result along with the execution time.- Type Parameters:
T
- The type of the result.- Parameters:
future
- The Future representing the result of an asynchronous computation.timeout
- The timeout duration.unit
- The TimeUnit of the timeout.- Returns:
- A Pair containing the result and the execution time.
- Throws:
InterruptedException
- If the execution is interrupted.ExecutionException
- If the computation threw an exception.TimeoutException
- If the computation did not complete before the timeout.
-
checkUserTimeout
Checks and adjusts the user-defined timeout based on the server timeout and time unit.- Parameters:
user_timeout
- The user-defined timeout.server_timeout
- The server-defined timeout.unit
- The TimeUnit of the timeouts.- Returns:
- The adjusted user-defined timeout.
-