当前位置: 首页>>代码示例>>Java>>正文


Java DatatypeIdValue.DT_STRING属性代码示例

本文整理汇总了Java中org.wikidata.wdtk.datamodel.interfaces.DatatypeIdValue.DT_STRING属性的典型用法代码示例。如果您正苦于以下问题:Java DatatypeIdValue.DT_STRING属性的具体用法?Java DatatypeIdValue.DT_STRING怎么用?Java DatatypeIdValue.DT_STRING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.wikidata.wdtk.datamodel.interfaces.DatatypeIdValue的用法示例。


在下文中一共展示了DatatypeIdValue.DT_STRING属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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());
	}
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit-Examples,代码行数:40,代码来源:ClassPropertyUsageAnalyzer.java

示例2: setPropertyTypeFromStringValue

/**
 * Returns the IRI of the primitive Type of an Property for
 * {@link StringValue} objects.
 *
 * @param propertyIdValue
 * @param value
 */
public String setPropertyTypeFromStringValue(
		PropertyIdValue propertyIdValue, StringValue value) {
	String datatype = getPropertyType(propertyIdValue);
	if (datatype == null) {
		logger.warn("Could not fetch datatype of "
				+ propertyIdValue.getIri() + ". Assuming type "
				+ DatatypeIdValue.DT_STRING);
		return DatatypeIdValue.DT_STRING; // default type for StringValue
	} else {
		return datatype;
	}
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:19,代码来源:PropertyRegister.java

示例3: 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;
	}
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:34,代码来源:SnakRdfConverter.java

示例4: equalityBasedOnContent

@Test
public void equalityBasedOnContent() {
	PropertyDocument pdDiffSubject = new PropertyDocumentImpl(
			DataObjectFactoryImplTest.getTestPropertyIdValue(3), labels,
			descriptions, aliases,
			DataObjectFactoryImplTest.getTestStatementGroups(3, 10, 3,
					EntityIdValue.ET_PROPERTY), datatypeId, 1234);
	PropertyDocument pdDiffLabels = new PropertyDocumentImpl(pid,
			Collections.<MonolingualTextValue> emptyList(), descriptions,
			aliases, statementGroups, datatypeId, 1234);
	PropertyDocument pdDiffDescriptions = new PropertyDocumentImpl(pid,
			labels, Collections.<MonolingualTextValue> emptyList(),
			aliases, statementGroups, datatypeId, 1234);
	PropertyDocument pdDiffAliases = new PropertyDocumentImpl(pid, labels,
			descriptions, Collections.<MonolingualTextValue> emptyList(),
			statementGroups, datatypeId, 1234);
	PropertyDocument pdDiffStatements = new PropertyDocumentImpl(pid,
			labels, descriptions, aliases,
			Collections.<StatementGroup> emptyList(), datatypeId, 1234);
	PropertyDocument pdDiffDatatype = new PropertyDocumentImpl(pid, labels,
			descriptions, aliases, statementGroups, new DatatypeIdImpl(
					DatatypeIdValue.DT_STRING), 1234);

	ItemDocument id = new ItemDocumentImpl(new ItemIdValueImpl("Q42",
			"foo"), labels, descriptions, aliases,
			Collections.<StatementGroup> emptyList(),
			Collections.<String, SiteLink> emptyMap(), 1234);

	assertEquals(pd1, pd1);
	assertEquals(pd1, pd2);
	assertThat(pd1, not(equalTo(pdDiffSubject)));
	assertThat(pd1, not(equalTo(pdDiffLabels)));
	assertThat(pd1, not(equalTo(pdDiffDescriptions)));
	assertThat(pd1, not(equalTo(pdDiffAliases)));
	assertThat(pd1, not(equalTo(pdDiffStatements)));
	assertThat(pd1, not(equalTo(pdDiffDatatype)));
	assertFalse(pd1.equals(id));
	assertThat(pd1, not(equalTo(null)));
	assertFalse(pd1.equals(this));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:40,代码来源:PropertyDocumentImplTest.java

示例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;
	}
 
开发者ID:dswarm,项目名称:wikidata-d-swarm-importer,代码行数:26,代码来源:WikidataDswarmImporter.java

示例6: getRdfValue

@Override
public Value getRdfValue(StringValue value,
		PropertyIdValue propertyIdValue, boolean simple) {
	String datatype = this.propertyRegister.setPropertyTypeFromStringValue(
			propertyIdValue, value);

	String valueUriString = null;
	switch (datatype) {
	case DatatypeIdValue.DT_STRING:
	case DatatypeIdValue.DT_EXTERNAL_ID:
	case DatatypeIdValue.DT_MATH:
		valueUriString = null;
		break;
	case DatatypeIdValue.DT_COMMONS_MEDIA:
		if (simple) {
			valueUriString = getCommonsUrl(value.getString());
		}
		break;
	case DatatypeIdValue.DT_URL:
		if (simple) {
			valueUriString = value.getString();
		}
		break;
	default:
		logIncompatibleValueError(propertyIdValue, datatype, "string");
		return null;
	}

	if (valueUriString == null) {
		if (simple) {
			this.rdfConversionBuffer.addDatatypeProperty(propertyIdValue);
			return this.rdfWriter.getLiteral(value.getString());
		} else {
			return null; // or blank node
		}
	} else {
		this.rdfConversionBuffer.addObjectProperty(propertyIdValue);
		try {
			return this.rdfWriter.getUri(valueUriString);
		} catch (IllegalArgumentException e) {
			logger.error("Invalid URI \"" + valueUriString
					+ "\". Not serializing value.");
			return null;
		}
	}
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:46,代码来源:StringValueConverter.java

示例7: equalityBasedOnContent

@Test
public void equalityBasedOnContent() {
	ItemDocument irDiffStatementGroups = new ItemDocumentImpl(iid,
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<StatementGroup> emptyList(), sitelinks, 1234);
	ItemDocument irDiffSiteLinks = new ItemDocumentImpl(iid,
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			statementGroups, Collections.<String, SiteLink> emptyMap(),
			1234);
	ItemDocument irDiffRevisions = new ItemDocumentImpl(iid,
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			statementGroups, sitelinks, 1235);

	PropertyDocument pr = new PropertyDocumentImpl(
			new PropertyIdValueImpl("P42", "foo"),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<StatementGroup> emptyList(), new DatatypeIdImpl(
					DatatypeIdValue.DT_STRING), 1234);

	// we need to use empty lists of Statement groups to test inequality
	// based on different item ids with all other data being equal
	ItemDocument irDiffItemIdValue = new ItemDocumentImpl(
			new ItemIdValueImpl("Q23", "http://example.org/"),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<StatementGroup> emptyList(), sitelinks, 1234);

	assertEquals(ir1, ir1);
	assertEquals(ir1, ir2);
	assertThat(ir1, not(equalTo(irDiffStatementGroups)));
	assertThat(ir1, not(equalTo(irDiffSiteLinks)));
	assertThat(ir1, not(equalTo(irDiffRevisions)));
	assertThat(irDiffStatementGroups, not(equalTo(irDiffItemIdValue)));
	assertFalse(ir1.equals(pr));
	assertThat(ir1, not(equalTo(null)));
	assertFalse(ir1.equals(this));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:46,代码来源:ItemDocumentImplTest.java


注:本文中的org.wikidata.wdtk.datamodel.interfaces.DatatypeIdValue.DT_STRING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。