class EasyRdf_Container extends EasyRdf_Resource implements ArrayAccess, Countable, SeekableIterator
Sub-class of EasyRdf_Resource that represents an RDF container (rdf:Alt, rdf:Bag and rdf:Seq)
This class can be used to iterate through a list of items.
Methods
__construct($uri, $graph)
Create a new container - do not use this directly |
||
EasyRdf_Graph |
getGraph()
Return the graph that this resource belongs to |
from EasyRdf_Resource |
string |
getUri()
Returns the URI for the resource. |
from EasyRdf_Resource |
bool |
isBNode()
Check to see if a resource is a blank node. |
from EasyRdf_Resource |
string |
getBNodeId()
Get the identifier for a blank node |
from EasyRdf_Resource |
string |
prefix()
Get a the prefix of the namespace that this resource is part of |
from EasyRdf_Resource |
string |
shorten()
Get a shortened version of the resources URI. |
from EasyRdf_Resource |
string |
localName()
Gets the local name of the URI of this resource |
from EasyRdf_Resource |
EasyRdf_ParsedUri |
parseUri()
Parse the URI of the resource and return as a ParsedUri object |
from EasyRdf_Resource |
string |
htmlLink(string $text = null, array $options = array())
Generates an HTML anchor tag, linking to this resource. |
from EasyRdf_Resource |
array |
toRdfPhp()
Returns the properties of the resource as an RDF/PHP associative array |
from EasyRdf_Resource |
string |
dumpValue(string $format = 'html', string $color = 'blue')
Return pretty-print view of the resource |
from EasyRdf_Resource |
string |
__toString()
Magic method to return URI of resource when casted to string |
from EasyRdf_Resource |
load(string $format = null)
Perform a load (download of remote URI) of the resource into the graph |
from EasyRdf_Resource | |
null |
delete(string $property, object $value = null)
Delete a property (or optionally just a specific value) |
from EasyRdf_Resource |
integer |
add(mixed $property, mixed $value)
Add values to for a property of the resource |
from EasyRdf_Resource |
integer |
addLiteral(mixed $property, mixed $values, string $lang = null)
Add a literal value as a property of the resource |
from EasyRdf_Resource |
integer |
addResource(mixed $property, mixed $resource2)
Add a resource as a property of the resource |
from EasyRdf_Resource |
integer |
set(string $property, mixed $value)
Set value for a property |
from EasyRdf_Resource |
mixed |
get(string|array $property, string $type = null, string $lang = null)
Get a single value for a property |
from EasyRdf_Resource |
object |
getLiteral(string|array $property, string $lang = null)
Get a single literal value for a property of the resource |
from EasyRdf_Resource |
object |
getResource(string|array $property)
Get a single resource value for a property of the resource |
from EasyRdf_Resource |
array |
all(string $property, string $type = null, string $lang = null)
Get all values for a property |
from EasyRdf_Resource |
array |
allLiterals(string $property, string $lang = null)
Get all literal values for a property of the resource |
from EasyRdf_Resource |
array |
allResources(string $property)
Get all resources for a property of the resource |
from EasyRdf_Resource |
integer |
countValues(string $property, string $type = null, string $lang = null)
Count the number of values for a property of a resource |
from EasyRdf_Resource |
string |
join(string $property, string $glue = ' ', string $lang = null)
Concatenate all values for a property into a string. |
from EasyRdf_Resource |
array |
propertyUris()
Get a list of the full URIs for the properties of this resource. |
from EasyRdf_Resource |
array |
properties()
Get a list of all the shortened property names (qnames) for a resource. |
from EasyRdf_Resource |
array |
reversePropertyUris()
Get a list of the full URIs for the properties that point to this resource. |
from EasyRdf_Resource |
bool |
hasProperty(string $property, mixed $value = null)
Check to see if a property exists for this resource. |
from EasyRdf_Resource |
array |
types()
Get a list of types for a resource. |
from EasyRdf_Resource |
string |
type()
Get a single type for a resource. |
from EasyRdf_Resource |
EasyRdf_Resource |
typeAsResource()
Get a single type for a resource, as a resource. |
from EasyRdf_Resource |
EasyRdf_Resource[] |
typesAsResources()
Get a list of types for a resource, as Resources. |
from EasyRdf_Resource |
boolean |
isA(string $type)
Check if a resource is of the specified type |
from EasyRdf_Resource |
integer |
addType(string $types)
Add one or more rdf:type properties to the resource |
from EasyRdf_Resource |
integer |
setType(string $type)
Change the rdf:type property for the resource |
from EasyRdf_Resource |
EasyRdf_Resource |
primaryTopic()
Get the primary topic of this resource. |
from EasyRdf_Resource |
string |
label($lang = null)
Get a human readable label for this resource |
from EasyRdf_Resource |
string |
dump(string $format = 'html')
Return a human readable view of the resource and its properties |
from EasyRdf_Resource |
string |
__get(string $name)
Magic method to get a property of a resource |
from EasyRdf_Resource |
__set(string $name, string $value)
Magic method to set the value for a property of a resource |
from EasyRdf_Resource | |
__isset(string $name)
Magic method to check if a property exists |
from EasyRdf_Resource | |
__unset(string $name)
Magic method to delete a property of the resource |
from EasyRdf_Resource | |
seek(integer $position)
Seek to a specific position in the container |
||
rewind()
Rewind the iterator back to the start of the container (item 1) |
||
mixed |
current()
Return the current item in the container |
|
int |
key()
Return the key / current position in the container |
|
next()
Move forward to next item in the container |
||
bool |
valid()
Checks if current position is valid |
|
integer |
count()
Counts the number of items in the container |
|
integer |
append(mixed $value)
Append an item to the end of the container |
|
offsetExists($offset)
Array Access: check if a position exists in container using array syntax |
||
offsetGet($offset)
Array Access: get an item at a specified position in container using array syntax |
||
offsetSet($offset, $value)
Array Access: set an item at a positon in container using array syntax |
||
offsetUnset($offset)
Array Access: delete an item at a specific postion using array syntax |
Details
at line 57
public
__construct($uri, $graph)
Create a new container - do not use this directly
in EasyRdf_Resource at line 87
public EasyRdf_Graph
getGraph()
Return the graph that this resource belongs to
in EasyRdf_Resource at line 96
public string
getUri()
Returns the URI for the resource.
in EasyRdf_Resource at line 105
public bool
isBNode()
Check to see if a resource is a blank node.
in EasyRdf_Resource at line 120
public string
getBNodeId()
Get the identifier for a blank node
Returns null if the resource is not a blank node.
in EasyRdf_Resource at line 136
public string
prefix()
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.
in EasyRdf_Resource at line 148
public string
shorten()
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.
in EasyRdf_Resource at line 160
public string
localName()
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.
in EasyRdf_Resource at line 171
public EasyRdf_ParsedUri
parseUri()
Parse the URI of the resource and return as a ParsedUri object
in EasyRdf_Resource at line 184
public string
htmlLink(string $text = null, array $options = array())
Generates an HTML anchor tag, linking to this resource.
If no text is given, then the URI also uses as the link text.
in EasyRdf_Resource at line 214
public array
toRdfPhp()
Returns the properties of the resource as an RDF/PHP associative array
For example: array('type' => 'uri', 'value' => 'http://www.example.com/')
in EasyRdf_Resource at line 229
public string
dumpValue(string $format = 'html', string $color = 'blue')
Return pretty-print view of the resource
in EasyRdf_Resource at line 238
public string
__toString()
Magic method to return URI of resource when casted to string
in EasyRdf_Resource at line 264
public
load(string $format = null)
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.
in EasyRdf_Resource at line 276
public null
delete(string $property, object $value = null)
Delete a property (or optionally just a specific value)
in EasyRdf_Resource at line 291
public integer
add(mixed $property, mixed $value)
Add values to for a property of the resource
Example: $resource->add('prefix:property', 'value');
in EasyRdf_Resource at line 309
public integer
addLiteral(mixed $property, mixed $values, string $lang = null)
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');
in EasyRdf_Resource at line 324
public integer
addResource(mixed $property, mixed $resource2)
Add a resource as a property of the resource
Example: $bob->add('foaf:knows', 'http://example.com/alice');
in EasyRdf_Resource at line 341
public integer
set(string $property, mixed $value)
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.
in EasyRdf_Resource at line 362
public mixed
get(string|array $property, string $type = null, string $lang = null)
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.
in EasyRdf_Resource at line 380
public object
getLiteral(string|array $property, string $lang = null)
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.
in EasyRdf_Resource at line 397
public object
getResource(string|array $property)
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.
in EasyRdf_Resource at line 412
public array
all(string $property, string $type = null, string $lang = null)
Get all values for a property
This method will return an empty array if the property does not exist.
in EasyRdf_Resource at line 427
public array
allLiterals(string $property, string $lang = null)
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.
in EasyRdf_Resource at line 441
public array
allResources(string $property)
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.
in EasyRdf_Resource at line 456
public integer
countValues(string $property, string $type = null, string $lang = null)
Count the number of values for a property of a resource
This method will return 0 if the property does not exist.
in EasyRdf_Resource at line 472
public string
join(string $property, string $glue = ' ', string $lang = null)
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.
in EasyRdf_Resource at line 484
public array
propertyUris()
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.
in EasyRdf_Resource at line 496
public array
properties()
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.
in EasyRdf_Resource at line 506
public array
reversePropertyUris()
Get a list of the full URIs for the properties that point to this resource.
in EasyRdf_Resource at line 522
public bool
hasProperty(string $property, mixed $value = null)
Check to see if a property exists for this resource.
This method will return true if the property exists. If the value parameter is given, then it will only return true if the value also exists for that property.
in EasyRdf_Resource at line 535
public array
types()
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.
in EasyRdf_Resource at line 550
public string
type()
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.
in EasyRdf_Resource at line 565
public EasyRdf_Resource
typeAsResource()
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.
in EasyRdf_Resource at line 577
public EasyRdf_Resource[]
typesAsResources()
Get a list of types for a resource, as Resources.
in EasyRdf_Resource at line 588
public boolean
isA(string $type)
Check if a resource is of the specified type
in EasyRdf_Resource at line 599
public integer
addType(string $types)
Add one or more rdf:type properties to the resource
in EasyRdf_Resource at line 612
public integer
setType(string $type)
Change the rdf:type property for the resource
Note that the PHP class of the resource will not change.
in EasyRdf_Resource at line 624
public EasyRdf_Resource
primaryTopic()
Get the primary topic of this resource.
Returns null if no primary topic is available.
in EasyRdf_Resource at line 639
public string
label($lang = null)
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.
in EasyRdf_Resource at line 653
public string
dump(string $format = 'html')
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.
in EasyRdf_Resource at line 670
public string
__get(string $name)
Magic method to get a property of a resource
Note that only properties in the default namespace can be accessed in this way.
Example: $value = $resource->title;
in EasyRdf_Resource at line 686
public
__set(string $name, string $value)
Magic method to set the value for a property of a resource
Note that only properties in the default namespace can be accessed in this way.
Example: $resource->title = 'Title';
in EasyRdf_Resource at line 701
public
__isset(string $name)
Magic method to check if a property exists
Note that only properties in the default namespace can be accessed in this way.
Example: if (isset($resource->title)) { blah(); }
in EasyRdf_Resource at line 716
public
__unset(string $name)
Magic method to delete a property of the resource
Note that only properties in the default namespace can be accessed in this way.
Example: unset($resource->title);
at line 70
public
seek(integer $position)
Seek to a specific position in the container
The first item is postion 1
at line 90
public
rewind()
Rewind the iterator back to the start of the container (item 1)
at line 99
public mixed
current()
Return the current item in the container
at line 108
public int
key()
Return the key / current position in the container
at line 116
public
next()
Move forward to next item in the container
at line 125
public bool
valid()
Checks if current position is valid
at line 137
public integer
count()
Counts the number of items in the container
Note that this is an slow method - it is more efficient to use the iterator interface, if you can.
at line 151
public integer
append(mixed $value)
Append an item to the end of the container
at line 167
public
offsetExists($offset)
Array Access: check if a position exists in container using array syntax
Example: isset($seq[2])
at line 182
public
offsetGet($offset)
Array Access: get an item at a specified position in container using array syntax
Example: $item = $seq[2];
at line 200
public
offsetSet($offset, $value)
Array Access: set an item at a positon in container using array syntax
Example: $seq[2] = $item;
Warning: creating gaps in the sequence will result in unexpected behavior
at line 220
public
offsetUnset($offset)
Array Access: delete an item at a specific postion using array syntax
Example: unset($seq[2]);
Warning: creating gaps in the sequence will result in unexpected behavior