Docs For Class EasyRdf_Resource

## Class EasyRdf_Resource

Description

Class that represents an RDF resource

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

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

Method Summary
EasyRdf_Resource __construct ( $uri, [ $graph = null])
array add (mixed $property, [ $values = null], mixed $resource, mixed $value)
void addLiteral (mixed $property, $values, [string $lang = null], mixed $value)
void addResource (mixed $property, $values, mixed $resource2)
void addType ( $types, string $type)
array all (string $property, [string $type = null], [string $lang = null])
array allLiterals (string $property, [string $lang = null])
array allResources (string $property)
null delete (string $property, [object $value = null])
string dump ([bool $html = true])
string dumpValue ([bool $html = true], [string $color = 'blue'])
mixed get (string|array $property, [ $type = null], [string $lang = null])
object EasyRdf_Literal getLiteral (string|array $property, [string $lang = null], string $resource)
string getNodeId ()
object EasyRdf_Resource getResource (string|array $property)
string getUri ()
bool hasProperty (string $property)
bool isBnode ()
boolean is_a (string $type)
string join (string $property, [string $glue = ' '], [string $lang = null])
string label ([ $lang = null])
string prefix ()
EasyRdf_Resource primaryTopic ()
array properties ()
array propertyUris ()
array reversePropertyUris ()
array set (string $property, mixed $values)
void setType (string $type)
string shorten ()
array toArray ()
string type ()
EasyRdf_Resource typeAsResource ()
array types ()
string __toString ()
Methods
Constructor __construct (line 63)

Constructor

* Please do not call new EasyRdf_Resource() directly *

To create a new resource use the get method in a graph: $resource = $graph->resource('http://www.example.com/');

- access: public

EasyRdf_Resource __construct ( $uri, [ $graph = null])

- $uri
- $graph

add (line 228)

Add values to for a property of the resource

The value can either be a single value or an array of values.

Example: $resource->add('prefix:property', 'value');

- return: Array of all values associated with property.
- access: public

array add (mixed $property, [ $values = null], mixed $resource, mixed $value)

- mixed $resource: The resource to add data to
- mixed $property: The property name
- mixed $value: The value for the property
- $values

addLiteral (line 245)

Add a literal value as a property of the resource

The value can either be a single value or an array of values.

Example: $resource->add('dc:title', 'Title of Page');

- access: public

void addLiteral (mixed $property, $values, [string $lang = null], mixed $value)

- mixed $property: The property name
- mixed $value: The value or values for the property
- string $lang: The language of the literal
- $values

addResource (line 259)

Add a resource as a property of the resource

Example: $bob->add('foaf:knows', 'http://example.com/alice');

- access: public

void addResource (mixed $property, $values, mixed $resource2)

- mixed $property: The property name
- mixed $resource2: The resource to be value of the property
- $values

addType (line 485)

Add one or more rdf:type properties to the resource

- access: public

void addType ( $types, string $type)

- string $type: The new type (e.g. foaf:Person)
- $types

all (line 330)

Get all values for a property

This method will return an empty array if the property does not exist.

- return: An array of values associated with the property
- access: public

array all (string $property, [string $type = null], [string $lang = null])

- string $property: The name of the property (e.g. foaf:name)
- string $type: The type of value to filter by (e.g. literal)
- string $lang: The language to filter by (e.g. en)

allLiterals (line 345)

Get all literal values for a property of the resource

This method will return an empty array if the resource does not has any literal values for that property.

- return: An array of values associated with the property
- access: public

array allLiterals (string $property, [string $lang = null])

- string $property: The name of the property (e.g. foaf:name)
- string $lang: The language to filter by (e.g. en)

allResources (line 359)

Get all resources for a property of the resource

This method will return an empty array if the resource does not has any resources for that property.

- return: An array of values associated with the property
- access: public

array allResources (string $property)

- string $property: The name of the property (e.g. foaf:name)

delete (line 210)

Delete a property (or optionally just a specific value)

- access: public

null delete (string $property, [object $value = null])

- string $property: The name of the property (e.g. foaf:name)
- object $value: The value to delete (null to delete all values)

dump (line 538)

Return a human readable view of the resource and its properties

This method is intended to be a debugging aid and will print a resource and its properties.

- access: public

string dump ([bool $html = true])

- bool $html: Set to true to format the dump using HTML

dumpValue (line 159)

Return pretty-print view of the resource

- access: public

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

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

get (line 279)

Get a single value for a property

If multiple values are set for a property then the value returned may be arbitrary.

If $property is an array, then the first item in the array that matches a property that exists is returned.

This method will return null if the property does not exist.

- return: A value associated with the property
- access: public

mixed get (string|array $property, [ $type = null], [string $lang = null])

- string|array $property: The name of the property (e.g. foaf:name)
- string $lang: The language to filter by (e.g. en)
- $type

getLiteral (line 298)

Get a single literal value for a property of the resource

If multiple values are set for a property then the value returned may be arbitrary.

