本文整理汇总了Java中org.wikidata.wdtk.datamodel.interfaces.DatatypeIdValue.DT_ITEM属性的典型用法代码示例。如果您正苦于以下问题:Java DatatypeIdValue.DT_ITEM属性的具体用法?Java DatatypeIdValue.DT_ITEM怎么用?Java DatatypeIdValue.DT_ITEM使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.wikidata.wdtk.datamodel.interfaces.DatatypeIdValue
的用法示例。
在下文中一共展示了DatatypeIdValue.DT_ITEM属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRdfValue
@Override
public Value getRdfValue(EntityIdValue value,
PropertyIdValue propertyIdValue, boolean simple) {
String datatype = this.propertyRegister
.setPropertyTypeFromEntityIdValue(propertyIdValue, value);
switch (datatype) {
case DatatypeIdValue.DT_ITEM:
if (simple) {
this.rdfConversionBuffer.addObjectProperty(propertyIdValue);
return this.rdfWriter.getUri(value.getIri());
} else {
return null; // or blank node
}
case DatatypeIdValue.DT_PROPERTY:
if (simple) {
this.rdfConversionBuffer.addObjectProperty(propertyIdValue);
return this.rdfWriter.getUri(value.getIri());
} else {
return null; // or blank node
}
default:
logIncompatibleValueError(propertyIdValue, datatype, "entity");
return null;
}
}
示例2: getDatatypeLabel
/**
* Returns an English label for a given datatype.
*
* @param datatype
* the datatype to label
* @return the label
*/
private String getDatatypeLabel(DatatypeIdValue datatype) {
if (datatype.getIri() == null) { // TODO should be redundant once the
// JSON parsing works
return "Unknown";
}
switch (datatype.getIri()) {
case DatatypeIdValue.DT_COMMONS_MEDIA:
return "Commons media";
case DatatypeIdValue.DT_GLOBE_COORDINATES:
return "Globe coordinates";
case DatatypeIdValue.DT_ITEM:
return "Item";
case DatatypeIdValue.DT_QUANTITY:
return "Quantity";
case DatatypeIdValue.DT_STRING:
return "String";
case DatatypeIdValue.DT_TIME:
return "Time";
case DatatypeIdValue.DT_URL:
return "URL";
case DatatypeIdValue.DT_PROPERTY:
return "Property";
case DatatypeIdValue.DT_EXTERNAL_ID:
return "External identifier";
case DatatypeIdValue.DT_MATH:
return "Math";
case DatatypeIdValue.DT_MONOLINGUAL_TEXT:
return "Monolingual Text";
default:
throw new RuntimeException("Unknown datatype " + datatype.getIri());
}
}
示例3: setPropertyTypeFromEntityIdValue
/**
* Returns the IRI of the primitive Type of an Property for
* {@link EntityIdValue} objects.
*
* @param propertyIdValue
* @param value
*/
public String setPropertyTypeFromEntityIdValue(
PropertyIdValue propertyIdValue, EntityIdValue value) {
switch (value.getId().charAt(0)) {
case 'Q':
return DatatypeIdValue.DT_ITEM;
case 'P':
return DatatypeIdValue.DT_PROPERTY;
default:
logger.warn("Could not determine Type of "
+ propertyIdValue.getId()
+ ". It is not a valid EntityDocument Id");
return null;
}
}
示例4: getRangeUri
/**
* Returns the class of datatype URI that best characterizes the range of
* the given property based on its datatype.
*
* @param propertyIdValue
* the property for which to get a range
* @return the range URI or null if the datatype could not be identified.
*/
String getRangeUri(PropertyIdValue propertyIdValue) {
String datatype = this.propertyRegister
.getPropertyType(propertyIdValue);
if (datatype == null)
return null;
switch (datatype) {
case DatatypeIdValue.DT_STRING:
case DatatypeIdValue.DT_EXTERNAL_ID:
case DatatypeIdValue.DT_MATH:
this.rdfConversionBuffer.addDatatypeProperty(propertyIdValue);
return Vocabulary.XSD_STRING;
case DatatypeIdValue.DT_COMMONS_MEDIA:
case DatatypeIdValue.DT_GLOBE_COORDINATES:
case DatatypeIdValue.DT_ITEM:
case DatatypeIdValue.DT_PROPERTY:
case DatatypeIdValue.DT_QUANTITY:
case DatatypeIdValue.DT_TIME:
case DatatypeIdValue.DT_URL:
this.rdfConversionBuffer.addObjectProperty(propertyIdValue);
return Vocabulary.OWL_THING;
default:
return null;
}
}
示例5: determineWikidataPropertyValueDataType
private static String determineWikidataPropertyValueDataType(final Predicate gdmPredicate, final NodeType gdmObjectType) {
final String propertyValueDataType;
switch (gdmObjectType) {
case Literal:
propertyValueDataType = DatatypeIdValue.DT_STRING;
break;
case Resource:
propertyValueDataType = DatatypeIdValue.DT_ITEM;
break;
default:
propertyValueDataType = DatatypeIdValue.DT_STRING;
LOG.debug("set property value data type '{}' for property '{}', because object type is '{}'", propertyValueDataType,
gdmPredicate.getUri(), gdmObjectType);
}
return propertyValueDataType;
}
示例6: setUp
@Before
public void setUp() {
d1 = new DatatypeIdImpl(DatatypeIdValue.DT_ITEM);
d2 = new DatatypeIdImpl("http://wikiba.se/ontology#WikibaseItem");
d3 = new DatatypeIdImpl(DatatypeIdValue.DT_TIME);
}
示例7: setUp
@Before
public void setUp() throws Exception {
pid = DataObjectFactoryImplTest.getTestPropertyIdValue(2);
labelMap = new HashMap<String, MonolingualTextValue>();
labelMap.put("en", new MonolingualTextValueImpl("Property 42", "en"));
labels = new ArrayList<MonolingualTextValue>();
labels.add(new MonolingualTextValueImpl("Property 42", "en"));
descriptionMap = new HashMap<String, MonolingualTextValue>();
descriptionMap.put("de", new MonolingualTextValueImpl(
"Dies ist Property 42.", "de"));
descriptions = new ArrayList<MonolingualTextValue>();
descriptions.add(new MonolingualTextValueImpl("Dies ist Property 42.",
"de"));
MonolingualTextValue alias1 = new MonolingualTextValueImpl(
"An alias of P42", "en");
MonolingualTextValue alias2 = new MonolingualTextValueImpl(
"Ein Alias von P42", "de");
MonolingualTextValue alias3 = new MonolingualTextValueImpl(
"Another alias of P42", "en");
aliasMap = new HashMap<String, List<MonolingualTextValue>>();
List<MonolingualTextValue> enAliases = new ArrayList<MonolingualTextValue>();
enAliases.add(alias1);
enAliases.add(alias3);
aliasMap.put("en", enAliases);
aliasMap.put("de",
Collections.singletonList(alias2));
aliases = new ArrayList<MonolingualTextValue>();
aliases.add(alias1);
aliases.add(alias2);
aliases.add(alias3);
statementGroups = DataObjectFactoryImplTest.getTestStatementGroups(2,
10, 3, EntityIdValue.ET_PROPERTY);
datatypeId = new DatatypeIdImpl(DatatypeIdValue.DT_ITEM);
pd1 = new PropertyDocumentImpl(pid, labels, descriptions, aliases,
statementGroups, datatypeId, 1234);
pd2 = new PropertyDocumentImpl(pid, labels, descriptions, aliases,
statementGroups, datatypeId, 1234);
}