Skip to content
Snippets Groups Projects
Commit da9cfa66 authored by Vincent Massol's avatar Vincent Massol
Browse files

[Misc] Use a Java 14 construct for switch + remove unnecessary escapes

parent d9391db4
No related branches found
No related tags found
No related merge requests found
...@@ -209,15 +209,12 @@ public int getQueueSize() ...@@ -209,15 +209,12 @@ public int getQueueSize()
int size = 0; int size = 0;
for (EventStoreTask<?, ?> task : this.queue) { for (EventStoreTask<?, ?> task : this.queue) {
switch (task.type) { switch (task.type) {
case DELETE_EVENT: case DELETE_EVENT, DELETE_EVENT_BY_ID:
case DELETE_EVENT_BY_ID:
--size; --size;
break; break;
case SAVE_EVENT: case SAVE_EVENT:
++size; ++size;
break; break;
default: default:
break; break;
} }
......
...@@ -744,13 +744,11 @@ private String serializeCompareCondition(CompareQueryCondition condition) ...@@ -744,13 +744,11 @@ private String serializeCompareCondition(CompareQueryCondition condition)
} }
break; break;
case LESS: case LESS, LESS_OR_EQUALS:
case LESS_OR_EQUALS:
builder.append(toFilterQueryStringRange(null, condition)); builder.append(toFilterQueryStringRange(null, condition));
break; break;
case GREATER: case GREATER, GREATER_OR_EQUALS:
case GREATER_OR_EQUALS:
builder.append(toFilterQueryStringRange(condition, null)); builder.append(toFilterQueryStringRange(condition, null));
break; break;
......
...@@ -410,9 +410,9 @@ private void generateIndexPage(ZipOutputStream zos, XWikiContext context) throws ...@@ -410,9 +410,9 @@ private void generateIndexPage(ZipOutputStream zos, XWikiContext context) throws
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(""" builder.append("""
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html lang=\"en-US\"> <html lang="en-US">
<head> <head>
<meta charset=\"UTF-8\"> <meta charset="UTF-8">
<title>Export Index</title> <title>Export Index</title>
</head> </head>
<body> <body>
......
...@@ -397,11 +397,9 @@ private String encodeId(String value) ...@@ -397,11 +397,9 @@ private String encodeId(String value)
boolean encode = false; boolean encode = false;
switch (c) { switch (c) {
// '/' and '\' has been known to cause issues with various default server setup (Tomcat for example) // '/' and '\' have been known to cause issues with various default server setup (Tomcat for example)
case '/': case '/', '\\':
case '\\':
encode = true; encode = true;
break; break;
default: default:
......
...@@ -53,7 +53,7 @@ private FileSystemStoreUtils() ...@@ -53,7 +53,7 @@ private FileSystemStoreUtils()
* </ul> * </ul>
* *
* @param name the name to escape * @param name the name to escape
* @param caseInsensitive true if case insensitive filesystems should be supported * @param caseInsensitive true if case-insensitive filesystems should be supported
* @return a safe version of the name * @return a safe version of the name
*/ */
public static String encode(String name, boolean caseInsensitive) public static String encode(String name, boolean caseInsensitive)
...@@ -70,19 +70,8 @@ public static String encode(String name, boolean caseInsensitive) ...@@ -70,19 +70,8 @@ public static String encode(String name, boolean caseInsensitive)
// + is used for encoding // + is used for encoding
// Characters reserved on Windows and Unix // Characters reserved on Windows and Unix
// (https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx#naming_conventions) // (https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx#naming_conventions)
case '%': case '%', '+', '<', '>', ':', '"', '/', '\\', '|', '?', '*':
case '+':
case '<':
case '>':
case ':':
case '"':
case '/':
case '\\':
case '|':
case '?':
case '*':
encode = true; encode = true;
break; break;
case ' ': case ' ':
...@@ -90,7 +79,6 @@ public static String encode(String name, boolean caseInsensitive) ...@@ -90,7 +79,6 @@ public static String encode(String name, boolean caseInsensitive)
if (i == 0 || i == name.length() - 1) { if (i == 0 || i == name.length() - 1) {
encode = true; encode = true;
} }
break; break;
case '.': case '.':
...@@ -99,16 +87,14 @@ public static String encode(String name, boolean caseInsensitive) ...@@ -99,16 +87,14 @@ public static String encode(String name, boolean caseInsensitive)
if (i == 0 || i == name.length() - 1) { if (i == 0 || i == name.length() - 1) {
encode = true; encode = true;
} }
break; break;
default: default:
// Encode any non ASCII character to avoid surprises // Encode any non ASCII character to avoid surprises
// For case insensitive filesystem encode upper case characters // For case-insensitive filesystem encode upper case characters
if (!CharUtils.isAscii(c) || (caseInsensitive && Character.isUpperCase(c))) { if (!CharUtils.isAscii(c) || (caseInsensitive && Character.isUpperCase(c))) {
encode = true; encode = true;
} }
break; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment