Class URLCollection

  • All Implemented Interfaces:
    java.lang.Iterable

    
    public class URLCollection
     implements Iterable<T>
                        

    Collection class designed for handling URLs

    Before a URL is added to the collection, it is wrapped in a URLString class. The iterator unwraps the URL before return.

    N.B. Designed for use by HTMLParser, so is not a full implementation - e.g. does not support remove()

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      boolean add(URL u) Adds the URL to the Collection, first wrapping it in the URLString class
      boolean addURL(String url, URL baseUrl) Convenience method for adding URLs to the collection.
      Iterator<URL> iterator()
      • Methods inherited from class java.lang.Iterable

        forEach, spliterator
      • Methods inherited from class java.lang.Object

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

      • URLCollection

        URLCollection(Collection<URLString> c)
        Creates a new URLCollection from an existing Collection
        Parameters:
        c - collection to start with (Must not be null)
    • Method Detail

      • add

         boolean add(URL u)

        Adds the URL to the Collection, first wrapping it in the URLString class

        Parameters:
        u - URL to add
      • addURL

         boolean addURL(String url, URL baseUrl)

        Convenience method for adding URLs to the collection. If the url parameter is null, empty or URL is malformed, nothing is done

        Parameters:
        url - String, may be null or empty
        baseUrl - base for url to add information, which might be missing in url