com.redfin.sitemapgenerator
Class GoogleCodeSitemapGenerator

java.lang.Object
  extended by com.redfin.sitemapgenerator.GoogleCodeSitemapGenerator

public class GoogleCodeSitemapGenerator
extends java.lang.Object

Builds a code sitemap for Google Code Search. To configure options, use builder(URL, File)

Author:
Dan Fabulich
See Also:
Creating Code Search Sitemaps

Field Summary
static int MAX_URLS_PER_SITEMAP
          50000 URLs per sitemap maximum
 
Constructor Summary
GoogleCodeSitemapGenerator(java.lang.String baseUrl, java.io.File baseDir)
          Configures the generator with a base URL and directory to write the sitemap files.
GoogleCodeSitemapGenerator(java.net.URL baseUrl, java.io.File baseDir)
          Configures the generator with a base URL and directory to write the sitemap files.
 
Method Summary
 THIS addUrl(java.lang.String url)
          Add one URL of the appropriate type to this sitemap.
 THIS addUrl(U url)
          Add one URL of the appropriate type to this sitemap.
 THIS addUrl(java.net.URL url)
          Add one URL of the appropriate type to this sitemap.
 THIS addUrls(java.lang.Iterable<? extends U> urls)
          Add multiple URLs of the appropriate type to this sitemap, one at a time.
 THIS addUrls(java.lang.String... urls)
          Add multiple URLs of the appropriate type to this sitemap, one at a time.
 THIS addUrls(U... urls)
          Add multiple URLs of the appropriate type to this sitemap, one at a time.
 THIS addUrls(java.net.URL... urls)
          Add multiple URLs of the appropriate type to this sitemap, one at a time.
static SitemapGeneratorBuilder<GoogleCodeSitemapGenerator> builder(java.lang.String baseUrl, java.io.File baseDir)
          Configures a builder so you can specify sitemap generator options
static SitemapGeneratorBuilder<GoogleCodeSitemapGenerator> builder(java.net.URL baseUrl, java.io.File baseDir)
          Configures a builder so you can specify sitemap generator options
 java.util.List<java.io.File> write()
          Write out remaining URLs; this method can only be called once.
 void writeSitemapsWithIndex()
          After you've called write(), call this to generate a sitemap index of all sitemaps you generated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_URLS_PER_SITEMAP

public static final int MAX_URLS_PER_SITEMAP
50000 URLs per sitemap maximum

See Also:
Constant Field Values
Constructor Detail

GoogleCodeSitemapGenerator

public GoogleCodeSitemapGenerator(java.lang.String baseUrl,
                                  java.io.File baseDir)
                           throws java.net.MalformedURLException
Configures the generator with a base URL and directory to write the sitemap files.

Parameters:
baseUrl - All URLs in the generated sitemap(s) should appear under this base URL
baseDir - Sitemap files will be generated in this directory as either "sitemap.xml" or "sitemap1.xml" "sitemap2.xml" and so on.
Throws:
java.net.MalformedURLException

GoogleCodeSitemapGenerator

public GoogleCodeSitemapGenerator(java.net.URL baseUrl,
                                  java.io.File baseDir)
Configures the generator with a base URL and directory to write the sitemap files.

Parameters:
baseUrl - All URLs in the generated sitemap(s) should appear under this base URL
baseDir - Sitemap files will be generated in this directory as either "sitemap.xml" or "sitemap1.xml" "sitemap2.xml" and so on.
Method Detail

builder

public static SitemapGeneratorBuilder<GoogleCodeSitemapGenerator> builder(java.net.URL baseUrl,
                                                                          java.io.File baseDir)
Configures a builder so you can specify sitemap generator options

Parameters:
baseUrl - All URLs in the generated sitemap(s) should appear under this base URL
baseDir - Sitemap files will be generated in this directory as either "sitemap.xml" or "sitemap1.xml" "sitemap2.xml" and so on.
Returns:
a builder; call .build() on it to make a sitemap generator

builder

public static SitemapGeneratorBuilder<GoogleCodeSitemapGenerator> builder(java.lang.String baseUrl,
                                                                          java.io.File baseDir)
                                                                   throws java.net.MalformedURLException
Configures a builder so you can specify sitemap generator options

Parameters:
baseUrl - All URLs in the generated sitemap(s) should appear under this base URL
baseDir - Sitemap files will be generated in this directory as either "sitemap.xml" or "sitemap1.xml" "sitemap2.xml" and so on.
Returns:
a builder; call .build() on it to make a sitemap generator
Throws:
java.net.MalformedURLException

addUrl

public THIS addUrl(U url)
Add one URL of the appropriate type to this sitemap. If we have reached the maximum number of URLs, we'll throw an exception if allowMultipleSitemaps is false, or else write out one sitemap immediately.

Parameters:
url - the URL to add to this sitemap
Returns:
this

addUrls

public THIS addUrls(java.lang.Iterable<? extends U> urls)
Add multiple URLs of the appropriate type to this sitemap, one at a time. If we have reached the maximum number of URLs, we'll throw an exception if allowMultipleSitemaps is false, or write out one sitemap immediately.

Parameters:
urls - the URLs to add to this sitemap
Returns:
this

addUrls

public THIS addUrls(U... urls)
Add multiple URLs of the appropriate type to this sitemap, one at a time. If we have reached the maximum number of URLs, we'll throw an exception if allowMultipleSitemaps is false, or write out one sitemap immediately.

Parameters:
urls - the URLs to add to this sitemap
Returns:
this

addUrls

public THIS addUrls(java.lang.String... urls)
                                                                          throws java.net.MalformedURLException
Add multiple URLs of the appropriate type to this sitemap, one at a time. If we have reached the maximum number of URLs, we'll throw an exception if allowMultipleSitemaps is false, or write out one sitemap immediately.

Parameters:
urls - the URLs to add to this sitemap
Returns:
this
Throws:
java.net.MalformedURLException

addUrl

public THIS addUrl(java.lang.String url)
                                                                         throws java.net.MalformedURLException
Add one URL of the appropriate type to this sitemap. If we have reached the maximum number of URLs, we'll throw an exception if allowMultipleSitemaps is false, or else write out one sitemap immediately.

Parameters:
url - the URL to add to this sitemap
Returns:
this
Throws:
java.net.MalformedURLException

addUrls

public THIS addUrls(java.net.URL... urls)
Add multiple URLs of the appropriate type to this sitemap, one at a time. If we have reached the maximum number of URLs, we'll throw an exception if allowMultipleSitemaps is false, or write out one sitemap immediately.

Parameters:
urls - the URLs to add to this sitemap
Returns:
this

addUrl

public THIS addUrl(java.net.URL url)
Add one URL of the appropriate type to this sitemap. If we have reached the maximum number of URLs, we'll throw an exception if allowMultipleSitemaps is false, or write out one sitemap immediately.

Parameters:
url - the URL to add to this sitemap
Returns:
this

write

public java.util.List<java.io.File> write()
Write out remaining URLs; this method can only be called once. This is necessary so we can keep an accurate count for writeSitemapsWithIndex().

Returns:
a list of files we wrote out to disk

writeSitemapsWithIndex

public void writeSitemapsWithIndex()
After you've called write(), call this to generate a sitemap index of all sitemaps you generated.



Copyright © 2009. All Rights Reserved.