Semantic MediaWiki and related extensions
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SMWDataItem Class Reference

Public Member Functions

 getDIType ()
 
 getSortKey ()
 
 equals (SMWDataItem $di)
 
 getSortKeyDataItem ()
 
 getSerialization ()
 
 getHash ()
 
 __toString ()
 
 setOption ($key, $value)
 
 getOption ($key)
 

Static Public Member Functions

static newFromSerialization ($diType, $serialization)
 
static getDataItemClassNameForId ($diType)
 

Public Attributes

const TYPE_NOTYPE = 0
 Data item ID that can be used to indicate that no data item class is appropriate. More...
 
const TYPE_NUMBER = 1
 Data item ID for SMWDINumber. More...
 
const TYPE_STRING = 2
 
const TYPE_BLOB = 2
 Data item ID for SMWDIBlob. More...
 
const TYPE_BOOLEAN = 4
 Data item ID for SMWDIBoolean. More...
 
const TYPE_URI = 5
 Data item ID for SMWDIUri. More...
 
const TYPE_TIME = 6
 Data item ID for SMWDITimePoint. More...
 
const TYPE_GEO = 7
 Data item ID for SMWDIGeoCoord. More...
 
const TYPE_CONTAINER = 8
 Data item ID for SMWDIContainer. More...
 
const TYPE_WIKIPAGE = 9
 Data item ID for SMWDIWikiPage. More...
 
const TYPE_CONCEPT = 10
 Data item ID for SMWDIConcept. More...
 
const TYPE_PROPERTY = 11
 Data item ID for SMWDIProperty. More...
 
const TYPE_ERROR = 12
 Data item ID for SMWDIError. More...
 

Detailed Description

Objects of this type represent all that is known about a certain piece of data that could act as the value of some property. Data items only represent the stored data, and are thus at the core of SMW's data model. Data items are always immutable, i.e. they must not be changed after creation (and this is mostly enforced by the API with some minor exceptions).

The set of available data items is fixed and cannot be extended. These are the kinds of information that SMW can process. Their concrete use and handling might depend on the context in which they are used. In particular, property values may be influences by settings made for their property. This aspect, however, is not part of the data item API.

Since
1.6

Member Function Documentation

SMWDataItem::__toString ( )
Since
2.1
Returns
string
SMWDataItem::equals ( SMWDataItem  $di)
abstract

Method to compare two SMWDataItems This should result true only if they are of the same DI type and have the same internal value

Since
1.8
Parameters
SMWDataItem$di
Returns
boolean
static SMWDataItem::getDataItemClassNameForId (   $diType)
static

Gets the class name of the data item that has the provided type id.

Parameters
integer$diTypeElement of the SMWDataItem::TYPE_ enum
Exceptions
InvalidArgumentException
Returns
string
SMWDataItem::getDIType ( )
abstract

Convenience method that returns a constant that defines the concrete class that implements this data item. Used to switch when processing data items.

Returns
integer that specifies the basic type of data item
SMWDataItem::getHash ( )

Get a hash string for this data item. Might be overwritten in subclasses to obtain shorter or more efficient hashes.

Returns
string
SMWDataItem::getOption (   $key)
Since
2.5
Parameters
string$key
Returns
mixed
SMWDataItem::getSerialization ( )
abstract

Get a UTF-8 encoded string serialization of this data item. The serialisation should be concise and need not be pretty, but it must allow unserialization. Each subclass of SMWDataItem implements a static method doUnserialize() for this purpose.

Returns
string
SMWDataItem::getSortKey ( )
abstract

Return a value that can be used for sorting data of this type. If the data is of a numerical type, the sorting must be done in numerical order. If the data is a string, the data must be sorted alphabetically.

Note
Every data item returns a sort key, even if there is no natural linear order for the type. SMW must order listed data in some way in any case. If there is a natural order (e.g. for Booleans where false < true), then the sortkey must agree with this order (e.g. for Booleans where false maps to 0, and true maps to 1).
Wiki pages are a special case in SMW. They are ordered by a sortkey that is assigned to them as a property value. When pages are sorted, this data should be used if possible.
Returns
float|string
SMWDataItem::getSortKeyDataItem ( )

Create a data item that represents the sortkey, i.e. either an SMWDIBlob or an SMWDINumber. For efficiency, these subclasses overwrite this method to return themselves.

Returns
SMWDataItem
static SMWDataItem::newFromSerialization (   $diType,
  $serialization 
)
static

Create a data item of the given dataitem ID based on the the provided serialization string and (optional) typeid.

Parameters
$diTypeinteger dataitem ID
$serializationstring
Returns
SMWDataItem
SMWDataItem::setOption (   $key,
  $value 
)
Since
2.5
Parameters
string$key
string$value

Member Data Documentation

const SMWDataItem::TYPE_BLOB = 2

Data item ID for SMWDIBlob.

const SMWDataItem::TYPE_BOOLEAN = 4

Data item ID for SMWDIBoolean.

const SMWDataItem::TYPE_CONCEPT = 10

Data item ID for SMWDIConcept.

const SMWDataItem::TYPE_CONTAINER = 8

Data item ID for SMWDIContainer.

const SMWDataItem::TYPE_ERROR = 12

Data item ID for SMWDIError.

const SMWDataItem::TYPE_GEO = 7

Data item ID for SMWDIGeoCoord.

const SMWDataItem::TYPE_NOTYPE = 0

Data item ID that can be used to indicate that no data item class is appropriate.

const SMWDataItem::TYPE_NUMBER = 1

Data item ID for SMWDINumber.

const SMWDataItem::TYPE_PROPERTY = 11

Data item ID for SMWDIProperty.

const SMWDataItem::TYPE_STRING = 2

Data item ID for SMWDIString.

Deprecated:
Will vanish after SMW 1.9; use TYPE_BLOB instead.
const SMWDataItem::TYPE_TIME = 6

Data item ID for SMWDITimePoint.

const SMWDataItem::TYPE_URI = 5

Data item ID for SMWDIUri.

const SMWDataItem::TYPE_WIKIPAGE = 9

Data item ID for SMWDIWikiPage.


The documentation for this class was generated from the following file: