Class EasyRdf_Resource

Description

Class that represents an RDF resource

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


	
			
Method Summary
EasyRdf_Resource __construct ( $uri, [ $graph = null])
integer add (mixed $property, mixed $value, mixed $resource)
integer addLiteral (mixed $property,  $values, [string $lang = null], mixed $value)
integer addResource (mixed $property,  $values, mixed $resource2)
integer 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)
integer count (string $property, [string $type = null], [string $lang = null])
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)
string htmlLink ([string $text = NULL], [array $options = array()])
bool isBnode ()
boolean is_a (string $type)
string join (string $property, [string $glue = ' '], [string $lang = null])
string label ([ $lang = null])
void load ([string $format = null])
string localName ()
string prefix ()
array properties ()
array propertyUris ()
integer set (string $property, mixed $value)
integer setType (string $type)
string shorten ()
array toArray ()
string type ()
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 275)

Add values to for a property of the resource

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

  • return: The number of values added (1 or 0)
  • access: public
integer add (mixed $property, mixed $value, mixed $resource)
  • mixed $resource: The resource to add data to
  • mixed $property: The property name
  • mixed $value: The value for the property
addLiteral (line 293)

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');

  • return: The number of values added
  • access: public
integer 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 308)

Add a resource as a property of the resource

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

  • return: The number of values added (1 or 0)
  • access: public
integer addResource (mixed $property,  $values, mixed $resource2)
  • mixed $property: The property name
  • mixed $resource2: The resource to be value of the property
  • $values
addType (line 567)

Add one or more rdf:type properties to the resource

  • return: The number of types added
  • access: public
integer addType ( $types, string $type)
  • string $type: The new type (e.g. foaf:Person)
  • $types
all (line 396)

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 411)

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 425)

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)
count (line 440)

Count the number of values for a property of a resource

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

  • return: The number of values associated with the property
  • access: public
integer count (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)
delete (line 259)

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 621)

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 212)

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 345)

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 364)

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 111)

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 381)

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 87)

Returns the URI for the resource.

  • return: URI of this resource.
  • access: public
string getUri ()
hasProperty (line 503)

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)
htmlLink (line 175)

Generates an HTML anchor tag, linking to this resource.

If no text is given, then the URI also uses as the link text.

  • return: The HTML link string
  • access: public
string htmlLink ([string $text = NULL], [array $options = array()])
  • string $text: Text for the link.
  • array $options: Associative array of attributes for the anchor tag
isBnode (line 96)

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 556)

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 456)

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 607)

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
load (line 247)

Perform a load (download of remote URI) of the resource into the graph

The document type is optional but should be specified if it can't be guessed or got from the HTTP headers.

  • access: public
void load ([string $format = null])
  • string $format: Optional format of the data (eg. rdfxml)
localName (line 151)

Gets the local name of the URI of this resource

The local name is defined as the part of the URI string after the last occurrence of the '#', ':' or '/' character.

  • return: The local name
  • access: public
string localName ()
parseUri (line 162)

Parse the URI of the resource and return as a ParsedUri object

  • access: public
EasyRdf_ParsedUri parseUri ()
prefix (line 127)

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 592)

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 480)

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 468)

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 490)

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 325)

Set value 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: The number of values added (1 or 0)
  • access: public
integer set (string $property, mixed $value)
  • string $property: The name of the property (e.g. foaf:name)
  • mixed $value: The value for the property.
setType (line 580)

Change the rdf:type property for the resource

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

  • return: The number of types added
  • access: public
integer setType (string $type)
  • string $type: The new type (e.g. foaf:Person)
shorten (line 139)

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 198)

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 531)

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 546)

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 516)

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 221)

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, 16 Jan 2013 19:16:38 +0000 by phpDocumentor 1.4.4