All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.redfin.sitemapgenerator.SitemapGeneratorBuilder Maven / Gradle / Ivy

The newest version!
package com.redfin.sitemapgenerator;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

/** A convenience class to let you configure options straightforwardly; don't instantiate by hand.
 * 
 * 

Instead, get one statically from a SitemapGenerator class. For example: WebSitemapGenerator g =
* WebSitemapGenerator.builder("http://example.com", myDir).gzip(true).autoValidate(true).build()

* * * @author Dan Fabulich * * @param */ //that weird thing with generics is so sub-classed objects will return themselves //It makes sense, I swear! http://madbean.com/2004/mb2004-3/ public class SitemapGeneratorBuilder> extends AbstractSitemapGeneratorOptions> { Class sitemapGeneratorClass; /**Configures the generator with a base URL and directory to write the sitemap files. * * @param baseUrl All URLs in the generated sitemap(s) should appear under this base URL * @param baseDir Sitemap files will be generated in this directory as either "sitemap.xml" or "sitemap1.xml" "sitemap2.xml" and so on. * @param sitemapGeneratorClass the class of the generator the builder will create */ public SitemapGeneratorBuilder(URL baseUrl, File baseDir, Class sitemapGeneratorClass) { super(baseUrl, baseDir); this.sitemapGeneratorClass = sitemapGeneratorClass; } /**Configures the generator with a base URL and directory to write the sitemap files. * * @param baseUrl All URLs in the generated sitemap(s) should appear under this base URL * @param baseDir Sitemap files will be generated in this directory as either "sitemap.xml" or "sitemap1.xml" "sitemap2.xml" and so on. * @param sitemapGeneratorClass the class of the generator the builder will create */ public SitemapGeneratorBuilder(String baseUrl, File baseDir, Class sitemapGeneratorClass) throws MalformedURLException { this(new URL(baseUrl), baseDir, sitemapGeneratorClass); } /** Constructs a sitemap generator configured with the options you specified */ public G build() { try { return sitemapGeneratorClass.getDeclaredConstructor(AbstractSitemapGeneratorOptions.class).newInstance(this); } catch (Exception e) { throw new RuntimeException(e); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy