replaced more size() > 0 by !isEmpty()

This commit is contained in:
orbiter 2012-07-12 11:12:21 +02:00
parent 0cbda0b2b8
commit bbfa497a3c
15 changed files with 27 additions and 19 deletions

View File

@ -72,7 +72,7 @@ public class CrawlStartScanner_p
if ( hosts.isEmpty() ) {
InetAddress ip;
if ( sb.isIntranetMode() ) {
if ( ips.size() > 0 ) {
if ( !ips.isEmpty() ) {
ip = ips.iterator().next();
} else {
ip = Domains.dnsResolve("192.168.0.1");

View File

@ -127,7 +127,7 @@ public class IndexImportOAIPMH_p {
// start jobs for the sources
DigestURI url = null;
while (sourceList.size() > 0) {
while (!sourceList.isEmpty()) {
final String oaipmhurl = sourceList.remove(r.nextInt(sourceList.size()));
try {
url = new DigestURI(oaipmhurl);

View File

@ -72,7 +72,7 @@ public class Status
post.remove("noforward");
}
if ( post != null && post.size() > 0 ) {
if ( post != null && !post.isEmpty() ) {
if ( sb.adminAuthenticated(header) < 2 ) {
prop.authenticationRequired();
return prop;

View File

@ -174,7 +174,7 @@ public class Table_API_p {
final Map<String, Integer> l = sb.tables.execAPICalls(Domains.LOCALHOST, (int) sb.getConfigLong("port", 8090), sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""), pks);
// construct result table
prop.put("showexec", l.size() > 0 ? 1 : 0);
prop.put("showexec", l.isEmpty() ? 0 : 1);
final Iterator<Map.Entry<String, Integer>> resultIterator = l.entrySet().iterator();
Map.Entry<String, Integer> record;

View File

@ -293,7 +293,7 @@ public class yacysearchtrailer {
// vocabulary navigators
final Map<String, ScoreMap<String>> vocabularyNavigators = theSearch.getVocabularyNavigators();
if (vocabularyNavigators != null && vocabularyNavigators.size() > 0) {
if (vocabularyNavigators != null && !vocabularyNavigators.isEmpty()) {
int navvoccount = 0;
vocnav: for (Map.Entry<String, ScoreMap<String>> ve: vocabularyNavigators.entrySet()) {
String navname = ve.getKey();

View File

@ -504,7 +504,7 @@ public class Balancer {
// best case would be, if we have some zeroWaitingCandidates,
// then we select that one with the largest stack
if (zeroWaitingCandidates.size() > 0) {
if (!zeroWaitingCandidates.isEmpty()) {
int largestStack = -1;
String largestStackHost = null;
byte[] largestStackHash = null;
@ -550,7 +550,7 @@ public class Balancer {
break;
}
count++;
if (this.domainStacks.size() > 0 && count > 120 * this.domainStacks.size()) break;
if (!this.domainStacks.isEmpty() && count > 120 * this.domainStacks.size()) break;
}
Log.logInfo("BALANCER", "re-fill of domain stacks; fileIndex.size() = " + this.urlFileIndex.size() + ", domainStacks.size = " + this.domainStacks.size() + ", collection time = " + (System.currentTimeMillis() - this.lastDomainStackFill) + " ms");
this.domStackInitSize = this.domainStacks.size();

View File

@ -343,7 +343,7 @@ public final class CrawlStacker {
}
long maxFileSize = Long.MAX_VALUE;
if (entry.size() > 0) {
if (!entry.isEmpty()) {
final String protocol = entry.url().getProtocol();
if (protocol.equals("http") || protocol.equals("https")) maxFileSize = Switchboard.getSwitchboard().getConfigLong("crawler.http.maxFileSize", HTTPLoader.DEFAULT_MAXFILESIZE);
if (protocol.equals("ftp")) maxFileSize = Switchboard.getSwitchboard().getConfigLong("crawler.ftp.maxFileSize", FTPLoader.DEFAULT_MAXFILESIZE);

View File

@ -275,6 +275,10 @@ public class Request extends WorkflowJob
return this.size;
}
public boolean isEmpty() {
return this.size == 0;
}
public String name() {
// return the anchor name (text inside <a> tag)
return this.name;

View File

@ -175,7 +175,7 @@ public class Response {
this.requestHeader = new RequestHeader();
this.responseHeader = new ResponseHeader(200);
this.responseHeader.put(HeaderFramework.CONTENT_TYPE, "text/plain"); // tell parser how to handle the content
if (request.size() > 0) this.responseHeader.put(HeaderFramework.CONTENT_LENGTH, Long.toString(request.size()));
if (!request.isEmpty()) this.responseHeader.put(HeaderFramework.CONTENT_LENGTH, Long.toString(request.size()));
this.profile = profile;
this.status = QUEUE_STATE_FRESH;
this.content = request.name().length() > 0 ? request.name().getBytes() : request.url().toTokens().getBytes();

View File

@ -259,10 +259,10 @@ public class BookmarksDB {
*/
public void putTag(final Tag tag){
if (tag == null) return;
if (tag.size() > 0) {
this.tags.put(tag.getTagHash(), tag);
} else {
if (tag.isEmpty()) {
this.tags.remove(tag.getTagHash());
} else {
this.tags.put(tag.getTagHash(), tag);
}
}
@ -461,6 +461,10 @@ public class BookmarksDB {
public int size(){
return this.urlHashes.size();
}
public boolean isEmpty() {
return this.urlHashes.isEmpty();
}
}
/**

View File

@ -559,7 +559,7 @@ public final class HTTPDFileHandler {
// track all files that had been accessed so far
if (targetFile != null && targetFile.exists()) {
if (args != null && args.size() > 0) sb.setConfig("server.servlets.submitted", appendPath(sb.getConfig("server.servlets.submitted", ""), path));
if (args != null && !args.isEmpty()) sb.setConfig("server.servlets.submitted", appendPath(sb.getConfig("server.servlets.submitted", ""), path));
}
//File targetClass = rewriteClassFile(targetFile);

View File

@ -59,7 +59,7 @@ public class SchwarzerPeter {
List<Karte> stapel0 = new ArrayList<Karte>();
for (Karte karte: alleKarten) stapel0.add(karte);
List<Karte> stapel1 = new ArrayList<Karte>();
while (stapel0.size() > 0) stapel1.add(stapel0.remove(r.nextInt(stapel0.size())));
while (!stapel0.isEmpty()) stapel1.add(stapel0.remove(r.nextInt(stapel0.size())));
return stapel1;
}
@ -161,7 +161,7 @@ return true;
this.haende = new Hand[spieler.spieleranzahl];
for (int i = 0; i < spieler.spieleranzahl; i++) this.haende[i] = new Hand(Strategy.nichtsortieren_linksziehen);
List<Karte> geben = neuerStapel(r);
while (geben.size() > 0) {
while (!geben.isEmpty()) {
this.haende[spieler.spielernummer].annehmen(r, geben.remove(0));
spieler = spieler.nextRole();
}

View File

@ -83,7 +83,7 @@ public class mmParser extends AbstractParser implements Parser {
final List<String> nodeTextList = freeMindHandler.getNodeText();
rootElementText = (nodeTextList.size() > 0) ? nodeTextList.get(0) : "";
rootElementText = nodeTextList.isEmpty() ? "" : nodeTextList.get(0);
for (final String nodeText : nodeTextList) {
sb.append(nodeText);

View File

@ -125,11 +125,11 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
final long t = System.currentTimeMillis();
if ((IndexCell.this.ram.size() >= IndexCell.this.maxRamEntries ||
(IndexCell.this.ram.size() > 3000 && !MemoryControl.request(80L * 1024L * 1024L, false)) ||
(IndexCell.this.ram.size() > 0 && IndexCell.this.lastDump + dumpCycle < t))) {
(!IndexCell.this.ram.isEmpty() && IndexCell.this.lastDump + dumpCycle < t))) {
synchronized (IndexCell.this.merger) {
if (IndexCell.this.ram.size() >= IndexCell.this.maxRamEntries ||
(IndexCell.this.ram.size() > 3000 && !MemoryControl.request(80L * 1024L * 1024L, false)) ||
(IndexCell.this.ram.size() > 0 && IndexCell.this.lastDump + dumpCycle < t)) try {
(!IndexCell.this.ram.isEmpty() && IndexCell.this.lastDump + dumpCycle < t)) try {
IndexCell.this.lastDump = System.currentTimeMillis();
// removed delayed
try {removeDelayed();} catch (final IOException e) {}

View File

@ -108,7 +108,7 @@ public class SolrConfiguration extends ConfigurationSet implements Serializable
}
protected void addSolr(final SolrDoc solrdoc, final SolrField key, final List<String> value) {
if ((isEmpty() || contains(key.name())) && (!this.lazy || (value != null && value.size() > 0))) solrdoc.addSolr(key, value);
if ((isEmpty() || contains(key.name())) && (!this.lazy || (value != null && !value.isEmpty()))) solrdoc.addSolr(key, value);
}
protected void addSolr(final SolrDoc solrdoc, final SolrField key, final int value) {