SMWDataItem Class Reference
[SMWDataItems]

Objects of this type represent all that is known about a certain piece of data that could act as the value of some property. More...

Inherited by SMWDIBlob, SMWDIBoolean, SMWDIConcept, SMWDIContainer, SMWDIError, SMWDIGeoCoord, SMWDINumber, SMWDIProperty, SMWDITime, SMWDIUri, and SMWDIWikiPage.

List of all members.

Public Member Functions

 getDIType ()
 Convenience method that returns a constant that defines the concrete class that implements this data item.
 getSortKey ()
 Return a value that can be used for sorting data of this type.
 getSortKeyDataItem ()
 Create a data item that represents the sortkey, i.e.
 getSerialization ()
 Get a UTF-8 encoded string serialization of this data item.
 getHash ()
 Get a hash string for this data item.

Static Public Member Functions

static newFromSerialization ($diType, $serialization)
 Create a data item of the given dataitem ID based on the the provided serialization string and (optional) typeid.
static getDataItemClassNameForId ($diType)
 Gets the class name of the data item that has the provided type id.

Public Attributes

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


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

Definition at line 44 of file SMW_DataItem.php.


Member Function Documentation

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

Reimplemented in SMWDIBlob, SMWDIBoolean, SMWDIConcept, SMWDIContainer, SMWDIError, SMWDIGeoCoord, SMWDINumber, SMWDIProperty, SMWDIString, SMWDITime, SMWDIUri, and SMWDIWikiPage.

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 or string

Reimplemented in SMWDIBlob, SMWDIBoolean, SMWDIConcept, SMWDIContainer, SMWDIError, SMWDIGeoCoord, SMWDINumber, SMWDIProperty, SMWDITime, SMWDIUri, and SMWDIWikiPage.

Referenced by getSortKeyDataItem().

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

Reimplemented in SMWDIBlob, and SMWDINumber.

Definition at line 109 of file SMW_DataItem.php.

References getSortKey().

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

Reimplemented in SMWDIBlob, SMWDIBoolean, SMWDIConcept, SMWDIContainer, SMWDIError, SMWDIGeoCoord, SMWDINumber, SMWDIProperty, SMWDITime, SMWDIUri, and SMWDIWikiPage.

Referenced by getHash(), and SMWDISerializer::getSerialization().

SMWDataItem::getHash (  ) 

Get a hash string for this data item.

Might be overwritten in subclasses to obtain shorter or more efficient hashes.

Returns:
string

Reimplemented in SMWDIContainer.

Definition at line 133 of file SMW_DataItem.php.

References getSerialization().

Referenced by SMWSemanticData::addPropertyObjectValue(), and SMWExportController::queuePage().

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:
$diType integer dataitem ID
$serialization string
$typeid string SMW type ID (optional)
Returns:
SMWDataItem

Definition at line 147 of file SMW_DataItem.php.

static SMWDataItem::getDataItemClassNameForId ( diType  )  [static]

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

Parameters:
integer $diType Element of the SMWDataItem::TYPE_ enum
Exceptions:
InvalidArgumentException 
Returns:
string

Definition at line 161 of file SMW_DataItem.php.


Member Data Documentation

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

Definition at line 47 of file SMW_DataItem.php.

Referenced by SMWSparqlStoreQueryEngine::addOrderByDataForProperty(), SMWCompatibilityHelpers::dataItemFromDBKeys(), and SMWDataValueFactory::getDataItemId().


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

Generated on Sun Mar 18 07:15:43 2012 for Semantic MediaWiki by  doxygen 1.5.6