1
0
mirror of https://github.com/crawler-commons/crawler-commons synced 2024-09-24 09:40:41 +02:00

issue 27 : [SiteMap] Unnecessary String concatenations when logging + in SiteMapURL.toString()

This commit is contained in:
digitalpebble 2013-05-24 14:09:26 +00:00
parent 1042aa4436
commit 40ef1f5a10
3 changed files with 40 additions and 13 deletions

View File

@ -1,5 +1,8 @@
Crawler-Commons Change Log
TRUNK
- Issue 27: [SiteMap] Unnecessary String concatenations when logging + in SiteMapURL.toString() (jnioche)
Release 0.2
- Move to pure Maven for CC build lifecycle (lewismc)
- Move Javadoc out of core code (lewismc)

View File

@ -148,7 +148,11 @@ public class SiteMapParser {
boolean valid = urlIsLegal(textSiteMap.getBaseUrl(), url.toString());
if (valid || !strict) {
LOG.debug(" " + i + ". " + url);
if (LOG.isDebugEnabled()){
StringBuffer sb = new StringBuffer(" ");
sb.append(i).append(". ").append(url);
LOG.debug(sb.toString());
}
i++;
SiteMapURL surl = new SiteMapURL(url, valid);
textSiteMap.addSiteMapUrl(surl);
@ -267,7 +271,11 @@ public class SiteMapParser {
if (valid || !strict) {
SiteMapURL sUrl = new SiteMapURL(url.toString(), lastMod, changeFreq, priority, valid);
sitemap.addSiteMapUrl(sUrl);
LOG.trace(" " + (i + 1) + ". " + sUrl);
if (LOG.isDebugEnabled()){
StringBuffer sb = new StringBuffer(" ");
sb.append(i + 1).append(". ").append(sUrl);
LOG.debug(sb.toString());
}
}
} catch (MalformedURLException e) {
// e.printStackTrace();
@ -324,7 +332,11 @@ public class SiteMapParser {
SiteMap s = new SiteMap(sitemapUrl, lastModified);
sitemapIndex.addSitemap(s);
LOG.debug(" " + (i + 1) + ". " + s);
if (LOG.isDebugEnabled()){
StringBuffer sb = new StringBuffer(" ");
sb.append(i + 1).append(". ").append(s);
LOG.debug(sb.toString());
}
} catch (MalformedURLException e) {
// e.printStackTrace();
@ -427,7 +439,11 @@ public class SiteMapParser {
if (valid || !strict) {
SiteMapURL sUrl = new SiteMapURL(url.toString(), lastMod, null, null, valid);
sitemap.addSiteMapUrl(sUrl);
LOG.debug(" " + (i + 1) + ". " + sUrl);
if (LOG.isDebugEnabled()){
StringBuffer sb = new StringBuffer(" ");
sb.append(i + 1).append(". ").append(sUrl);
LOG.debug(sb.toString());
}
}
} catch (MalformedURLException e) {
// Can't create an entry with a bad URL
@ -506,7 +522,11 @@ public class SiteMapParser {
if (valid || !strict) {
SiteMapURL sUrl = new SiteMapURL(url.toString(), lastMod, null, null, valid);
sitemap.addSiteMapUrl(sUrl);
LOG.debug(" " + (i + 1) + ". " + sUrl);
if (LOG.isDebugEnabled()){
StringBuffer sb = new StringBuffer(" ");
sb.append(i + 1).append(". ").append(sUrl);
LOG.debug(sb.toString());
}
}
} catch (MalformedURLException e) {
// Can't create an entry with a bad URL
@ -574,8 +594,12 @@ public class SiteMapParser {
String u = testUrl.substring(0, sitemapBaseUrl.length()).toLowerCase();
ret = sitemapBaseUrl.equals(u);
}
LOG.trace("urlIsLegal: " + sitemapBaseUrl + " <= " + testUrl + " ? " + ret);
if (LOG.isTraceEnabled()){
StringBuffer sb = new StringBuffer("urlIsLegal: ");
sb.append(sitemapBaseUrl).append(" <= ").append(testUrl);
sb.append(" ? ").append(ret);
LOG.trace(sb.toString());
}
return ret;
}

View File

@ -237,12 +237,12 @@ public class SiteMapURL {
}
public String toString() {
String s = "url=\"" + url + "\",";
s += "lastMod=";
s += (lastModified == null) ? "null" : SiteMap.getFullDateFormat().format(lastModified);
s += ",changeFreq=" + changeFreq;
s += ",priority=" + priority;
return s;
StringBuilder sb = new StringBuilder();
sb.append("url=\"").append(url).append("\",");
sb.append("lastMod=").append((lastModified == null) ? "null" : SiteMap.getFullDateFormat().format(lastModified));
sb.append(",changeFreq=").append(changeFreq);
sb.append(",priority=").append(priority);
return sb.toString();
}
}