com.redfin.sitemapgenerator
Class SitemapIndexGenerator

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

public class SitemapIndexGenerator
extends java.lang.Object

Builds a sitemap index, which points only to other sitemaps.

Author:
Dan Fabulich

Nested Class Summary
static class SitemapIndexGenerator.Options
          Options to configure sitemap index generation
 
Field Summary
static int MAX_SITEMAPS_PER_INDEX
          Maximum 1,000 sitemaps per index allowed
 
Constructor Summary
SitemapIndexGenerator(java.lang.String baseUrl, java.io.File outFile)
          Configures the generator with a base URL and destination to write the sitemap index file.
SitemapIndexGenerator(java.net.URL baseUrl, java.io.File outFile)
          Configures the generator with a base URL and destination to write the sitemap index file.
 
Method Summary
 SitemapIndexGenerator addUrl(SitemapIndexUrl url)
          Adds a single sitemap to the index
 SitemapIndexGenerator addUrl(java.lang.String url)
          Adds a single sitemap to the index
 SitemapIndexGenerator addUrl(java.lang.String url, java.util.Date lastMod)
          Adds a single sitemap to the index
 SitemapIndexGenerator addUrl(java.net.URL url)
          Adds a single sitemap to the index
 SitemapIndexGenerator addUrl(java.net.URL url, java.util.Date lastMod)
          Adds a single sitemap to the index
 SitemapIndexGenerator addUrls(java.lang.Iterable<? extends SitemapIndexUrl> urls)
          Add multiple sitemaps to the index
 SitemapIndexGenerator addUrls(SitemapIndexUrl... urls)
          Add multiple sitemaps to the index
 SitemapIndexGenerator addUrls(java.lang.String... urls)
          Add multiple sitemaps to the index
 SitemapIndexGenerator addUrls(java.lang.String prefix, java.lang.String suffix, int count)
          Add a numbered list of sitemaps to the index, e.g.
 SitemapIndexGenerator addUrls(java.net.URL... urls)
          Add multiple sitemaps to the index
 void write()
          Writes out the sitemap index
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_SITEMAPS_PER_INDEX

public static final int MAX_SITEMAPS_PER_INDEX
Maximum 1,000 sitemaps per index allowed

See Also:
Constant Field Values
Constructor Detail

SitemapIndexGenerator

public SitemapIndexGenerator(java.net.URL baseUrl,
                             java.io.File outFile)
Configures the generator with a base URL and destination to write the sitemap index file.

Parameters:
baseUrl - All URLs in the generated sitemap(s) should appear under this base URL
outFile - The sitemap index will be written out at this location

SitemapIndexGenerator

public SitemapIndexGenerator(java.lang.String baseUrl,
                             java.io.File outFile)
                      throws java.net.MalformedURLException
Configures the generator with a base URL and destination to write the sitemap index file.

Parameters:
baseUrl - All URLs in the generated sitemap(s) should appear under this base URL
outFile - The sitemap index will be written out at this location
Throws:
java.net.MalformedURLException
Method Detail

addUrl

public SitemapIndexGenerator addUrl(SitemapIndexUrl url)
Adds a single sitemap to the index


addUrls

public SitemapIndexGenerator addUrls(java.lang.Iterable<? extends SitemapIndexUrl> urls)
Add multiple sitemaps to the index


addUrls

public SitemapIndexGenerator addUrls(SitemapIndexUrl... urls)
Add multiple sitemaps to the index


addUrls

public SitemapIndexGenerator addUrls(java.lang.String... urls)
                              throws java.net.MalformedURLException
Add multiple sitemaps to the index

Throws:
java.net.MalformedURLException

addUrl

public SitemapIndexGenerator addUrl(java.lang.String url)
                             throws java.net.MalformedURLException
Adds a single sitemap to the index

Throws:
java.net.MalformedURLException

addUrls

public SitemapIndexGenerator addUrls(java.net.URL... urls)
Add multiple sitemaps to the index


addUrl

public SitemapIndexGenerator addUrl(java.net.URL url)
Adds a single sitemap to the index


addUrl

public SitemapIndexGenerator addUrl(java.net.URL url,
                                    java.util.Date lastMod)
Adds a single sitemap to the index


addUrl

public SitemapIndexGenerator addUrl(java.lang.String url,
                                    java.util.Date lastMod)
                             throws java.net.MalformedURLException
Adds a single sitemap to the index

Throws:
java.net.MalformedURLException

addUrls

public SitemapIndexGenerator addUrls(java.lang.String prefix,
                                     java.lang.String suffix,
                                     int count)
Add a numbered list of sitemaps to the index, e.g. "sitemap1.xml" "sitemap2.xml" "sitemap3.xml" etc.

Parameters:
prefix - the first part of the filename e.g. "sitemap"
suffix - the last part of the filename e.g. ".xml" or ".xml.gz"
count - the number of sitemaps (1-based)

write

public void write()
Writes out the sitemap index



Copyright © 2009. All Rights Reserved.