Class RouteUtils

java.lang.Object
com.creativityfactory.swiftserver.utils.RouteUtils

public class RouteUtils extends Object
This class is responsible for handling route operations, such as URL segmentation and pattern matching. It provides methods for parsing a URL and determining if it matches a specific pattern, as well as extracting variables from the URL for further processing.
  • Constructor Details

    • RouteUtils

      public RouteUtils()
  • Method Details

    • allSegment

      public static List<String> allSegment(String url)
      This method takes a URL string and returns a list of segments extracted from it by splitting it using the "/" delimiter. Each segment is a string.
      Parameters:
      url - The input URL string.
      Returns:
      The list of URL segments.
    • isUrlPatternMatched

      public static boolean isUrlPatternMatched(String pattern, String url)
      This method takes a URL pattern and a URL string and returns a boolean indicating whether the URL matches the given pattern or not. The pattern can contain placeholders (segments starting with ':') which match any segment of the URL.
      Parameters:
      pattern - The URL pattern to match against.
      url - The input URL string.
      Returns:
      A boolean indicating whether the URL matches the pattern.
    • extractParams

      public static Map<String,String> extractParams(String pattern, String url)
      This method takes a URL pattern and a URL string and returns a map of key-value pairs containing the values of the placeholder segments in the URL. The placeholders are identified by the ':' prefix.
      Parameters:
      pattern - The URL pattern to extract parameters from.
      url - The input URL string.
      Returns:
      A map of key-value pairs containing the values of the placeholder segments in the URL.
    • extractQueries

      public static Map<String,String> extractQueries(String queries)
      This method takes a string of queries and returns a map of key-value pairs containing the queries in the form of key-value pairs.
      Parameters:
      queries - The input string of queries.
      Returns:
      A map of key-value pairs containing the queries.