Replaces spaced indents with tab indents.

This commit is contained in:
Robert van der Spek 2018-07-17 10:20:39 +02:00
parent ab87227014
commit 3c852e4474
3 changed files with 57 additions and 57 deletions

View File

@ -60,7 +60,7 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
* or else write out one sitemap immediately.
* @param url the URL to add to this sitemap
* @return this
* @throws IOException when closing of streams has failed
* @throws IOException when closing of streams has failed
*/
public THIS addUrl(U url) throws IOException {
if (finished) throw new RuntimeException("Sitemap already printed; you must create a new generator to make more sitemaps");
@ -83,7 +83,7 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
* or write out one sitemap immediately.
* @param urls the URLs to add to this sitemap
* @return this
* @throws IOException when closing of streams has failed.
* @throws IOException when closing of streams has failed.
*/
public THIS addUrls(Iterable<? extends U> urls) throws IOException {
for (U url : urls) addUrl(url);
@ -95,7 +95,7 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
* or write out one sitemap immediately.
* @param urls the URLs to add to this sitemap
* @return this
* @throws IOException when closing of streams has failed.
* @throws IOException when closing of streams has failed.
*/
public THIS addUrls(U... urls) throws IOException {
for (U url : urls) addUrl(url);
@ -123,8 +123,8 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
U sitemapUrl;
try {
sitemapUrl = renderer.getUrlClass().getConstructor(String.class).newInstance(url);
return addUrl(sitemapUrl);
} catch (Exception e) {
return addUrl(sitemapUrl);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ -150,8 +150,8 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
U sitemapUrl;
try {
sitemapUrl = renderer.getUrlClass().getConstructor(URL.class).newInstance(url);
return addUrl(sitemapUrl);
} catch (Exception e) {
return addUrl(sitemapUrl);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ -169,10 +169,10 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
if (finished) throw new RuntimeException("Sitemap already printed; you must create a new generator to make more sitemaps");
if (!allowEmptySitemap && urls.isEmpty() && mapCount == 0) throw new RuntimeException("No URLs added, sitemap would be empty; you must add some URLs with addUrls");
try {
writeSiteMap();
} catch (IOException ex) {
throw new RuntimeException("Closing of streams has failed at some point.", ex);
}
writeSiteMap();
} catch (IOException ex) {
throw new RuntimeException("Closing of streams has failed at some point.", ex);
}
finished = true;
return outFiles;
}
@ -215,7 +215,7 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
/**
* After you've called {@link #write()}, call this to generate a sitemap index of all sitemaps you generated.
* The sitemap index is written to {baseDir}/sitemap_index.xml
* @throws IOException when closing of streams has failed
* @throws IOException when closing of streams has failed
*/
public File writeSitemapsWithIndex() throws IOException {
if (!finished) throw new RuntimeException("Sitemaps not generated yet; call write() first");
@ -227,7 +227,7 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
* After you've called {@link #write()}, call this to generate a sitemap index of all sitemaps you generated.
*
* @param outFile the destination file of the sitemap index.
* @throws IOException when closing of streams has failed
* @throws IOException when closing of streams has failed
*/
public File writeSitemapsWithIndex(File outFile) throws IOException {
if (!finished) throw new RuntimeException("Sitemaps not generated yet; call write() first");
@ -251,8 +251,8 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
File outFile = new File(baseDir, fileNamePrefix+fileNameSuffix);
outFiles.add(outFile);
OutputStreamWriter out = null;
try {
OutputStreamWriter out = null;
try {
if (gzip) {
FileOutputStream fileStream = new FileOutputStream(outFile);
GZIPOutputStream gzipStream = new GZIPOutputStream(fileStream);
@ -270,10 +270,10 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
} catch (SAXException e) {
throw new RuntimeException("Sitemap file failed to validate (bug?)", e);
} finally {
if(out != null) {
out.close();
}
}
if(out != null) {
out.close();
}
}
}
private void writeSiteMap(OutputStreamWriter out) throws IOException {

View File

@ -222,27 +222,27 @@ public class SitemapIndexGenerator {
/** Writes out the sitemap index */
public void write() {
if (!allowEmptyIndex && urls.isEmpty()) throw new RuntimeException("No URLs added, sitemap index would be empty; you must add some URLs with addUrls");
try {
FileWriter out = null;
try {
// TODO gzip? is that legal for a sitemap index?
out = new FileWriter(outFile);
writeSiteMap(out);
out.flush();
try {
FileWriter out = null;
try {
// TODO gzip? is that legal for a sitemap index?
out = new FileWriter(outFile);
writeSiteMap(out);
out.flush();
if (autoValidate) SitemapValidator.validateSitemapIndex(outFile);
} catch (IOException e) {
throw new RuntimeException("Problem writing sitemap index file " + outFile, e);
} catch (SAXException e) {
throw new RuntimeException("Problem validating sitemap index file (bug?)", e);
} finally {
if(out != null) {
out.close();
}
}
} catch (IOException ex) {
throw new RuntimeException("Closing of stream has failed.", ex);
}
if (autoValidate) SitemapValidator.validateSitemapIndex(outFile);
} catch (IOException e) {
throw new RuntimeException("Problem writing sitemap index file " + outFile, e);
} catch (SAXException e) {
throw new RuntimeException("Problem validating sitemap index file (bug?)", e);
} finally {
if(out != null) {
out.close();
}
}
} catch (IOException ex) {
throw new RuntimeException("Closing of stream has failed.", ex);
}
}

View File

@ -38,7 +38,7 @@ public class SitemapValidator {
private synchronized static void lazyLoad() {
if (sitemapSchema != null) return;
SchemaFactory factory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
try {
sitemapSchema = lazyLoad(factory, "sitemap.xsd");
sitemapIndexSchema = lazyLoad(factory, "siteindex.xsd");
@ -48,20 +48,20 @@ public class SitemapValidator {
}
private synchronized static Schema lazyLoad(SchemaFactory factory, String resource) throws IOException, SAXException {
InputStream stream = null;
InputStream stream = null;
try {
stream = SitemapValidator.class.getResourceAsStream(resource);
if (stream == null) throw new RuntimeException("BUG Couldn't load " + resource);
StreamSource source = new StreamSource(stream);
return factory.newSchema(source);
} finally {
if(stream != null) {
stream.close();
}
}
try {
stream = SitemapValidator.class.getResourceAsStream(resource);
if (stream == null) throw new RuntimeException("BUG Couldn't load " + resource);
StreamSource source = new StreamSource(stream);
return factory.newSchema(source);
} finally {
if(stream != null) {
stream.close();
}
}
}
}
/** Validates an ordinary web sitemap file (NOT a Google-specific sitemap) */
public static void validateWebSitemap(File sitemap) throws SAXException, IOException {
@ -77,7 +77,7 @@ public class SitemapValidator {
private static void validateXml(File sitemap, Schema schema) throws SAXException, IOException {
Validator validator = schema.newValidator();
FileReader reader = null;
FileReader reader = null;
try {
reader = new FileReader(sitemap);
SAXSource source = new SAXSource(new InputSource(reader));
@ -85,10 +85,10 @@ public class SitemapValidator {
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if(reader != null) {
reader.close();
}
}
if(reader != null) {
reader.close();
}
}
}
}