當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。