Class BasicPageUtils

    • Constructor Summary

      Constructors 
      Constructor Description
      BasicPageUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getAbsoluteUrl​(java.lang.String baseUrl, java.lang.String relativePath)
      Returns an absolute URL built from the passed base URL and relative path.
      static java.lang.String getAbsoluteUrl​(java.net.URL baseUrl, java.lang.String relativePath)
      Returns an absolute URL built from the passed base URL and relative path.
      static <T> T pickOneRandomly​(java.util.List<T> elements)
      Returns one entry from the passed list, chosen randomly.
      static <T> T pickOneRandomly​(java.util.List<T> elements, boolean excludeFirst)
      Returns one entry from the passed list, chosen randomly.
      static <T> T pickOneRandomly​(java.util.List<T> elements, boolean excludeFirst, boolean excludeLast)
      Returns one entry from the passed list, chosen randomly.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BasicPageUtils

        public BasicPageUtils()
    • Method Detail

      • getAbsoluteUrl

        public static java.lang.String getAbsoluteUrl​(java.lang.String baseUrl,
                                                      java.lang.String relativePath)
                                               throws java.net.MalformedURLException
        Returns an absolute URL built from the passed base URL and relative path.
        Parameters:
        baseUrl - the base URL as a string
        relativePath - the relative path
        Returns:
        the new absolute URL
        Throws:
        java.net.MalformedURLException - if the new URL is invalid
      • getAbsoluteUrl

        public static java.lang.String getAbsoluteUrl​(java.net.URL baseUrl,
                                                      java.lang.String relativePath)
                                               throws java.net.MalformedURLException
        Returns an absolute URL built from the passed base URL and relative path.
        Parameters:
        baseUrl - the base URL
        relativePath - the relative path
        Returns:
        the new absolute URL
        Throws:
        java.net.MalformedURLException - if the new URL is invalid
      • pickOneRandomly

        public static <T> T pickOneRandomly​(java.util.List<T> elements)
        Returns one entry from the passed list, chosen randomly.
        Type Parameters:
        T - the type of the elements in the list
        Parameters:
        elements - the list
        Returns:
        one element from the list
      • pickOneRandomly

        public static <T> T pickOneRandomly​(java.util.List<T> elements,
                                            boolean excludeFirst)
        Returns one entry from the passed list, chosen randomly. It can be specified whether or not the first entry is to be ignored.
        Type Parameters:
        T - the type of the elements in the list
        Parameters:
        elements - the list
        excludeFirst - whether or not the first entry is to be excluded
        Returns:
        one element from the list
      • pickOneRandomly

        public static <T> T pickOneRandomly​(java.util.List<T> elements,
                                            boolean excludeFirst,
                                            boolean excludeLast)
        Returns one entry from the passed list, chosen randomly. It can be specified whether or not the first and/or the last entries are to be ignored.
        Type Parameters:
        T - the type of the elements in the list
        Parameters:
        elements - the list
        excludeFirst - whether or not the first entry is to be excluded
        excludeLast - whether or not the last entry is to be excluded
        Returns:
        one element from the list