Package: ToURLConverter
ToURLConverter
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ToURLConverter() |
|
|
|
|
|
||||||||||||||||||||
convertToAttribute(Object) |
|
|
|
|
|
||||||||||||||||||||
convertToAxiomValue(URL) |
|
|
|
|
|
||||||||||||||||||||
supportsAxiomValueType(Class) |
|
|
|
|
|
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: }