Skip to content

Package: ToURLConverter

ToURLConverter

nameinstructionbranchcomplexitylinemethod
ToURLConverter()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
convertToAttribute(Object)
M: 14 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
convertToAxiomValue(URL)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
supportsAxiomValueType(Class)
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: package cz.cvut.kbss.jopa.oom.converter;
2:
3: import cz.cvut.kbss.jopa.exception.UnsupportedTypeTransformationException;
4:
5: import java.net.MalformedURLException;
6: import java.net.URL;
7:
8: /**
9: * Converter to {@link java.net.URL}.
10: * <p>
11: * Only {@code String} values are supported.
12: */
13: public class ToURLConverter implements ConverterWrapper<URL, Object> {
14:
15: @Override
16: public boolean supportsAxiomValueType(Class<?> type) {
17: return String.class.equals(type);
18: }
19:
20: @Override
21: public Object convertToAxiomValue(URL value) {
22: return value.toString();
23: }
24:
25: @Override
26: public URL convertToAttribute(Object value) {
27: try {
28: return new URL(value.toString());
29: } catch (MalformedURLException e) {
30: throw new UnsupportedTypeTransformationException("Unable to convert value " + value + " to URL.", e);
31: }
32: }
33: }