Class AbstractSitemapGenerator<T extends AbstractGenerator>

    • Constructor Detail

      • AbstractSitemapGenerator

        public AbstractSitemapGenerator​(String baseUrl)
    • Method Detail

      • toStringArray

        public abstract String[] toStringArray()
      • toString

        public String toString()
        Construct sitemap into String
        Overrides:
        toString in class Object
        Returns:
        sitemap
      • toString

        public T toString​(Consumer<String> stringConsumer)
        Construct sitemap into String which is consumed by supplied Consumer
        Parameters:
        stringConsumer - Consumer which consumes generated String
        Returns:
        this
      • toPrettyString

        public String toPrettyString​(int indent)
        Construct sitemap into prettified String
        Parameters:
        indent - Indentation
        Returns:
        sitemap
      • toPrettyString

        public T toPrettyString​(int indent,
                                Consumer<String> stringConsumer)
        Construct sitemap into prettified String which is consumed by supplied Consumer
        Parameters:
        indent - Indentation
        stringConsumer - Consumer which consumes generated String
        Returns:
        this
      • toGzipByteArray

        public byte[] toGzipByteArray()
        Construct sitemap into gzipped file
        Returns:
        byte array
      • toGzipByteArray

        public T toGzipByteArray​(Consumer<byte[]> byteArrayConsumer)
        Construct sitemap into gzipped byte array which is consumed by supplied Consumer
        Parameters:
        byteArrayConsumer - Consumer which consumes generated byte array
        Returns:
        this
      • toFile

        public T toFile​(File file)
                 throws IOException
        Construct and save sitemap to output file
        Parameters:
        file - Output file
        Returns:
        this
        Throws:
        IOException - when error
      • toFile

        public T toFile​(Supplier<File> fileSupplier)
                 throws IOException
        Construct and save sitemap to output file
        Parameters:
        fileSupplier - Supplier which supplies output file
        Returns:
        this
        Throws:
        IOException - when error
      • toFile

        public T toFile​(Path path)
                 throws IOException
        Construct and save sitemap to output file
        Parameters:
        path - Output file
        Returns:
        this
        Throws:
        IOException - when error
      • toFile

        public T toFile​(String first,
                        String... more)
                 throws IOException
        Construct and save sitemap to output file
        Parameters:
        first - The path string or initial part of the path string
        more - Additional strings to be joined to form the path string
        Returns:
        this
        Throws:
        IOException - when error
      • toFile

        public T toFile​(File parent,
                        String child)
                 throws IOException
        Construct and save sitemap to output file
        Parameters:
        parent - The parent abstract pathname
        child - The child pathname string
        Returns:
        this
        Throws:
        IOException - when error
      • ping

        public PingResponse ping​(Ping ping)
        Ping search engine(s) that sitemap has changed.
        Parameters:
        ping - Ping object
        Returns:
        true if operation succeeded. If ping.isThrowExceptionOnFailure() == false and operation doesn't succeed, returns false.
      • pingGoogle

        @Deprecated
        public void pingGoogle​(String sitemapUrl)
        Deprecated.
        Ping Google that sitemap has changed. Will call this URL: https://www.google.com/ping?sitemap=URL_Encoded_sitemapUrl
        Parameters:
        sitemapUrl - sitemap url
      • pingGoogle

        @Deprecated
        public boolean pingGoogle​(String sitemapUrl,
                                  boolean doNotThrowExceptionOnFailure)
        Deprecated.
        Ping Google that sitemap has changed. Will call this URL: https://www.google.com/ping?sitemap=URL_Encoded_sitemapUrl
        Parameters:
        sitemapUrl - sitemap url
        doNotThrowExceptionOnFailure - If this is true and it's not possible to ping google, this method won't throw any exception, but will return false.
        Returns:
        If operation succeeded
      • pingBing

        @Deprecated
        public void pingBing​(String sitemapUrl)
        Deprecated.
        Ping Bing that sitemap has changed. Will call this URL: https://www.bing.com/ping?sitemap=URL_Encoded_sitemapUrl
        Parameters:
        sitemapUrl - sitemap url
      • pingBing

        @Deprecated
        public boolean pingBing​(String sitemapUrl,
                                boolean doNotThrowExceptionOnFailure)
        Deprecated.
        Ping Bing that sitemap has changed. Will call this URL: https://www.bing.com/ping?sitemap=URL_Encoded_sitemapUrl
        Parameters:
        sitemapUrl - sitemap url
        doNotThrowExceptionOnFailure - If this is true and it's not possible to ping google, this method won't throw any exception, but will return false.
        Returns:
        If operation succeeded
      • pingGoogle

        @Deprecated
        public void pingGoogle()
        Deprecated.
        Ping Google that sitemap has changed. Sitemap must be on this location: baseUrl/sitemap.xml (for example http://www.javavids.com/sitemap.xml)
      • pingGoogle

        @Deprecated
        public boolean pingGoogle​(boolean doNotThrowExceptionOnFailure)
        Deprecated.
        Ping Google that sitemap has changed. Sitemap must be on this location: baseUrl/sitemap.xml (for example http://www.javavids.com/sitemap.xml)
        Parameters:
        doNotThrowExceptionOnFailure - If this is true and it's not possible to ping google, this method won't throw any exception, but will return false.
        Returns:
        If operation succeeded
      • pingBing

        @Deprecated
        public void pingBing()
        Deprecated.
        Ping Google that sitemap has changed. Sitemap must be on this location: baseUrl/sitemap.xml (for example http://www.javavids.com/sitemap.xml)
      • pingBing

        @Deprecated
        public boolean pingBing​(boolean doNotThrowExceptionOnFailure)
        Deprecated.
        Ping Bing that sitemap has changed. Sitemap must be on this location: baseUrl/sitemap.xml (for example http://www.javavids.com/sitemap.xml)
        Parameters:
        doNotThrowExceptionOnFailure - If this is true and it's not possible to ping google, this method won't throw any exception, but will return false.
        Returns:
        If operation succeeded
      • defaultDir

        public T defaultDir​(String dirName)
        Sets default prefix dir to name for all subsequent WebPages. Final name will be "dirName/name"
        Parameters:
        dirName - Dir name
        Returns:
        this
      • defaultDir

        public T defaultDir​(String... dirNames)
        Sets default prefix dirs to name for all subsequent WebPages. For dirs: ["a", "b", "c"], the final name will be "a/b/c/name"
        Parameters:
        dirNames - Dir names
        Returns:
        this
      • resetDefaultDir

        public T resetDefaultDir()
        Reset default dir value
        Returns:
        this
      • defaultExtension

        public T defaultExtension​(String extension)
        Sets default suffix extension for all subsequent WebPages. Final name will be "name.extension"
        Parameters:
        extension - Extension
        Returns:
        this
      • resetDefaultExtension

        public T resetDefaultExtension()
        Reset default extension value
        Returns:
        this
      • defaultPriorityMax

        public T defaultPriorityMax()
        Sets default priority for all subsequent WebPages to maximum (1.0)
        Returns:
        this
      • defaultPriority

        public T defaultPriority​(Double priority)
        Sets default priority for all subsequent WebPages
        Parameters:
        priority - Default priority
        Returns:
        this
      • resetDefaultPriority

        public T resetDefaultPriority()
        Reset default priority
        Returns:
        this
      • defaultChangeFreq

        public T defaultChangeFreq​(ChangeFreq changeFreq)
        Sets default changeFreq for all subsequent WebPages
        Parameters:
        changeFreq - ChangeFreq
        Returns:
        this
      • defaultChangeFreqAlways

        public T defaultChangeFreqAlways()
        Sets default changeFreq to ALWAYS for all subsequent WebPages
        Returns:
        this
      • defaultChangeFreqHourly

        public T defaultChangeFreqHourly()
        Sets default changeFreq to HOURLY for all subsequent WebPages
        Returns:
        this
      • defaultChangeFreqDaily

        public T defaultChangeFreqDaily()
        Sets default changeFreq to DAILY for all subsequent WebPages
        Returns:
        this
      • defaultChangeFreqWeekly

        public T defaultChangeFreqWeekly()
        Sets default changeFreq to WEEKLY for all subsequent WebPages
        Returns:
        this
      • defaultChangeFreqMonthly

        public T defaultChangeFreqMonthly()
        Sets default changeFreq to MONTHLY for all subsequent WebPages
        Returns:
        this
      • defaultChangeFreqYearly

        public T defaultChangeFreqYearly()
        Sets default changeFreq to YEARLY for all subsequent WebPages
        Returns:
        this
      • defaultChangeFreqNever

        public T defaultChangeFreqNever()
        Sets default changeFreq to NEVER for all subsequent WebPages
        Returns:
        this
      • resetDefaultChangeFreq

        public T resetDefaultChangeFreq()
        Reset default changeFreq
        Returns:
        this
      • defaultLastMod

        public T defaultLastMod​(Date lastMod)
        Sets default lastMod for all subsequent WebPages
        Parameters:
        lastMod - lastMod
        Returns:
        this
      • defaultLastMod

        public T defaultLastMod​(LocalDateTime lastMod)
        Sets default lastMod for all subsequent WebPages
        Parameters:
        lastMod - lastMod
        Returns:
        this
      • defaultLastModNow

        public T defaultLastModNow()
        Sets default lastMod = new Date() for all subsequent WebPages
        Returns:
        this
      • resetDefaultLastMod

        public T resetDefaultLastMod()
        Reset default lastMod
        Returns:
        this
      • setHttpClient

        public void setHttpClient​(HttpClient httpClient)
      • getAbsoluteUrl

        protected String getAbsoluteUrl​(String webPageName)
        Get absolute URL: If webPageName is null, return baseUrl. If webPageName is not null, check if webPageName is absolute (can be URL from CDN) or relative URL. If it's relative URL, prepend baseUrl and return result. This method escapes webPageName's special characters, thus it must not be called for ping Google / Bing functionality!
        Parameters:
        webPageName - WebPageName
        Returns:
        Correct URL
      • getAbsoluteUrl

        protected String getAbsoluteUrl​(String webPageName,
                                        boolean escapeSpecialCharacters)
        Get absolute URL: If webPageName is null, return baseUrl. If webPageName is not null, check if webPageName is absolute (can be URL from CDN) or relative URL. If it's relative URL, prepend baseUrl and return result
        Parameters:
        webPageName - WebPageName
        escapeSpecialCharacters - Escape special characters? Special characters must be escaped if the URL will be stored to sitemap. If this method is called for ping Google / Bing functionality, special characters must not be escaped.
        Returns:
        Correct URL