diff --git a/htroot/TransNews_p.java b/htroot/TransNews_p.java index a4e9e1e71..596e99084 100644 --- a/htroot/TransNews_p.java +++ b/htroot/TransNews_p.java @@ -56,9 +56,8 @@ public class TransNews_p { prop.put("errmsg", 1); // msg: activate diff lng prop.put("transsize", 0); return prop; - } else { - prop.put("errmsg", 0); } + prop.put("errmsg", 0); TranslationManager transMgr = new TranslationManager(); File locallangFile = transMgr.getScratchFile(new File(currentlang + ".lng")); diff --git a/htroot/Translator_p.java b/htroot/Translator_p.java index b6779cee6..e8af97b26 100644 --- a/htroot/Translator_p.java +++ b/htroot/Translator_p.java @@ -44,9 +44,8 @@ public class Translator_p { if ("default".equals(langcfg) || "browser".equals(langcfg)) { prop.put("errmsg", 1); // msg: activate diff lng return prop; - } else { - prop.put("errmsg", 0); } + prop.put("errmsg", 0); final File localesFolder = sb.getAppPath("locale.source", "locales"); File lngfile = new File(localesFolder, langcfg + ".lng"); diff --git a/source/net/yacy/cora/protocol/RequestHeader.java b/source/net/yacy/cora/protocol/RequestHeader.java index 88f238198..5a5160fcd 100644 --- a/source/net/yacy/cora/protocol/RequestHeader.java +++ b/source/net/yacy/cora/protocol/RequestHeader.java @@ -161,9 +161,8 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest String cookiestring = this.get(COOKIE); // get from legacy or HttpServletRequest if (cookiestring == null) { return ""; - } else { - return cookiestring; } + return cookiestring; } // implementation of HttpServletRequest procedures @@ -214,11 +213,10 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public String mime() { if (super.containsKey(HeaderFramework.CONTENT_TYPE)) { return super.mime(); - } else { - if (_request != null) { - return _request.getContentType(); - } } + if (_request != null) { + return _request.getContentType(); + } return "application/octet-stream"; } @@ -234,15 +232,14 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public Cookie[] getCookies() { if (_request != null) { return _request.getCookies(); - } else { - String cstr = super.get(COOKIE); - if (cstr != null) { - CookieCutter cc = new CookieCutter(); // reuse jetty cookie parser - cc.addCookieField(cstr); - return cc.getCookies(); - } - return null; } + String cstr = super.get(COOKIE); + if (cstr != null) { + CookieCutter cc = new CookieCutter(); // reuse jetty cookie parser + cc.addCookieField(cstr); + return cc.getCookies(); + } + return null; } @Override @@ -250,12 +247,11 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest Date d = super.headerDate(name); if (d != null) { return d.getTime(); - } else { - if (_request != null) { - return _request.getDateHeader(name); - } - return -1; } + if (_request != null) { + return _request.getDateHeader(name); + } + return -1; } @Override @@ -298,9 +294,8 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public String getMethod() { if (_request != null) { return _request.getMethod(); - } else { - return HeaderFramework.METHOD_POST; } + return HeaderFramework.METHOD_POST; } @Override @@ -317,146 +312,130 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public String getPathTranslated() { if (_request != null) { return _request.getPathTranslated(); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getContextPath() { if (_request != null) { return _request.getContextPath(); - } else { - return ""; } + return ""; } @Override public String getQueryString() { if (_request != null) { return _request.getQueryString(); - } else { - return null; } + return null; } @Override public String getRemoteUser() { if (_request != null) return _request.getRemoteUser(); - else - return null; + return null; } @Override public boolean isUserInRole(String role) { if (_request != null) { return _request.isUserInRole(role); - } else { - return false; } + return false; } @Override public Principal getUserPrincipal() { if (_request != null) { return _request.getUserPrincipal(); - } else { - return null; } + return null; } @Override public String getRequestedSessionId() { if (_request != null) { return _request.getRequestedSessionId(); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getRequestURI() { if (_request != null) { return _request.getRequestURI(); - } else { - return super.get(HeaderFramework.CONNECTION_PROP_PATH, "/"); // TODO: property as header discouraged (but currently used) } + return super.get(HeaderFramework.CONNECTION_PROP_PATH, "/"); // TODO: property as header discouraged (but currently used) } @Override public StringBuffer getRequestURL() { if (_request != null) { return _request.getRequestURL(); - } else { - StringBuffer sbuf = new StringBuffer(32); - URIUtil.appendSchemeHostPort(sbuf, this.getScheme(), this.getServerName(), this.getServerPort()); - sbuf.append(this.getRequestURI()); - return sbuf; } + StringBuffer sbuf = new StringBuffer(32); + URIUtil.appendSchemeHostPort(sbuf, this.getScheme(), this.getServerName(), this.getServerPort()); + sbuf.append(this.getRequestURI()); + return sbuf; } @Override public String getServletPath() { if (_request != null) { return _request.getServletPath(); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public HttpSession getSession(boolean create) { if (_request != null) { return _request.getSession(create); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public HttpSession getSession() { if (_request != null) { return _request.getSession(); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public String changeSessionId() { if (_request != null) { return _request.changeSessionId(); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public boolean isRequestedSessionIdValid() { if (_request != null) { return _request.isRequestedSessionIdValid(); - } else { - return false; } + return false; } @Override public boolean isRequestedSessionIdFromCookie() { if (_request != null) { return _request.isRequestedSessionIdFromCookie(); - } else { - return false; } + return false; } @Override public boolean isRequestedSessionIdFromURL() { if (_request != null) { return _request.isRequestedSessionIdFromURL(); - } else { - return false; } + return false; } @Deprecated // As of Version 2.1 of the Java Servlet API, use isRequestedSessionIdFromURL() instead. @@ -464,18 +443,16 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public boolean isRequestedSessionIdFromUrl() { if (_request != null) { return _request.isRequestedSessionIdFromUrl(); - } else { - return false; } + return false; } @Override public boolean authenticate(HttpServletResponse response) throws IOException, ServletException { if (_request != null) { return _request.authenticate(response); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override @@ -526,18 +503,16 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public Object getAttribute(String name) { if (_request != null) { return _request.getAttribute(name); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public Enumeration getAttributeNames() { if (_request != null) { return _request.getAttributeNames(); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override @@ -579,11 +554,10 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public String getContentType() { if (super.containsKey(HeaderFramework.CONTENT_TYPE)) { return super.mime(); - } else { - if (_request != null) { - return _request.getContentType(); - } } + if (_request != null) { + return _request.getContentType(); + } return null; } @@ -591,45 +565,40 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public ServletInputStream getInputStream() throws IOException { if (_request != null) { return _request.getInputStream(); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getParameter(String name) { if (_request != null) { return _request.getParameter(name); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public Enumeration getParameterNames() { if (_request != null) { return _request.getParameterNames(); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public String[] getParameterValues(String name) { if (_request != null) { return _request.getParameterValues(name); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override public Map getParameterMap() { if (_request != null) { return _request.getParameterMap(); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override @@ -637,9 +606,8 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest // here we can directly check original request, as protocol is not expected to be modified if (_request != null) { return _request.getProtocol(); - } else { - return super.get(HeaderFramework.CONNECTION_PROP_HTTP_VER, HeaderFramework.HTTP_VERSION_1_1); } + return super.get(HeaderFramework.CONNECTION_PROP_HTTP_VER, HeaderFramework.HTTP_VERSION_1_1); } @Override @@ -647,13 +615,11 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest // here we can directly check original request first, as scheme is not expected to be changed if (_request != null) { return _request.getScheme(); - } else { - if (super.containsKey(HeaderFramework.CONNECTION_PROP_PROTOCOL)) { - return super.get(HeaderFramework.CONNECTION_PROP_PROTOCOL); - } else { - return "http"; - } } + if (super.containsKey(HeaderFramework.CONNECTION_PROP_PROTOCOL)) { + return super.get(HeaderFramework.CONNECTION_PROP_PROTOCOL); + } + return "http"; } @Override @@ -708,9 +674,8 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public String getRemoteAddr() { if (this._request != null) { return client(_request); - } else { - return super.get(HeaderFramework.CONNECTION_PROP_CLIENTIP); } + return super.get(HeaderFramework.CONNECTION_PROP_CLIENTIP); } public static String client(final ServletRequest request) { @@ -772,9 +737,8 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public Enumeration getLocales() { if (this._request != null) { return _request.getLocales(); - } else { - throw new UnsupportedOperationException("Not supported yet."); } + throw new UnsupportedOperationException("Not supported yet."); } @Override diff --git a/source/net/yacy/document/importer/WarcImporter.java b/source/net/yacy/document/importer/WarcImporter.java index 6fa81ec76..81a9bf9eb 100644 --- a/source/net/yacy/document/importer/WarcImporter.java +++ b/source/net/yacy/document/importer/WarcImporter.java @@ -242,10 +242,9 @@ public class WarcImporter extends Thread implements Importer { public long remainingTime() { if (this.consumed == 0) { return 0; - } else { - long speed = this.consumed / runningTime(); - return (this.sourceSize - this.consumed) / speed; } + long speed = this.consumed / runningTime(); + return (this.sourceSize - this.consumed) / speed; } @Override diff --git a/source/net/yacy/search/navigator/LanguageNavigator.java b/source/net/yacy/search/navigator/LanguageNavigator.java index 6e238c176..74d1b4152 100644 --- a/source/net/yacy/search/navigator/LanguageNavigator.java +++ b/source/net/yacy/search/navigator/LanguageNavigator.java @@ -128,9 +128,8 @@ public class LanguageNavigator extends StringNavigator implements Navigator { String longname = ISO639.country(lng); if (longname == null) { return lng; - } else { - return longname; } + return longname; } /** @@ -141,10 +140,6 @@ public class LanguageNavigator extends StringNavigator implements Navigator { */ @Override public boolean modifieractive(final QueryModifier modifier, final String name) { - if (modifier.language != null && modifier.language.contains(name)) { - return true; - } else { - return false; - } + return modifier.language != null && modifier.language.contains(name); } } diff --git a/source/net/yacy/search/navigator/YearNavigator.java b/source/net/yacy/search/navigator/YearNavigator.java index edaec4c20..30eef72e0 100644 --- a/source/net/yacy/search/navigator/YearNavigator.java +++ b/source/net/yacy/search/navigator/YearNavigator.java @@ -69,8 +69,7 @@ public class YearNavigator extends StringNavigator implements Navigator { public String getQueryModifier(final String key) { if (this.field == CollectionSchema.dates_in_content_dts) return "from:" + key +"-01-01 to:" + key + "-12-31 "; - else - return key; + return key; } /** diff --git a/source/net/yacy/utils/translation/TranslationManager.java b/source/net/yacy/utils/translation/TranslationManager.java index 7b82acaac..448734730 100644 --- a/source/net/yacy/utils/translation/TranslationManager.java +++ b/source/net/yacy/utils/translation/TranslationManager.java @@ -128,8 +128,7 @@ public class TranslationManager extends TranslatorXliff { Map tmp = mainTransLists.get(filename); if (tmp != null) return tmp.get(source); - else - return null; + return null; } /** diff --git a/source/net/yacy/utils/translation/TranslatorXliff.java b/source/net/yacy/utils/translation/TranslatorXliff.java index a95c1d857..c8dacc0a1 100644 --- a/source/net/yacy/utils/translation/TranslatorXliff.java +++ b/source/net/yacy/utils/translation/TranslatorXliff.java @@ -169,9 +169,8 @@ public class TranslatorXliff extends Translator { Map> mergedList = loadTranslationsListsFromXliff(xliffFile); Map> tmplist = loadTranslationsListsFromXliff(locallng); return mergeTranslationLists(mergedList, tmplist); - } else { - return loadTranslationsListsFromXliff(xliffFile); } + return loadTranslationsListsFromXliff(xliffFile); } else if (locallng.exists()) { Map> mergedList = super.loadTranslationsLists(xliffFile); Map> tmplist = super.loadTranslationsLists(locallng); @@ -382,10 +381,8 @@ public class TranslatorXliff extends Translator { public File getScratchFile(final File langFile) { if (Switchboard.getSwitchboard() != null) { // for debug and testing were switchboard is null File f = Switchboard.getSwitchboard().getDataPath("locale.translated_html", "DATA/LOCALE"); - f = new File(f.getParentFile(), langFile.getName()); - return f; - } else { - return langFile; + return new File(f.getParentFile(), langFile.getName()); } + return langFile; } }