Wikidata/Development/Data values and types
This page offers a draft of how data values and data types in Wikibase could interplay, and how this plays together with SMW's data values.
There are two main classes:
Type, and, from the ValueHandler extension,
TypeFactory is used to
- get a list of all
- get an instance of
Type is used to
- get labels of itself
- parse a string and get a
DataValue comes from the ValueHandler extension and is used to
- store a specific value (e.g. 3km+-50 meter)
DataValue is always stored within a
Snak, that keeps track of the
Type of the
DataValue and can thus also provide formatting and parsing for the
Property is an
Entity that allows you to get its
Normally, developers using values and types do not need to understand the underlying implementation, but merely the above interfaces.
The ValueHandler extension provides four components:
Validator. These are shared with the Validator extension, and also between Semantic MediaWiki and Wikibase.
DataValuestores the actual value
DataValueinto a serialization
Parserturns a serialization into a
DataValuefor further conditions
Each of these four, and often are, subclassed, and many of them can be combined together. So, for example, there are subclasses of
DataValue for geodata, numbers, etc.
In Wikibase, a
Type is basically defined by composing it from the four different components provided in the ValueHandler extension. This composition is configured for
TypeFactory and made programmatically accesible through it.
TypeFactory uses this configuration and assembles the