Skip to content

Package: EndPoint

EndPoint

nameinstructionbranchcomplexitylinemethod
parseRegex(String)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
replacePlaceholder(String)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
static {...}
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%

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 java.util.Map;
16: import java.util.regex.Pattern;
17:
18: import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
19:
20: import org.apache.camel.Exchange;
21: import org.apache.camel.Header;
22: import org.apache.camel.Properties;
23: import org.slf4j.Logger;
24: import org.slf4j.LoggerFactory;
25:
26: @XmlJavaTypeAdapter(EndPointAdapter.class)
27: public interface EndPoint {
28:
29: static Logger logger = LoggerFactory.getLogger(EndPoint.class);
30:
31: boolean matches(Exchange exchange, Object value, @Header(Exchange.SLIP_ENDPOINT) String previous, @Properties Map<String, Object> properties);
32:
33: String getEndPoint(Exchange exchange, Object value, @Header(Exchange.SLIP_ENDPOINT) String previous, @Properties Map<String, Object> properties);
34:
35: void toLog(StringBuffer buffer, String prefix);
36:
37: static String replacePlaceholder(String regex) {
38: try {
39: return PlaceholderReplacer.replace(regex);
40: } catch (Exception e) {
41: logger.error("Cannot replace placeholder '{}'", regex, e);
42: return null;
43: }
44: }
45:
46: static Pattern parseRegex(String regex) {
47: try {
48: return Pattern.compile(regex);
49: } catch (Exception e) {
50: logger.error("Cannot compile regex '{}'", regex, e);
51: return null;
52: }
53: }
54:
55: }