Class EasyRdf_Graph

Description

Container for collection of EasyRdf_Resources.

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


	
			
Method Summary
static object EasyRdf_Graph newAndLoad (string $uri, [string $format = null])
object EasyRdf_Graph __construct ([string $uri = null], [string $data = null], [string $format = null])
integer add (mixed $resource, mixed $property, mixed $value)
integer addLiteral (mixed $resource, mixed $property, mixed $value, [string $lang = null])
integer addResource (mixed $resource, mixed $property, mixed $resource2)
integer addType (string $resource,  $types, string $type)
array all (string $resource, string $propertyPath, [string $type = null], [string $lang = null])
array allLiterals (string $resource, string $property, [string $lang = null])
array allOfType (string $type)
array allResources (string $resource, string $property)
integer count (string $resource, string $property, [string $type = null], [string $lang = null])
integer countTriples ()
integer delete ( $resource, string $property, [object $value = null])
void deleteLiteral (mixed $resource, mixed $property, mixed $value, [string $lang = null])
void deleteResource (mixed $resource, mixed $property, mixed $resource2)
string dump ([boolean $html = true])
string dumpResource ( $resource, [boolean $html = true])
mixed get (string $resource, string $propertyPath, [string $type = null], [string $lang = null])
object EasyRdf_Literal getLiteral (string $resource, string|array $property, [string $lang = null])
object EasyRdf_Resource getResource (string $resource, string|array $property)
string getUri ()
boolean hasProperty ( $resource, string $property)
boolean isEmpty ()
boolean is_a ( $resource, string $type)
string join ( $resource, string $property, [string $glue = ' '], [string $lang = null])
string label ([ $resource = null], [ $lang = null])
integer load ([string $uri = null], [string $format = null])
object EasyRdf_Resource newBNode ([mixed $types = array()])
string newBNodeId ()
integer parse (string $data, [string $format = null], [string $uri = null])
integer parseFile (string $filename, [string $format = null], [string $uri = null])
EasyRdf_Resource primaryTopic ([ $resource = null])
array properties ( $resource)
array propertyUris ( $resource)
object EasyRdf_Resource resource ([string $uri = null], [mixed $types = array()])
array resources ()
array resourcesMatching (string $property, [mixed $value = null])
array reversePropertyUris ( $resource)
mixed serialise (mixed $format)
integer set (string $resource, string $property, mixed $value)
integer setType (string $resource, string $type)
array toArray ()
string type ([ $resource = null])
object EasyRdf_Resource typeAsResource ([ $resource = null])
array types ([ $resource = null])
string __toString ()
Methods
static method newAndLoad (line 109)

Create a new graph and load RDF data from a URI into it

This static function is shorthand for: $graph = new EasyRdf_Graph($uri); $graph->load($uri, $format);

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

  • return: The new the graph object
  • access: public
static object EasyRdf_Graph newAndLoad (string $uri, [string $format = null])
  • string $uri: The URI of the data to load
  • string $format: Optional format of the data (eg. rdfxml)
Constructor __construct (line 83)

Constructor

If no URI is given then an unnamed graph is created.

The $data parameter is optional and will be parsed into the graph if given.

The data format is optional and should be specified if it can't be guessed by EasyRdf.

  • access: public
object EasyRdf_Graph __construct ([string $uri = null], [string $data = null], [string $format = null])
  • string $uri: The URI of the graph
  • string $data: Data for the graph
  • string $format: The document type of the data (e.g. rdfxml)
add (line 892)

Add data to the graph

The resource can either be a resource or the URI of a resource.

Example: $graph->add("http://www.example.com", 'dc:title', 'Title of Page');

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

Add a literal value as a property of a resource

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

Example: $graph->add("http://www.example.com", 'dc:title', 'Title of Page');

  • return: The number of values added
  • access: public
integer addLiteral (mixed $resource, mixed $property, mixed $value, [string $lang = null])
  • mixed $resource: The resource to add data to
  • mixed $property: The property name
  • mixed $value: The value or values for the property
  • string $lang: The language of the literal
addResource (line 981)

Add a resource as a property of another resource

The resource can either be a resource or the URI of a resource.

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

  • return: The number of values added
  • access: public
integer addResource (mixed $resource, mixed $property, mixed $resource2)
  • mixed $resource: The resource to add data to
  • mixed $property: The property name
  • mixed $resource2: The resource to be value of the property
addType (line 1401)

Add one or more rdf:type properties to a resource

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

