more PMD enhancements

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6576 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 15 years ago
parent 5d930c96f0
commit 82f57f79e5

@ -121,7 +121,7 @@ public class ConfigAppearance_p {
return prop;
}
if (post.containsKey("use_skin") && (post.get("use_skin", "")).equals("on")) {
changeSkin(sb, skinPath, url.substring(url.lastIndexOf("/"), url.length()));
changeSkin(sb, skinPath, url.substring(url.lastIndexOf('/'), url.length()));
}
}

@ -125,7 +125,7 @@ public class ConfigBasic {
String host = null;
if (header.containsKey(HeaderFramework.HOST)) {
host = header.get(HeaderFramework.HOST);
final int idx = host.indexOf(":");
final int idx = host.indexOf(':');
if (idx != -1) host = host.substring(0,idx);
} else {
host = Domains.myPublicLocalIP().getHostAddress();

@ -109,7 +109,7 @@ public class ConfigLanguage_p {
return prop;
}
try{
final File langFile = new File(langPath, url.substring(url.lastIndexOf("/"), url.length()));
final File langFile = new File(langPath, url.substring(url.lastIndexOf('/'), url.length()));
final BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(langFile)));
while (it.hasNext()) {
@ -121,7 +121,7 @@ public class ConfigLanguage_p {
return prop;
}
if(post.containsKey("use_lang") && (post.get("use_lang")).equals("on")){
translator.changeLang(env, langPath, url.substring(url.lastIndexOf("/"), url.length()));
translator.changeLang(env, langPath, url.substring(url.lastIndexOf('/'), url.length()));
}
}
}