This method will return null if there is not literal value for the property.

- return: Literal value associated with the property
- access: public

object EasyRdf_Literal getLiteral (string|array $property, [string $lang = null], string $resource)

- string $resource: The URI of the resource (e.g. http://example.com/joe#me)
- string|array $property: The name of the property (e.g. foaf:name)
- string $lang: The language to filter by (e.g. en)

getNodeId (line 105)

Get the identifier for a blank node

Returns null if the resource is not a blank node.

- return: The identifer for the bnode
- access: public

string getNodeId ()
getResource (line 315)

Get a single resource value for a property of the resource

If multiple values are set for a property then the value returned may be arbitrary.

This method will return null if there is not resource for the property.

- return: Resource associated with the property
- access: public

object EasyRdf_Resource getResource (string|array $property)

- string|array $property: The name of the property (e.g. foaf:name)

getUri (line 81)

Returns the URI for the resource.

- return: URI of this resource.
- access: public

string getUri ()
hasProperty (line 422)

Check to see if a property exists for this resource.

This method will return true if the property exists.

- return: True if value the property exists.
- access: public

bool hasProperty (string $property)

- string $property: The name of the property (e.g. foaf:gender)

isBnode (line 90)

Check to see if a resource is a blank node.

- return: True if this resource is a blank node.
- access: public

bool isBnode ()
is_a (line 475)

Check if a resource is of the specified type

- return: True if resource is of specified type.
- access: public

boolean is_a (string $type)

- string $type: The type to check (e.g. foaf:Person)

join (line 375)

Concatenate all values for a property into a string.

The default is to join the values together with a space character. This method will return an empty string if the property does not exist.

- return: Concatenation of all the values.
- access: public

string join (string $property, [string $glue = ' '], [string $lang = null])

- string $property: The name of the property (e.g. foaf:name)
- string $glue: The string to glue the values together with.
- string $lang: The language to filter by (e.g. en)

label (line 524)

Get a human readable label for this resource

This method will check a number of properties for the resource (in the order: skos:prefLabel, rdfs:label, foaf:name, dc:title) and return an approriate first that is available. If no label is available then it will return null.

- return: A label for the resource.
- access: public

string label ([ $lang = null])

- $lang

prefix (line 121)

Get a the prefix of the namespace that this resource is part of

This method will return null the resource isn't part of any registered namespace.

- return: The namespace prefix of the resource (e.g. foaf)
- access: public

string prefix ()
primaryTopic (line 509)

Get the primary topic of this resource.

Returns null if no primary topic is available.

- return: The primary topic of this resource.
- access: public

EasyRdf_Resource primaryTopic ()
properties (line 399)

Get a list of all the shortened property names (qnames) for a resource.

This method will return an empty array if the resource has no properties.

- return: Array of shortened URIs
- access: public

array properties ()
propertyUris (line 387)

Get a list of the full URIs for the properties of this resource.

This method will return an empty array if the resource has no properties.

- return: Array of full URIs
- access: public

array propertyUris ()
reversePropertyUris (line 409)

Get a list of the full URIs for the properties that point to this resource.

- return: Array of full property URIs
- access: public

array reversePropertyUris ()
set (line 198)

Set value(s) for a property

The new value(s) will replace the existing values for the property. The name of the property should be a string. If you set a property to null or an empty array, then the property will be deleted.

- return: Array of new values for this property.
- access: public

array set (string $property, mixed $values)

- string $property: The name of the property (e.g. foaf:name)
- mixed $values: The value(s) for the property.

setType (line 497)

Change the rdf:type property for the resource

Note that the PHP class of the resource will not change.

- access: public

void setType (string $type)

- string $type: The new type (e.g. foaf:Person)

shorten (line 133)

Get a shortened version of the resources URI.

This method will return the full URI if the resource isn't part of any registered namespace.

- return: The shortened URI of this resource (e.g. foaf:name)
- access: public

string shorten ()
toArray (line 145)

Returns the properties of the resource as an associative array

For example: array('type' => 'uri', 'value' => 'http://www.example.com/')

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

array toArray ()
type (line 450)

Get a single type for a resource.

The type will be a shortened URI as a string. If the resource has multiple types then the type returned may be arbitrary. This method will return null if the resource has no type.

- return: A type assocated with the resource (e.g. foaf:Person)
- access: public

string type ()
typeAsResource (line 465)

Get a single type for a resource, as a resource.

The type will be returned as an EasyRdf_Resource. If the resource has multiple types then the type returned may be arbitrary. This method will return null if the resource has no type.

- return: A type assocated with the resource.
- access: public

EasyRdf_Resource typeAsResource ()
types (line 435)

Get a list of types for a resource.

The types will each be a shortened URI as a string. This method will return an empty array if the resource has no types.

- return: All types assocated with the resource (e.g. foaf:Person)
- access: public

array types ()
__toString (line 168)

Magic method to return URI of resource when casted to string

- return: The URI of the resource
- access: public

string __toString ()

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