MultiHashKey

This commit is contained in:
redkale
2024-01-30 23:15:06 +08:00
parent 54d629155b
commit 5ce226edd7
2 changed files with 12 additions and 8 deletions

View File

@@ -29,7 +29,7 @@ class MultiHashKeys {
for (int i = 0; i < chars.length; i++) {
char ch = chars[i];
if (ch == '{') {
if (paraming || i < 1) {
if (paraming) {
throw new RedkaleException(MultiHashKey.class.getSimpleName() + " parse error, key: " + key);
}
if (last == '#') {
@@ -43,15 +43,12 @@ class MultiHashKeys {
sb.deleteCharAt(sb.length() - 1);
sb.append(ch);
} else {
throw new RedkaleException(MultiHashKey.class.getSimpleName() + " parse error, key: " + key);
sb.append(ch);
}
} else if (last == '\\' && ch == '}') {
} else if (ch == '}' && last == '\\') {
sb.deleteCharAt(sb.length() - 1);
sb.append(ch);
} else if (ch == '}') {
if (!paraming) {
throw new RedkaleException(MultiHashKey.class.getSimpleName() + " parse error, key: " + key);
}
} else if (ch == '}' && paraming) {
String name = sb.toString();
sb.delete(0, sb.length());
if (name.indexOf('.') > 0) {
@@ -65,6 +62,9 @@ class MultiHashKeys {
}
last = ch;
}
if (sb.length() > 0) {
list.add(new StringKey(sb.toString()));
}
if (list.size() == 1) {
return list.get(0);
}