Debian Codegraph @

wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/values/AbstractValueConverter.java

raw
1 package org.wikidata.wdtk.rdf.values;
2
3 /*
4 * #%L
5 * Wikidata Toolkit RDF
6 * %%
7 * Copyright (C) 2014 Wikidata Toolkit Developers
8 * %%
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * #L%
21 */
22
23 import org.eclipse.rdf4j.rio.RDFHandlerException;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26 import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
27 import org.wikidata.wdtk.rdf.OwlDeclarationBuffer;
28 import org.wikidata.wdtk.rdf.PropertyRegister;
29 import org.wikidata.wdtk.rdf.RdfWriter;
30
31 public abstract class AbstractValueConverter<V extends org.wikidata.wdtk.datamodel.interfaces.Value>
32 implements ValueConverter<V> {
33
34 final PropertyRegister propertyRegister;
35 final RdfWriter rdfWriter;
36 final OwlDeclarationBuffer rdfConversionBuffer;
37
38 static final Logger logger = LoggerFactory.getLogger(ValueConverter.class);
39
40 public AbstractValueConverter(RdfWriter rdfWriter,
41 PropertyRegister propertyRegister,
42 OwlDeclarationBuffer rdfConversionBuffer) {
43 this.rdfWriter = rdfWriter;
44 this.propertyRegister = propertyRegister;
45 this.rdfConversionBuffer = rdfConversionBuffer;
46 }
47
48 @Override
49 public void writeAuxiliaryTriples() throws RDFHandlerException {
50 // default implementation: no auxiliary triples
51 }
52
53 /**
54 * Logs a message for a case where the value of a property does not fit to
55 * its declared datatype.
56 *
57 * @param propertyIdValue
58 * the property that was used
59 * @param datatype
60 * the declared type of the property
61 * @param valueType
62 * a string to denote the type of value
63 */
64 protected void logIncompatibleValueError(PropertyIdValue propertyIdValue,
65 String datatype, String valueType) {
66 logger.warn("Property " + propertyIdValue.getId() + " has type \""
67 + datatype + "\" but a value of type " + valueType
68 + ". Data ignored.");
69 }
70 }