|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dspace.app.sitemap.AbstractGenerator
public abstract class AbstractGenerator
Base class for creating sitemaps of various kinds. A sitemap consists of one or more files which list significant URLs on a site for search engines to efficiently crawl. Dates of modification may also be included. A sitemap index file that links to each of the sitemap files is also generated. It is this index file that search engines should be directed towards.
Provides most of the required functionality, subclasses need just implement a few methods that specify the "boilerplate" and text for including URLs.
Typical usage:
AbstractGenerator g = new FooGenerator(...);
while (...) {
g.addURL(url, date);
}
g.finish();
| Field Summary | |
|---|---|
protected int |
bytesWritten
Number of bytes written to current file |
protected PrintStream |
currentOutput
Current output |
protected int |
fileCount
Number of files written so far |
protected File |
outputDir
Directory files are written to |
protected int |
urlsWritten
Number of URLs written to current file |
| Constructor Summary | |
|---|---|
AbstractGenerator(File outputDirIn)
Initialize this generator to write to the given directory. |
|
| Method Summary | |
|---|---|
void |
addURL(String url,
Date lastMod)
Add the given URL to the sitemap. |
protected void |
closeCurrentFile()
Finish with the current sitemap file. |
int |
finish()
Complete writing sitemap files and write the index files. |
abstract String |
getFilename(int number)
Return the filename a sitemap at the given index should be stored at. |
abstract String |
getIndexFilename()
Get the filename the index should be written to. |
abstract String |
getLeadingBoilerPlate()
Return the boilerplate at the top of a sitemap file. |
abstract int |
getMaxSize()
Return the maximum size in bytes that an individual sitemap file should be. |
abstract int |
getMaxURLs()
Return the maximum number of URLs that an individual sitemap file should contain. |
abstract String |
getTrailingBoilerPlate()
Return the boilerplate at the end of a sitemap file. |
abstract String |
getURLText(String url,
Date lastMod)
Return marked-up text to be included in a sitemap about a given URL. |
protected void |
startNewFile()
Start writing a new sitemap file. |
abstract boolean |
useCompression()
Return whether the written sitemap files and index should be GZIP-compressed. |
abstract void |
writeIndex(PrintStream output,
int sitemapCount)
Write the index file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int fileCount
protected int bytesWritten
protected int urlsWritten
protected File outputDir
protected PrintStream currentOutput
| Constructor Detail |
|---|
public AbstractGenerator(File outputDirIn)
outputDirIn - directory to write sitemap files to| Method Detail |
|---|
protected void startNewFile()
throws IOException
IOException - if an error occurs creating the file
public void addURL(String url,
Date lastMod)
throws IOException
url - Full URL to addlastMod - Date URL was last modified, or null
IOException - if an error occurs writing
protected void closeCurrentFile()
throws IOException
IOException - if an error occurs writing
public int finish()
throws IOException
addURL(String, Date) have
been completed, and invalidates the generator.
IOException - if an error occurs writing
public abstract String getURLText(String url,
Date lastMod)
url - URL to add information aboutlastMod - date URL was last modified, or null if unknown or not
applicable
public abstract String getLeadingBoilerPlate()
public abstract String getTrailingBoilerPlate()
public abstract int getMaxSize()
public abstract int getMaxURLs()
public abstract boolean useCompression()
true if GZIP compression should be used, false
otherwise.public abstract String getFilename(int number)
number - index of the sitemap file (zero is first).
public abstract String getIndexFilename()
public abstract void writeIndex(PrintStream output,
int sitemapCount)
throws IOException
output - stream to write the index tositemapCount - number of sitemaps that were generated
IOException - if an IO error occurs
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||