Get all values for a property path

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 $resource, string $propertyPath, [string $type = null], [string $lang = null])
  • string $resource: The URI of the resource (e.g. http://example.com/joe#me)
  • string $propertyPath: A valid property path
  • string $type: The type of value to filter by (e.g. literal)
  • string $lang: The language to filter by (e.g. en)
allLiterals (line 820)

Get all literal values for a property of a 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 $resource, string $property, [string $lang = null])
  • string $resource: The URI of the resource (e.g. http://example.com/joe#me)
  • string $property: The name of the property (e.g. foaf:name)
  • string $lang: The language to filter by (e.g. en)
allOfType (line 847)

Get all the resources in the graph of a certain type

If no resources of the type are available and empty array is returned.

  • return: The array of resources
  • access: public
array allOfType (string $type)
  • string $type: The type of the resource (e.g. foaf:Person)
allResources (line 834)

Get all resources for a property of a 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 $resource, string $property)
  • string $resource: The URI of the resource (e.g. http://example.com/joe#me)
  • string $property: The name of the property (e.g. foaf:name)
count (line 860)

Count all values for a property of a resource

  • return: The number of values for this property
  • access: public
integer count (string $resource, string $property, [string $type = null], [string $lang = null])
  • string $resource: The URI of the resource (e.g. http://example.com/joe#me)
  • 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)
countTriples (line 1489)

Calculates the number of triples in the graph

  • return: The number of triples in the graph.
  • access: public
integer countTriples ()
delete (line 1023)

Delete a property (or optionally just a specific value)

  • return: The number of values deleted
  • access: public
integer delete ( $resource, 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)
  • $resource
deleteLiteral (line 1089)

Delete a literal value from a property of a resource

Example: $graph->delete("http://www.example.com", 'dc:title', 'Title of Page');

  • access: public
void deleteLiteral (mixed $resource, mixed $property, mixed $value, [string $lang = null])
  • mixed $resource: The resource to add data to
  • mixed $property: The property name
  • mixed $value: The value of the property
  • string $lang: The language of the literal
deleteResource (line 1065)

Delete a resource from a property of another resource

The resource can either be a resource or the URI of a resource.

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

  • access: public
void deleteResource (mixed $resource, mixed $property, mixed $resource2)
  • mixed $resource: The resource to delete data from
  • mixed $property: The property name
  • mixed $resource2: The resource value of the property to be deleted
dump (line 1237)

Return a human readable view of all the resources in the graph

This method is intended to be a debugging aid and will return a pretty-print view of all the resources and their properties.

  • access: public
string dump ([boolean $html = true])
  • boolean $html: Set to true to format the dump using HTML
dumpResource (line 1262)

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 dumpResource ( $resource, [boolean $html = true])
  • boolean $html: Set to true to format the dump using HTML
  • $resource
get (line 557)

Get a single value for a property of a resource

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 $resource, string $propertyPath, [string $type = null], [string $lang = null])
  • string $resource: The URI of the resource (e.g. http://example.com/joe#me)
  • string $propertyPath: A valid property path
  • string $type: The type of value to filter by (e.g. literal or resource)
  • string $lang: The language to filter by (e.g. en)
getLiteral (line 654)

Get a single literal value for a property of a 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 $resource, string|array $property, [string $lang = null])
  • 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)
getResource (line 671)

Get a single resource value for a property of a 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 $resource, string|array $property)
  • 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)
getUri (line 403)

Get the URI of the graph

  • return: The URI of the graph
  • access: public
string getUri ()
hasProperty (line 1192)

Check to see if a property exists for a resource.

This method will return true if the property exists.

  • return: True if value the property exists.
  • access: public
boolean hasProperty ( $resource, string $property)
  • string $property: The name of the property (e.g. foaf:gender)
  • $resource
isEmpty (line 1127)

Check if the graph contains any statements

  • return: True if the graph contains no statements
  • access: public
boolean isEmpty ()
is_a (line 1382)

Check if a resource is of the specified type

  • return: True if resource is of specified type.
  • access: public
boolean is_a ( $resource, string $type)
  • string $type: The type to check (e.g. foaf:Person)
  • $resource
join (line 875)

Concatenate all values for a property of a resource 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 ( $resource, 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)
  • $resource
label (line 1443)

Get a human readable label for a resource

This method will check a number of properties for a 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 ([ $resource = null], [ $lang = null])
  • $resource
  • $lang
load (line 263)

Load RDF data into the graph from a URI.

If no URI is given, then the URI of the graph will be used.

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

  • return: The number of triples added to the graph
  • access: public
integer load ([string $uri = null], [string $format = null])
  • string $uri: The URI of the data to load
  • string $format: Optional format of the data (eg. rdfxml)
newBNode (line 187)

Create a new blank node in the graph and return it.

