Skip to content

Package: PlaceholderReplacer

PlaceholderReplacer

nameinstructionbranchcomplexitylinemethod
replace(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 24 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.broker.core.router;
14:
15: import org.apache.commons.lang3.text.StrSubstitutor;
16: import org.eclipse.kapua.commons.setting.system.SystemSetting;
17:
18: import java.util.HashMap;
19:
20: public class PlaceholderReplacer {
21:
22: private static final String REGEX_REPLACEMENT_CHARS = "([\\\\\\.\\)\\]\\}\\(‌​\\[\\{\\*\\+\\?\\^\\$\\|])";
23:
24: enum CAMEL_ROUTER_PLACEHOLDER {
25: CLASSIFIER
26: }
27:
28: private static HashMap<String, String> replacingMap;
29:
30: static {
31: replacingMap = new HashMap<>();
32: replacingMap.put(CAMEL_ROUTER_PLACEHOLDER.CLASSIFIER.name(), "^" +
33: SystemSetting.getInstance().getMessageClassifier().replaceAll(REGEX_REPLACEMENT_CHARS, "\\\\$0") + "\\.");
34: }
35:
36: private PlaceholderReplacer() {
37: }
38:
39: public static String replace(String str) {
40: return StrSubstitutor.replace(str, replacingMap);
41: }
42:
43: }