Skip to content

Package: DatatypeFactoryProvider

DatatypeFactoryProvider

nameinstructionbranchcomplexitylinemethod
DatatypeFactoryProvider()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getFactory()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
initFactory()
M: 7 C: 2
22%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 2 C: 1
33%
M: 0 C: 1
100%
static {...}
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%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.datatype.xsd;
19:
20: import javax.xml.datatype.DatatypeConfigurationException;
21: import javax.xml.datatype.DatatypeFactory;
22:
23: /**
24: * Provides a shared instance of {@link javax.xml.datatype.DatatypeFactory}, so that individual mappers do not need to manage their own.
25: * <p>
26: * Note that this assumes the factory implementation is thread-safe.
27: */
28: class DatatypeFactoryProvider {
29:
30: private static final DatatypeFactory FACTORY = initFactory();
31:
32: private DatatypeFactoryProvider() {
33: throw new AssertionError();
34: }
35:
36: private static DatatypeFactory initFactory() {
37: try {
38: return DatatypeFactory.newInstance();
39: } catch (DatatypeConfigurationException e) {
40: throw new IllegalStateException("Unable to initialize javax.xml.datatype.DatatypeFactory.", e);
41: }
42: }
43:
44: static DatatypeFactory getFactory() {
45: return FACTORY;
46: }
47: }