If you provide an RDF type and that type is registered with the EasyRdf_TypeMapper, then the resource will be an instance of the class registered.

  • return: The new blank node
  • access: public
object EasyRdf_Resource newBNode ([mixed $types = array()])
  • mixed $types: RDF type of a new blank node (e.g. foaf:Person)
newBNodeId (line 197)

Create a new unique blank node identifier and return it.

  • return: The new blank node identifier (e.g. _:genid1)
  • access: public
string newBNodeId ()
parse (line 210)

Parse some RDF data into the graph object.

  • return: The number of triples added to the graph
  • access: public
integer parse (string $data, [string $format = null], [string $uri = null])
  • string $data: Data to parse for the graph
  • string $format: Optional format of the data
  • string $uri: The URI of the data to load
parseFile (line 238)

Parse a file containing RDF data into the graph object.

  • return: The number of triples added to the graph
  • access: public
integer parseFile (string $filename, [string $format = null], [string $uri = null])
  • string $filename: The path of the file to load
  • string $format: Optional format of the file
  • string $uri: The URI of the file to load
primaryTopic (line 1463)

Get the primary topic of the graph

  • return: The primary topic of the document.
  • access: public
EasyRdf_Resource primaryTopic ([ $resource = null])
  • $resource
properties (line 1138)

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 ( $resource)
  • $resource
propertyUris (line 1159)

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

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

  • return: Array of full URIs
  • access: public
array propertyUris ( $resource)
  • $resource
resource (line 129)

Get or create a resource stored in a graph

If the resource did not previously exist, then a new resource will be created. If you provide an RDF type and that type is registered with the EasyRdf_TypeMapper, then the resource will be an instance of the class registered.

If URI is null, then the URI of the graph is used.

  • access: public
object EasyRdf_Resource resource ([string $uri = null], [mixed $types = array()])
  • string $uri: The URI of the resource
  • mixed $types: RDF type of a new resource (e.g. foaf:Person)
resources (line 338)

Get an associative array of all the resources stored in the graph.

The keys of the array is the URI of the EasyRdf_Resource.

  • return: Array of EasyRdf_Resource
  • access: public
array resources ()
resourcesMatching (line 369)

Get an arry of resources matching a certain property and optional value.

For example this routine could be used as a way of getting everyone who has name: $people = $graph->resourcesMatching('foaf:name')

Or everyone who is male: $people = $graph->resourcesMatching('foaf:gender', 'male');

Or all homepages: $people = $graph->resourcesMatching('^foaf:homepage');

  • return: Array of EasyRdf_Resource
  • access: public
array resourcesMatching (string $property, [mixed $value = null])
  • string $property: The property to check.
  • mixed $value: Optional, the value of the propery to check for.
reversePropertyUris (line 1174)

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

  • return: Array of full property URIs
  • access: public
array reversePropertyUris ( $resource)
  • $resource
serialise (line 1219)

Serialise the graph into RDF

The $format parameter can be an EasyRdf_Format object, a format name, a mime type or a file extension.

Example: $turtle = $graph->serialise('turtle');

  • return: The serialised graph
  • access: public
mixed serialise (mixed $format)
  • mixed $format: The format to serialise to
set (line 1004)

Set a value for a property

The new value will replace the existing values for the property.

  • return: The number of values added (1 or 0)
  • access: public
integer set (string $resource, string $property, mixed $value)
  • string $resource: The resource to set the property on
  • string $property: The name of the property (e.g. foaf:name)
  • mixed $value: The value for the property
setType (line 1426)

Change the rdf:type property for a resource

Note that if the resource object has already previously been created, then the PHP class of the resource will not change.

  • return: The number of types added
  • access: public
integer setType (string $resource, string $type)
  • string $resource: The resource to change the type of
  • string $type: The new type (e.g. foaf:Person)
toArray (line 1480)

Returns the graph as a RDF/PHP associative array

  • return: The contents of the graph as an array.
  • access: public
array toArray ()
type (line 1322)

Get the resource type of the graph

The type will be a shortened URI as a string. If the graph 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:Document)
  • access: public
string type ([ $resource = null])
  • $resource
typeAsResource (line 1343)

Get the resource type of the graph as a EasyRdf_Resource

If the graph 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
object EasyRdf_Resource typeAsResource ([ $resource = null])
  • $resource
types (line 1363)

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.

If $resource is null, then it will get the types for the URI of the graph.

  • return: All types assocated with the resource (e.g. foaf:Person)
  • access: public
array types ([ $resource = null])
  • $resource
__toString (line 1504)

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:37 +0000 by phpDocumentor 1.4.4