| 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.model.Value; |
| 24 |
import org.wikidata.wdtk.datamodel.interfaces.DatatypeIdValue; |
| 25 |
import org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue; |
| 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.RdfConverter; |
| 30 |
import org.wikidata.wdtk.rdf.RdfWriter; |
| 31 |
|
| 32 |
public class MonolingualTextValueConverter extends |
| 33 |
AbstractValueConverter<MonolingualTextValue> { |
| 34 |
|
| 35 |
public MonolingualTextValueConverter(RdfWriter rdfWriter, |
| 36 |
PropertyRegister propertyRegister, |
| 37 |
OwlDeclarationBuffer rdfConversionBuffer) { |
| 38 |
super(rdfWriter, propertyRegister, rdfConversionBuffer); |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
public Value getRdfValue(MonolingualTextValue value, |
| 43 |
PropertyIdValue propertyIdValue, boolean simple) { |
| 44 |
String datatype = this.propertyRegister |
| 45 |
.setPropertyTypeFromMonolingualTextValue(propertyIdValue, value); |
| 46 |
|
| 47 |
switch (datatype) { |
| 48 |
case DatatypeIdValue.DT_MONOLINGUAL_TEXT: |
| 49 |
if (simple) { |
| 50 |
this.rdfConversionBuffer.addObjectProperty(propertyIdValue); |
| 51 |
return RdfConverter.getMonolingualTextValueLiteral(value, |
| 52 |
this.rdfWriter); |
| 53 |
} else { |
| 54 |
return null; // or blank node |
| 55 |
} |
| 56 |
default: |
| 57 |
logIncompatibleValueError(propertyIdValue, datatype, "entity"); |
| 58 |
return null; |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
} |