@ -156,7 +156,7 @@ public class Crawler_p {
if (crawlingStartURL!= null && fullDomain) {
newcrawlingMustMatch = ".*" + crawlingStartURL.getHost() + ".*";
}
if (crawlingStart!= null && subPath && (pos = crawlingStart.lastIndexOf("/")) > 0) {
if (crawlingStart!= null && subPath && (pos = crawlingStart.lastIndexOf('/')) > 0) {
newcrawlingMustMatch = crawlingStart.substring(0, pos + 1) + ".*";
}

@ -40,7 +40,7 @@ public class opensearchdescription {
if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", "");
String thisaddress = header.get("Host", "localhost");
if (thisaddress.indexOf(":") == -1) thisaddress += ":" + serverCore.getPortNr(env.getConfig("port", "8080"));
if (thisaddress.indexOf(':') == -1) thisaddress += ":" + serverCore.getPortNr(env.getConfig("port", "8080"));
int compareyacy = 0;
if(post != null && post.get("compare_yacy", "false").equals("true"))

@ -192,7 +192,7 @@ public HashMap parseProps(String s) {
int p;
String z;
for (int i = 0; i < l.length; i++) {
p = l[i].indexOf("=");
p = l[i].indexOf('=');
if (p > 0) {
z = l[i].substring(p + 1).trim();
if (z.length() > 0 && z.charAt(0) == '"') z = z.substring(1);

@ -153,7 +153,7 @@ public final class transferRWI {
estring = it.next();
// check if RWI entry is well-formed
p = estring.indexOf("{");
p = estring.indexOf('{');
if ((p < 0) || (estring.indexOf("x=") < 0) || !(estring.indexOf("[B@") < 0)) {
blocked++;
continue;

@ -650,7 +650,7 @@ public class yacysearch {
// adding some additional properties needed for the rss feed
String hostName = header.get("Host", "localhost");
if (hostName.indexOf(":") == -1) hostName += ":" + serverCore.getPortNr(env.getConfig("port", "8080"));
if (hostName.indexOf(':') == -1) hostName += ":" + serverCore.getPortNr(env.getConfig("port", "8080"));
prop.put("searchBaseURL", "http://" + hostName + "/yacysearch.html");
prop.put("rssYacyImageURL", "http://" + hostName + "/env/grafics/yacy.gif");
}

@ -131,7 +131,7 @@ public final class robotsParser {
// parse sitemap
if (lineUpper.startsWith(ROBOTS_SITEMAP)) {
pos = line.indexOf(" ");
pos = line.indexOf(' ');
if (pos != -1) {
sitemap = line.substring(pos).trim();
}
@ -160,10 +160,10 @@ public final class robotsParser {
if (pos != -1) line = line.substring(0,pos).trim();
// getting out the robots name
pos = line.indexOf(" ");
pos = line.indexOf(' ');
if (pos != -1) {
final String userAgent = line.substring(pos).trim();
isRule4AllAgents |= userAgent.equals("*");
isRule4AllAgents |= userAgent.equals('*');
isRule4YaCyAgent |= userAgent.toLowerCase().indexOf("yacy") >=0;
isRule4YaCyAgent |= userAgent.toLowerCase().indexOf("yacybot") >=0;
if (isRule4YaCyAgent) rule4YaCyFound = true;
@ -175,7 +175,7 @@ public final class robotsParser {
if (lineUpper.startsWith(ROBOTS_CRAWL_DELAY)) {
inBlock = true;
if (isRule4YaCyAgent || isRule4AllAgents) {
pos = line.indexOf(" ");
pos = line.indexOf(' ');
if (pos != -1) {
try {
// the crawl delay can be a float number and means number of seconds
@ -202,7 +202,7 @@ public final class robotsParser {
if (line.endsWith("*")) line = line.substring(0,line.length()-1);
// parse the path
pos = line.indexOf(" ");
pos = line.indexOf(' ');
if (pos >= 0) {
// getting the path
String path = line.substring(pos).trim();

@ -405,8 +405,8 @@ public final class HTTPDFileHandler {
// the indexOf(".") is just a workaround because there from ConfigLanguage.html commes "de.lng" and
// from ConfigBasic.html comes just "de" in the "language" parameter
localeSelection = args.get("language", localeSelection);
if (localeSelection.indexOf(".") != -1)
localeSelection = localeSelection.substring(0, localeSelection.indexOf("."));
if (localeSelection.indexOf('.') != -1)
localeSelection = localeSelection.substring(0, localeSelection.indexOf('.'));
}
File targetFile = getLocalizedFile(path, localeSelection);
@ -655,7 +655,7 @@ public final class HTTPDFileHandler {
String key;
String value;
for (int i = 0; i < cgiHeader.length; i++) {
indexOfDelimiter = cgiHeader[i].indexOf(":");
indexOfDelimiter = cgiHeader[i].indexOf(':');
key = cgiHeader[i].substring(0, indexOfDelimiter).trim();
value = cgiHeader[i].substring(indexOfDelimiter + 1).trim();
conProp.setProperty(key, value);
@ -1110,7 +1110,7 @@ public final class HTTPDFileHandler {
private static final File rewriteClassFile(final File template) {
try {
String f = template.getCanonicalPath();
final int p = f.lastIndexOf(".");
final int p = f.lastIndexOf('.');
if (p < 0) return null;
f = f.substring(0, p) + ".class";
//System.out.println("constructed class path " + f);

@ -332,7 +332,7 @@ public final class HTTPDProxyHandler {
return;
}
if ((pos = host.indexOf(":")) < 0) {
if ((pos = host.indexOf(':')) < 0) {
port = 80;
} else {
port = Integer.parseInt(host.substring(pos + 1));
@ -451,7 +451,7 @@ public final class HTTPDProxyHandler {
final String httpVer = conProp.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER); // the ip from the connecting peer
int port, pos;
if ((pos = host.indexOf(":")) < 0) {
if ((pos = host.indexOf(':')) < 0) {
port = 80;
} else {
port = Integer.parseInt(host.substring(pos + 1));
@ -762,7 +762,7 @@ public final class HTTPDProxyHandler {
final String httpVer = conProp.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER);
int port, pos;
if ((pos = host.indexOf(":")) < 0) {
if ((pos = host.indexOf(':')) < 0) {
port = 80;
} else {
port = Integer.parseInt(host.substring(pos + 1));
@ -865,7 +865,7 @@ public final class HTTPDProxyHandler {
final String httpVer = conProp.getProperty(HeaderFramework.CONNECTION_PROP_HTTP_VER);
int port, pos;
if ((pos = host.indexOf(":")) < 0) {
if ((pos = host.indexOf(':')) < 0) {
port = 80;
} else {
port = Integer.parseInt(host.substring(pos + 1));
@ -1049,11 +1049,11 @@ public final class HTTPDProxyHandler {
private static String domain(final String host) {
String domain = host;
int pos = domain.lastIndexOf(".");
int pos = domain.lastIndexOf('.');
if (pos >= 0) {
// truncate from last part
domain = domain.substring(0, pos);
pos = domain.lastIndexOf(".");
pos = domain.lastIndexOf('.');
if (pos >= 0) {
// truncate from first part
domain = domain.substring(pos + 1);
@ -1224,7 +1224,7 @@ public final class HTTPDProxyHandler {
if (args != null) { path = path + "?" + args; }
int port, pos;
if ((pos = host.indexOf(":")) < 0) {
if ((pos = host.indexOf(':')) < 0) {
port = 80;
} else {
port = Integer.parseInt(host.substring(pos + 1));
@ -1503,7 +1503,7 @@ public final class HTTPDProxyHandler {
// getting some connection properties
String orgHostPort = "80";
String orgHostName = conProp.getProperty(HeaderFramework.CONNECTION_PROP_HOST,"unknown").toLowerCase();
int pos = orgHostName.indexOf(":");
int pos = orgHostName.indexOf(':');
if (pos != -1) {
orgHostPort = orgHostName.substring(pos+1);
orgHostName = orgHostName.substring(0,pos);
@ -1531,7 +1531,7 @@ public final class HTTPDProxyHandler {
if (addr != null) if (addr != null) testHostNames.add(testHostName);
}
pos = orgHostName.lastIndexOf(".");
pos = orgHostName.lastIndexOf('.');
if (pos != -1) {
final Iterator<String> iter = topLevelDomains.iterator();
while (iter.hasNext()) {
@ -1661,8 +1661,8 @@ public final class HTTPDProxyHandler {
if (conProp.containsKey(HeaderFramework.CONNECTION_PROP_PROXY_RESPOND_HEADER)) {
final HeaderFramework proxyRespondHeader = (HeaderFramework) conProp.get(HeaderFramework.CONNECTION_PROP_PROXY_RESPOND_HEADER);
mime = proxyRespondHeader.mime();
if (mime.indexOf(";") != -1) {
mime = mime.substring(0,mime.indexOf(";"));
if (mime.indexOf(';') != -1) {
mime = mime.substring(0,mime.indexOf(';'));
}
}
logMessage.append(mime);

@ -348,7 +348,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
final String host = this.prop.getProperty(HeaderFramework.CONNECTION_PROP_HOST);
if (host == null) return false;
int pos;
if ((pos = host.indexOf(":")) < 0) {
if ((pos = host.indexOf(':')) < 0) {
// default port 80
return false; // not allowed
}
@ -439,7 +439,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
int pos;
String unknownCommand = null, args = null;
if ((pos = requestLine.indexOf(" ")) > 0) {
if ((pos = requestLine.indexOf(' ')) > 0) {
unknownCommand = requestLine.substring(0,pos);
args = requestLine.substring(pos+1);
} else {
@ -660,7 +660,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
// this is to support https
// parse HTTP version
int pos = arg.indexOf(" ");
int pos = arg.indexOf(' ');
String httpVersion = "HTTP/1.0";
if (pos >= 0) {
httpVersion = arg.substring(pos + 1);
@ -670,7 +670,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
// parse hostname and port
prop.setProperty(HeaderFramework.CONNECTION_PROP_HOST, arg);
pos = arg.indexOf(":");
pos = arg.indexOf(':');
int port = 443;
if (pos >= 0) {
port = Integer.parseInt(arg.substring(pos + 1));
@ -773,8 +773,8 @@ public final class HTTPDemon implements serverHandler, Cloneable {
int argc = 0;
// Textfield1=default+value+Textfield+1&Textfield2=default+value+Textfield+2&selection1=sel1&selection2=othervalue1&selection2=sel2&selection3=sel3&Menu1=SubEnry11&radio1=button1&check1=button2&check1=button3&hidden1=&sButton1=enter+%281%29
while (argsString.length() > 0) {
eqp = argsString.indexOf("=");
sep = argsString.indexOf("&");
eqp = argsString.indexOf('=');
sep = argsString.indexOf('&');
if ((eqp <= 0) || (sep <= 0)) break;
// resulting equations are inserted into the property args with leading '&'
args.put(parseArg(argsString.substring(0, eqp)), parseArg(argsString.substring(eqp + 1, sep)));
@ -1127,7 +1127,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
final String method = conProp.getProperty(HeaderFramework.CONNECTION_PROP_METHOD);
int port = 80;
final int pos = host.indexOf(":");
final int pos = host.indexOf(':');
if (pos != -1) {
port = Integer.parseInt(host.substring(pos + 1));
host = host.substring(0, pos);
@ -1414,7 +1414,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
if ((path == null) || (path.length() == 0)) return true;
int pos;
if ((pos = path.lastIndexOf(".")) != -1) {
if ((pos = path.lastIndexOf('.')) != -1) {
return !disallowZippedContentEncoding.contains(path.substring(pos).toLowerCase());
}
return true;
@ -1477,7 +1477,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
if ((hostName == null) || (hostName.length() == 0)) return false;
try {
final int idx = hostName.indexOf(":");
final int idx = hostName.indexOf(':');
final String dstHost = (idx != -1) ? hostName.substring(0,idx).trim() : hostName.trim();
final Integer dstPort = (idx != -1) ? Integer.valueOf(hostName.substring(idx+1).trim()) : Integer.valueOf(80);

@ -468,7 +468,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
//String ip = conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP); // the ip from the connecting peer
int port, pos;
if ((pos = host.indexOf(":")) < 0) {
if ((pos = host.indexOf(':')) < 0) {
port = 80;
} else {
port = Integer.parseInt(host.substring(pos + 1));
@ -508,7 +508,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
String line;
while ((line = reader.readLine()) != null) {
if (line.length() == 0) break;
if ((p = line.indexOf(":")) >= 0) {
if ((p = line.indexOf(':')) >= 0) {
// store a property
add(line.substring(0, p).trim(), line.substring(p + 1).trim());
}

@ -67,7 +67,7 @@ public class natLib {
}
}
if (ip == null) return false;
if (ip.indexOf(":") >= 0) return false; // ipv6...
if (ip.indexOf(':') >= 0) return false; // ipv6...
return (isNotLocal(ip)) && (isIP(ip));
}

@ -130,7 +130,7 @@ public class RankingProfile {
for (int i = 0; i < elts.length; i++) {
e = elts[i].trim();
if ((s == 0) || (e.startsWith(prefix))) {
p = e.indexOf("=");
p = e.indexOf('=');
if (p < 0) System.out.println("DEBUG: bug in plasmaSearchRankingProfile: e = " + e);
if ((p > 0) && (e.length() > p + 1)) coeff.put(e.substring(s, p), Integer.valueOf(Integer.parseInt(e.substring(p + 1))));
}

@ -243,7 +243,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
public static int getPortNr(String extendedPortString) {
int pos = -1;
if ((pos = extendedPortString.indexOf(":"))!= -1) {
if ((pos = extendedPortString.indexOf(':'))!= -1) {
extendedPortString = extendedPortString.substring(pos+1);
}
return Integer.parseInt(extendedPortString);
@ -256,7 +256,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
int bindPort;
int pos = -1;
if ((pos = extendedPortString.indexOf(":"))!= -1) {
if ((pos = extendedPortString.indexOf(':'))!= -1) {
bindIP = extendedPortString.substring(0,pos).trim();
extendedPortString = extendedPortString.substring(pos+1);

@ -490,7 +490,7 @@ public class serverSwitch {
// read user name according to host addresses
final String a = authorization.get(host);
if (a == null) return null;
final int p = a.indexOf("@");
final int p = a.indexOf('@');
if (p < 0) return null;
return a.substring(0, p);
}
@ -499,7 +499,7 @@ public class serverSwitch {
// read access rigths according to host addresses
final String a = authorization.get(host);
if (a == null) return null;
final int p = a.indexOf("@");
final int p = a.indexOf('@');
if (p < 0) return null;
return a.substring(p + 1);
}

@ -608,7 +608,7 @@ public final class yacySeedDB implements AlternativeDomainNames {
badPeerHashes.add(seed.hash);
continue;
}
if ((pos = addressStr.indexOf(":"))!= -1) {
if ((pos = addressStr.indexOf(':'))!= -1) {
addressStr = addressStr.substring(0,pos);
}
seedIPAddress = InetAddress.getByName(addressStr);
@ -637,7 +637,7 @@ public final class yacySeedDB implements AlternativeDomainNames {
badPeerHashes.add(seed.hash);
continue;
}
if ((pos = addressStr.indexOf(":"))!= -1) {
if ((pos = addressStr.indexOf(':'))!= -1) {
addressStr = addressStr.substring(0,pos);
}
seedIPAddress = InetAddress.getByName(addressStr);
@ -660,7 +660,7 @@ public final class yacySeedDB implements AlternativeDomainNames {
try {
seed = e.next();
if ((seed != null) && ((addressStr = seed.getPublicAddress()) != null)) {
if ((pos = addressStr.indexOf(":"))!= -1) {
if ((pos = addressStr.indexOf(':'))!= -1) {
addressStr = addressStr.substring(0,pos);
}
seedIPAddress = InetAddress.getByName(addressStr);
@ -676,7 +676,7 @@ public final class yacySeedDB implements AlternativeDomainNames {
if (this.mySeed == null) return null;
addressStr = mySeed.getPublicAddress();
if (addressStr == null) return null;
if ((pos = addressStr.indexOf(":"))!= -1) {
if ((pos = addressStr.indexOf(':'))!= -1) {
addressStr = addressStr.substring(0,pos);
}
seedIPAddress = InetAddress.getByName(addressStr);
@ -837,7 +837,7 @@ public final class yacySeedDB implements AlternativeDomainNames {
if (host.endsWith(".yacyh")) {
// this is not functional at the moment
// caused by lowecasing of hashes at the browser client
p = host.indexOf(".");
p = host.indexOf('.');
if ((p > 0) && (p != (host.length() - 6))) {
subdom = host.substring(0, p);
host = host.substring(p + 1);
@ -860,7 +860,7 @@ public final class yacySeedDB implements AlternativeDomainNames {
return seed.getPublicAddress() + ((subdom == null) ? "" : ("/" + subdom));
} else if (host.endsWith(".yacy")) {
// identify subdomain
p = host.indexOf(".");
p = host.indexOf('.');
if ((p > 0) && (p != (host.length() - 5))) {
subdom = host.substring(0, p); // no double-dot attack possible, the subdom cannot have ".." in it
host = host.substring(p + 1); // if ever, the double-dots are here but do not harm

@ -70,7 +70,8 @@ public class HttpResponse {
* @throws IllegalArgumentException if some error occurs during parsing
*/
protected HttpResponse( String rawHttpResponse ) throws IllegalArgumentException {
if ( rawHttpResponse == null || rawHttpResponse.trim().length() == 0 ) {
rawHttpResponse = rawHttpResponse.trim();
if ( rawHttpResponse == null || rawHttpResponse.length() == 0 ) {
throw new IllegalArgumentException( "Empty HTTP response message" );
}
boolean bodyParsing = false;
@ -123,7 +124,7 @@ public class HttpResponse {
while (tokenizer.countTokens() > 0) {
String nextToken = tokenizer.nextToken().trim();
if ( nextToken.startsWith( elementName ) ) {
int index = nextToken.indexOf( "=" );
int index = nextToken.indexOf( '=' );
if ( index != -1 ) {
return nextToken.substring( index + 1 ).trim();
}

@ -376,9 +376,9 @@ dc_rights
if (u.startsWith("mailto:")) {
emaillinks.put(u.substring(7), entry.getValue());
} else {
extpos = u.lastIndexOf(".");
extpos = u.lastIndexOf('.');
if (extpos > 0) {
if (((qpos = u.indexOf("?")) >= 0) && (qpos > extpos)) {
if (((qpos = u.indexOf('?')) >= 0) && (qpos > extpos)) {
ext = u.substring(extpos + 1, qpos).toLowerCase();
} else {
ext = u.substring(extpos + 1).toLowerCase();

@ -935,7 +935,7 @@ public class DigestURI implements Serializable {
public final String language() {
String language = "en";
if (host == null) return language;
final int pos = host.lastIndexOf(".");
final int pos = host.lastIndexOf('.');
if (pos > 0 && host.length() - pos == 3) language = host.substring(pos + 1).toLowerCase();
if (language.equals("uk")) language = "en";
return language;

Loading…
Cancel
Save