remove warnings: 'Statement unnecessarily nested within else clause'

pull/278/head
sgaebel 6 years ago
parent eeae816cc4
commit c2398fd890

@ -56,9 +56,8 @@ public class TransNews_p {
prop.put("errmsg", 1); // msg: activate diff lng prop.put("errmsg", 1); // msg: activate diff lng
prop.put("transsize", 0); prop.put("transsize", 0);
return prop; return prop;
} else {
prop.put("errmsg", 0);
} }
prop.put("errmsg", 0);
TranslationManager transMgr = new TranslationManager(); TranslationManager transMgr = new TranslationManager();
File locallangFile = transMgr.getScratchFile(new File(currentlang + ".lng")); File locallangFile = transMgr.getScratchFile(new File(currentlang + ".lng"));

@ -44,9 +44,8 @@ public class Translator_p {
if ("default".equals(langcfg) || "browser".equals(langcfg)) { if ("default".equals(langcfg) || "browser".equals(langcfg)) {
prop.put("errmsg", 1); // msg: activate diff lng prop.put("errmsg", 1); // msg: activate diff lng
return prop; return prop;
} else {
prop.put("errmsg", 0);
} }
prop.put("errmsg", 0);
final File localesFolder = sb.getAppPath("locale.source", "locales"); final File localesFolder = sb.getAppPath("locale.source", "locales");
File lngfile = new File(localesFolder, langcfg + ".lng"); File lngfile = new File(localesFolder, langcfg + ".lng");

@ -161,9 +161,8 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
String cookiestring = this.get(COOKIE); // get from legacy or HttpServletRequest String cookiestring = this.get(COOKIE); // get from legacy or HttpServletRequest
if (cookiestring == null) { if (cookiestring == null) {
return ""; return "";
} else {
return cookiestring;
} }
return cookiestring;
} }
// implementation of HttpServletRequest procedures // implementation of HttpServletRequest procedures
@ -214,11 +213,10 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
public String mime() { public String mime() {
if (super.containsKey(HeaderFramework.CONTENT_TYPE)) { if (super.containsKey(HeaderFramework.CONTENT_TYPE)) {
return super.mime(); return super.mime();
} else {
if (_request != null) {
return _request.getContentType();
}
} }
if (_request != null) {
return _request.getContentType();
}
return "application/octet-stream"; return "application/octet-stream";
} }
@ -234,15 +232,14 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
public Cookie[] getCookies() { public Cookie[] getCookies() {
if (_request != null) { if (_request != null) {
return _request.getCookies(); 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 @Override
@ -250,12 +247,11 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
Date d = super.headerDate(name); Date d = super.headerDate(name);
if (d != null) { if (d != null) {
return d.getTime(); return d.getTime();
} else {
if (_request != null) {
return _request.getDateHeader(name);
}
return -1;
} }
if (_request != null) {
return _request.getDateHeader(name);
}
return -1;
} }
@Override @Override
@ -298,9 +294,8 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
public String getMethod() { public String getMethod() {
if (_request != null) { if (_request != null) {
return _request.getMethod(); return _request.getMethod();
} else {
return HeaderFramework.METHOD_POST;
} }
return HeaderFramework.METHOD_POST;
} }
@Override @Override
@ -317,146 +312,130 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
public String getPathTranslated() { public String getPathTranslated() {
if (_request != null) { if (_request != null) {
return _request.getPathTranslated(); return _request.getPathTranslated();
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public String getContextPath() { public String getContextPath() {
if (_request != null) { if (_request != null) {
return _request.getContextPath(); return _request.getContextPath();
} else {
return "";
} }
return "";
} }
@Override @Override
public String getQueryString() { public String getQueryString() {
if (_request != null) { if (_request != null) {
return _request.getQueryString(); return _request.getQueryString();
} else {
return null;
} }
return null;
} }
@Override @Override
public String getRemoteUser() { public String getRemoteUser() {
if (_request != null) if (_request != null)
return _request.getRemoteUser(); return _request.getRemoteUser();
else return null;
return null;
} }
@Override @Override
public boolean isUserInRole(String role) { public boolean isUserInRole(String role) {
if (_request != null) { if (_request != null) {
return _request.isUserInRole(role); return _request.isUserInRole(role);
} else {
return false;
} }
return false;
} }
@Override @Override
public Principal getUserPrincipal() { public Principal getUserPrincipal() {
if (_request != null) { if (_request != null) {
return _request.getUserPrincipal(); return _request.getUserPrincipal();
} else {
return null;
} }
return null;
} }
@Override @Override
public String getRequestedSessionId() { public String getRequestedSessionId() {
if (_request != null) { if (_request != null) {
return _request.getRequestedSessionId(); return _request.getRequestedSessionId();
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public String getRequestURI() { public String getRequestURI() {
if (_request != null) { if (_request != null) {
return _request.getRequestURI(); 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 @Override
public StringBuffer getRequestURL() { public StringBuffer getRequestURL() {
if (_request != null) { if (_request != null) {
return _request.getRequestURL(); 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 @Override
public String getServletPath() { public String getServletPath() {
if (_request != null) { if (_request != null) {
return _request.getServletPath(); return _request.getServletPath();
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public HttpSession getSession(boolean create) { public HttpSession getSession(boolean create) {
if (_request != null) { if (_request != null) {
return _request.getSession(create); return _request.getSession(create);
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public HttpSession getSession() { public HttpSession getSession() {
if (_request != null) { if (_request != null) {
return _request.getSession(); return _request.getSession();
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public String changeSessionId() { public String changeSessionId() {
if (_request != null) { if (_request != null) {
return _request.changeSessionId(); return _request.changeSessionId();
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public boolean isRequestedSessionIdValid() { public boolean isRequestedSessionIdValid() {
if (_request != null) { if (_request != null) {
return _request.isRequestedSessionIdValid(); return _request.isRequestedSessionIdValid();
} else {
return false;
} }
return false;
} }
@Override @Override
public boolean isRequestedSessionIdFromCookie() { public boolean isRequestedSessionIdFromCookie() {
if (_request != null) { if (_request != null) {
return _request.isRequestedSessionIdFromCookie(); return _request.isRequestedSessionIdFromCookie();
} else {
return false;
} }
return false;
} }
@Override @Override
public boolean isRequestedSessionIdFromURL() { public boolean isRequestedSessionIdFromURL() {
if (_request != null) { if (_request != null) {
return _request.isRequestedSessionIdFromURL(); return _request.isRequestedSessionIdFromURL();
} else {
return false;
} }
return false;
} }
@Deprecated // As of Version 2.1 of the Java Servlet API, use isRequestedSessionIdFromURL() instead. @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() { public boolean isRequestedSessionIdFromUrl() {
if (_request != null) { if (_request != null) {
return _request.isRequestedSessionIdFromUrl(); return _request.isRequestedSessionIdFromUrl();
} else {
return false;
} }
return false;
} }
@Override @Override
public boolean authenticate(HttpServletResponse response) throws IOException, ServletException { public boolean authenticate(HttpServletResponse response) throws IOException, ServletException {
if (_request != null) { if (_request != null) {
return _request.authenticate(response); return _request.authenticate(response);
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
@ -526,18 +503,16 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
public Object getAttribute(String name) { public Object getAttribute(String name) {
if (_request != null) { if (_request != null) {
return _request.getAttribute(name); return _request.getAttribute(name);
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public Enumeration<String> getAttributeNames() { public Enumeration<String> getAttributeNames() {
if (_request != null) { if (_request != null) {
return _request.getAttributeNames(); return _request.getAttributeNames();
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
@ -579,11 +554,10 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
public String getContentType() { public String getContentType() {
if (super.containsKey(HeaderFramework.CONTENT_TYPE)) { if (super.containsKey(HeaderFramework.CONTENT_TYPE)) {
return super.mime(); return super.mime();
} else {
if (_request != null) {
return _request.getContentType();
}
} }
if (_request != null) {
return _request.getContentType();
}
return null; return null;
} }
@ -591,45 +565,40 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
public ServletInputStream getInputStream() throws IOException { public ServletInputStream getInputStream() throws IOException {
if (_request != null) { if (_request != null) {
return _request.getInputStream(); return _request.getInputStream();
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public String getParameter(String name) { public String getParameter(String name) {
if (_request != null) { if (_request != null) {
return _request.getParameter(name); return _request.getParameter(name);
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public Enumeration<String> getParameterNames() { public Enumeration<String> getParameterNames() {
if (_request != null) { if (_request != null) {
return _request.getParameterNames(); return _request.getParameterNames();
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public String[] getParameterValues(String name) { public String[] getParameterValues(String name) {
if (_request != null) { if (_request != null) {
return _request.getParameterValues(name); return _request.getParameterValues(name);
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override
public Map<String, String[]> getParameterMap() { public Map<String, String[]> getParameterMap() {
if (_request != null) { if (_request != null) {
return _request.getParameterMap(); return _request.getParameterMap();
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @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 // here we can directly check original request, as protocol is not expected to be modified
if (_request != null) { if (_request != null) {
return _request.getProtocol(); 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 @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 // here we can directly check original request first, as scheme is not expected to be changed
if (_request != null) { if (_request != null) {
return _request.getScheme(); 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 @Override
@ -708,9 +674,8 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
public String getRemoteAddr() { public String getRemoteAddr() {
if (this._request != null) { if (this._request != null) {
return client(_request); 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) { public static String client(final ServletRequest request) {
@ -772,9 +737,8 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
public Enumeration<Locale> getLocales() { public Enumeration<Locale> getLocales() {
if (this._request != null) { if (this._request != null) {
return _request.getLocales(); return _request.getLocales();
} else {
throw new UnsupportedOperationException("Not supported yet.");
} }
throw new UnsupportedOperationException("Not supported yet.");
} }
@Override @Override

@ -242,10 +242,9 @@ public class WarcImporter extends Thread implements Importer {
public long remainingTime() { public long remainingTime() {
if (this.consumed == 0) { if (this.consumed == 0) {
return 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 @Override

@ -128,9 +128,8 @@ public class LanguageNavigator extends StringNavigator implements Navigator {
String longname = ISO639.country(lng); String longname = ISO639.country(lng);
if (longname == null) { if (longname == null) {
return lng; return lng;
} else {
return longname;
} }
return longname;
} }
/** /**
@ -141,10 +140,6 @@ public class LanguageNavigator extends StringNavigator implements Navigator {
*/ */
@Override @Override
public boolean modifieractive(final QueryModifier modifier, final String name) { public boolean modifieractive(final QueryModifier modifier, final String name) {
if (modifier.language != null && modifier.language.contains(name)) { return modifier.language != null && modifier.language.contains(name);
return true;
} else {
return false;
}
} }
} }

@ -69,8 +69,7 @@ public class YearNavigator extends StringNavigator implements Navigator {
public String getQueryModifier(final String key) { public String getQueryModifier(final String key) {
if (this.field == CollectionSchema.dates_in_content_dts) if (this.field == CollectionSchema.dates_in_content_dts)
return "from:" + key +"-01-01 to:" + key + "-12-31 "; return "from:" + key +"-01-01 to:" + key + "-12-31 ";
else return key;
return key;
} }
/** /**

@ -128,8 +128,7 @@ public class TranslationManager extends TranslatorXliff {
Map<String, String> tmp = mainTransLists.get(filename); Map<String, String> tmp = mainTransLists.get(filename);
if (tmp != null) if (tmp != null)
return tmp.get(source); return tmp.get(source);
else return null;
return null;
} }
/** /**

@ -169,9 +169,8 @@ public class TranslatorXliff extends Translator {
Map<String, Map<String, String>> mergedList = loadTranslationsListsFromXliff(xliffFile); Map<String, Map<String, String>> mergedList = loadTranslationsListsFromXliff(xliffFile);
Map<String, Map<String, String>> tmplist = loadTranslationsListsFromXliff(locallng); Map<String, Map<String, String>> tmplist = loadTranslationsListsFromXliff(locallng);
return mergeTranslationLists(mergedList, tmplist); return mergeTranslationLists(mergedList, tmplist);
} else {
return loadTranslationsListsFromXliff(xliffFile);
} }
return loadTranslationsListsFromXliff(xliffFile);
} else if (locallng.exists()) { } else if (locallng.exists()) {
Map<String, Map<String, String>> mergedList = super.loadTranslationsLists(xliffFile); Map<String, Map<String, String>> mergedList = super.loadTranslationsLists(xliffFile);
Map<String, Map<String, String>> tmplist = super.loadTranslationsLists(locallng); Map<String, Map<String, String>> tmplist = super.loadTranslationsLists(locallng);
@ -382,10 +381,8 @@ public class TranslatorXliff extends Translator {
public File getScratchFile(final File langFile) { public File getScratchFile(final File langFile) {
if (Switchboard.getSwitchboard() != null) { // for debug and testing were switchboard is null if (Switchboard.getSwitchboard() != null) { // for debug and testing were switchboard is null
File f = Switchboard.getSwitchboard().getDataPath("locale.translated_html", "DATA/LOCALE"); File f = Switchboard.getSwitchboard().getDataPath("locale.translated_html", "DATA/LOCALE");
f = new File(f.getParentFile(), langFile.getName()); return new File(f.getParentFile(), langFile.getName());
return f;
} else {
return langFile;
} }
return langFile;
} }
} }

Loading…
Cancel
Save