mirror of
https://github.com/metosin/reitit.git
synced 2025-12-18 17:01:11 +00:00
Polish
This commit is contained in:
parent
885ca8813c
commit
d0cfdf304a
1 changed files with 6 additions and 9 deletions
|
|
@ -12,8 +12,7 @@ import java.util.*;
|
||||||
|
|
||||||
public class Trie {
|
public class Trie {
|
||||||
|
|
||||||
private static String decode(char[] chars, int begin, int end, boolean hasPercent, boolean hasPlus) {
|
private static String decode(String s, boolean hasPercent, boolean hasPlus) {
|
||||||
final String s = new String(chars, begin, end - begin);
|
|
||||||
try {
|
try {
|
||||||
if (hasPercent) {
|
if (hasPercent) {
|
||||||
return URLDecoder.decode(hasPlus ? s.replace("+", "%2B") : s, "UTF-8");
|
return URLDecoder.decode(hasPlus ? s.replace("+", "%2B") : s, "UTF-8");
|
||||||
|
|
@ -36,7 +35,7 @@ public class Trie {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return decode(chars, begin, end, hasPercent, hasPlus);
|
return decode(new String(chars, begin, end - begin), hasPercent, hasPlus);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Match {
|
public static class Match {
|
||||||
|
|
@ -114,18 +113,16 @@ public class Trie {
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class DataMatcher implements Matcher {
|
static final class DataMatcher implements Matcher {
|
||||||
private final IPersistentMap params;
|
private final Match match;
|
||||||
private final Object data;
|
|
||||||
|
|
||||||
DataMatcher(IPersistentMap params, Object data) {
|
DataMatcher(IPersistentMap params, Object data) {
|
||||||
this.params = params;
|
this.match = new Match(params, data);
|
||||||
this.data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Match match(int i, int max, char[] path) {
|
public Match match(int i, int max, char[] path) {
|
||||||
if (i == max) {
|
if (i == max) {
|
||||||
return new Match(params, data);
|
return match;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +139,7 @@ public class Trie {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return (data != null ? data.toString() : "nil");
|
return (match.data != null ? match.data.toString() : "nil");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue