Docs For Class EasyRdf_Literal

## Class EasyRdf_Literal

Description

Class that represents an RDF Literal

- copyright: Copyright (c) 2009-2011 Nicholas J Humfrey
- license: http://www.opensource.org/licenses/bsd-license.php

Located in /EasyRdf/Literal.php (line 46)

Direct descendents

Class | Description
--- | ---
EasyRdf_Literal_Boolean | Class that represents an RDF Literal of datatype xsd:boolean
EasyRdf_Literal_Date | Class that represents an RDF Literal of datatype xsd:date
EasyRdf_Literal_Decimal | Class that represents an RDF Literal of datatype xsd:decimal
EasyRdf_Literal_Integer | Class that represents an RDF Literal of datatype xsd:integer

Method Summary
static object EasyRdf_Literal create (mixed $value, [string $lang = null], [string $datatype = null])
static void deleteDatatypeMapping (string $datatype)
static string getDatatypeForValue ( $value)
static void setDatatypeMapping (string $datatype, string $class)
object EasyRdf_Literal __construct (string $value, [string $lang = null], [string $datatype = null])
string dumpValue ([bool $html = true], [string $color = 'black'])
string getDatatype ()
string getDatatypeUri ()
string getLang ()
string getValue ()
array toArray ()
string __toString ()
Methods
static method create (line 80)

Create a new literal object

PHP values of type bool, int or float, will automatically be converted to the corresponding datatype and PHP sub-class.

If a registered datatype is given, then the registered subclass of EasyRdf_Literal will instantiated.

Note that literals are not required to have a language or datatype. Literals cannot have both a language and a datatype.

- return: (or subclass of EasyRdf_Literal)
- access: public

static object EasyRdf_Literal create (mixed $value, [string $lang = null], [string $datatype = null])

- mixed $value: The value of the literal or an associative array
- string $lang: The natural language of the literal or null (e.g. 'en')
- string $datatype: The datatype of the literal or null (e.g. 'xsd:integer')

static method deleteDatatypeMapping (line 144)

Remove the mapping between an RDF datatype and a PHP class name

- access: public

static void deleteDatatypeMapping (string $datatype)

- string $datatype: The RDF datatype (e.g. xsd:dateTime)

static method getDatatypeForValue (line 169)

Get datatype URI for a PHP value.

This static function is intended for internal use. Given a PHP value, it will return an XSD datatype URI for that value, for example: http://www.w3.org/2001/XMLSchema#integer

- return: A URI for the datatype of $value.
- access: public

static string getDatatypeForValue ( $value)

- $value

static method setDatatypeMapping (line 121)

Register an RDF datatype with a PHP class name

When parsing registered class will be used whenever the datatype is seen.

When serialising a registered class, the mapping will be used to set the datatype in the RDF.

Example: EasyRdf_Literal::registerDatatype('xsd:dateTime', 'My_DateTime_Class');

- access: public

static void setDatatypeMapping (string $datatype, string $class)

- string $datatype: The RDF datatype (e.g. xsd:dateTime)
- string $class: The PHP class name (e.g. My_DateTime_Class)

Constructor __construct (line 191)

Constructor for creating a new literal

- access: public

object EasyRdf_Literal __construct (string $value, [string $lang = null], [string $datatype = null])

- string $value: The value of the literal
- string $lang: The natural language of the literal or null (e.g. 'en')
- string $datatype: The datatype of the literal or null (e.g. 'xsd:string')

Redefined in descendants as:

- EasyRdf_Literal_Boolean::__construct() : Constructor for creating a new boolean literal
- EasyRdf_Literal_Date::__construct() : Constructor for creating a new date literal
- EasyRdf_Literal_DateTime::__construct() : Constructor for creating a new date literal
- EasyRdf_Literal_Decimal::__construct() : Constructor for creating a new decimal literal
- EasyRdf_Literal_Integer::__construct() : Constructor for creating a new integer literal

dumpValue (line 296)

Return pretty-print view of the literal

- access: public

string dumpValue ([bool $html = true], [string $color = 'black'])

- bool $html: Set to true to format the dump using HTML
- string $color: The colour of the text

getDatatype (line 240)

Returns the shortened datatype URI of the literal.

- return: Datatype of this literal (e.g. xsd:integer).
- access: public

string getDatatype ()
getDatatypeUri (line 231)

Returns the full datatype URI of the literal.

- return: Datatype URI of this literal.
- access: public

string getDatatypeUri ()
getLang (line 253)

Returns the language of the literal.

- return: Language of this literal.
- access: public

string getLang ()
getValue (line 222)

Returns the value of the literal.

- return: Value of this literal.
- access: public

string getValue ()
toArray (line 265)

Returns the properties of the literal as an associative array

For example: array('type' => 'literal', 'value' => 'string value')

- return: The properties of the literal
- access: public

array toArray ()
__toString (line 285)

Magic method to return the value of a literal when casted to string

- return: The value of the literal
- access: public

string __toString ()

Redefined in descendants as:

- EasyRdf_Literal_Boolean::__toString() : Magic method to return the value of a boolean when casted to string
- EasyRdf_Literal_Date::__toString() : Magic method to return the value as an ISO8601 date string
- EasyRdf_Literal_DateTime::__toString() : Magic method to return the value as an ISO8601 string

Documentation generated on Wed, 20 Jul 2011 19:54:04 +0100 by phpDocumentor 1.4.3