#include <dataquay/PropertyObject.h>
Public Member Functions | |
| PropertyObject (Store *s, QUrl myUri) | |
| Construct a PropertyObject acting on the given Store, with the default prefix for properties taken from the global default (see setDefaultPropertyPrefix) and the given "subject" URI. | |
| PropertyObject (Store *s, QString myUri) | |
| Construct a PropertyObject acting on the given Store, with the default prefix for properties taken from the global default (see setDefaultPropertyPrefix) and the given "subject" URI (which will be prefix expanded). | |
| PropertyObject (Store *s, QString propertyPrefix, QUrl myUri) | |
| Construct a PropertyObject acting on the given Store, with the given default prefix for properties and the given "subject" URI. | |
| PropertyObject (Store *s, QString propertyPrefix, QString myUri) | |
| Construct a PropertyObject acting on the given Store, with the given default prefix for properties and the given "subject" URI (which will be prefix expanded). | |
| bool | hasProperty (QString name) const |
| Return true if the property object has the given property. | |
| bool | hasProperty (Transaction *tx, QString name) const |
| Return true if the property object has the given property, querying through the given transaction. | |
| QVariant | getProperty (QString name) const |
| Get the value of the given property. | |
| QVariant | getProperty (Transaction *tx, QString name) const |
| Get the value of the given property, querying through the given transaction. | |
| void | setProperty (Transaction *tx, QString name, QVariant value) |
| Set the given property to the given value. | |
| void | removeProperty (Transaction *tx, QString name) |
| Remove the given property. | |
| Store * | getStore (Transaction *tx) const |
| Return the Store object that will be used for modifications in the given transaction. | |
| QUrl | getPropertyUri (QString name) const |
| Return the URI used for the "predicate" part of any triple referring to the given property name. | |
Static Public Member Functions | |
| static void | setDefaultPropertyPrefix (QString prefix) |
| Set the global default property prefix. | |
This class provides set and get methods that act directly upon the backing datastore, with (optional but recommended) transaction support. See CacheingPropertyObject for a cacheing alternative.
PropertyObject is constructed using a "property prefix" (a string) and "my URI" (a URI). The URI is used by the property object as the subject for all RDF triples.
All the property handling methods then also take a "property name", which is a string. If this name contains no ':' character, it will be prefixed with the property prefix that was supplied to the PropertyObject constructor before being subjected to prefix expansion in the RDF store. The result is then used as the predicate for the RDF triple. If the name does contain a ':', it is passed for expansion directly (the prefix is not prepended first). As an exception, if the prefix is the special name "a", it will be expanded (by the store) as "rdf:type".
Example: If the property prefix is "myprops" and the property name passed to getProperty is "some_property", the returned value from getProperty will be the result of matching on the triple (myUri, "myprops:some_property", ()). Hopefully, the RDF store will have already been told about the "myprops" prefix and will know how to expand it.
Example: If the property prefix is "myprops" and the property name passed to getProperty is "yourprops:some_property", the returned value from getProperty will be the result of matching on the triple (myUri, "yourprops:some_property", ()). The property prefix is not used at all in this example because the property name contains ':'.
Definition at line 85 of file PropertyObject.h.
| Dataquay::PropertyObject::PropertyObject | ( | Store * | s, | |
| QUrl | myUri | |||
| ) |
Construct a PropertyObject acting on the given Store, with the default prefix for properties taken from the global default (see setDefaultPropertyPrefix) and the given "subject" URI.
Definition at line 44 of file PropertyObject.cpp.
| Dataquay::PropertyObject::PropertyObject | ( | Store * | s, | |
| QString | myUri | |||
| ) |
Construct a PropertyObject acting on the given Store, with the default prefix for properties taken from the global default (see setDefaultPropertyPrefix) and the given "subject" URI (which will be prefix expanded).
Definition at line 49 of file PropertyObject.cpp.
| Dataquay::PropertyObject::PropertyObject | ( | Store * | s, | |
| QString | propertyPrefix, | |||
| QUrl | myUri | |||
| ) |
Construct a PropertyObject acting on the given Store, with the given default prefix for properties and the given "subject" URI.
Definition at line 54 of file PropertyObject.cpp.
| Dataquay::PropertyObject::PropertyObject | ( | Store * | s, | |
| QString | propertyPrefix, | |||
| QString | myUri | |||
| ) |
Construct a PropertyObject acting on the given Store, with the given default prefix for properties and the given "subject" URI (which will be prefix expanded).
Definition at line 59 of file PropertyObject.cpp.
| bool Dataquay::PropertyObject::hasProperty | ( | QString | name | ) | const |
Return true if the property object has the given property.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name.
Definition at line 65 of file PropertyObject.cpp.
References getPropertyUri(), and Dataquay::Store::matchFirst().
Referenced by Dataquay::CacheingPropertyObject::hasProperty().
| bool Dataquay::PropertyObject::hasProperty | ( | Transaction * | tx, | |
| QString | name | |||
| ) | const |
Return true if the property object has the given property, querying through the given transaction.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name.
Definition at line 73 of file PropertyObject.cpp.
References getPropertyUri(), getStore(), and Dataquay::Store::matchFirst().
| QVariant Dataquay::PropertyObject::getProperty | ( | QString | name | ) | const |
Get the value of the given property.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name, convert the object part of the first such matching triple to a QVariant via Node::toVariant and return that value. If there is no such match, return QVariant().
Definition at line 82 of file PropertyObject.cpp.
References Dataquay::Triple::c, getPropertyUri(), Dataquay::Store::matchFirst(), and Dataquay::Node::toVariant().
Referenced by Dataquay::CacheingPropertyObject::getProperty().
| QVariant Dataquay::PropertyObject::getProperty | ( | Transaction * | tx, | |
| QString | name | |||
| ) | const |
Get the value of the given property, querying through the given transaction.
That is, if the store contains at least one triple whose subject and predicate match those for my URI and the expansion of the given property name, convert the object part of the first such matching triple to a QVariant via Node::toVariant and return that value. If there is no such match, return QVariant().
Definition at line 91 of file PropertyObject.cpp.
References Dataquay::Triple::c, getPropertyUri(), getStore(), Dataquay::Store::matchFirst(), and Dataquay::Node::toVariant().
| void Dataquay::PropertyObject::setProperty | ( | Transaction * | tx, | |
| QString | name, | |||
| QVariant | value | |||
| ) |
Set the given property to the given value.
That is, first remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name, then insert a new triple whose object part is the result of converting the given variant to a node via Node::fromVariant.
Definition at line 101 of file PropertyObject.cpp.
References Dataquay::Store::add(), Dataquay::Triple::c, Dataquay::Node::fromVariant(), getPropertyUri(), getStore(), and Dataquay::Store::remove().
Referenced by Dataquay::CacheingPropertyObject::setProperty().
| void Dataquay::PropertyObject::removeProperty | ( | Transaction * | tx, | |
| QString | name | |||
| ) |
Remove the given property.
That is, remove from the store any triples whose subject and predicate match those for my URI and the expansion of the given property name.
Definition at line 112 of file PropertyObject.cpp.
References getPropertyUri(), getStore(), and Dataquay::Store::remove().
Referenced by Dataquay::CacheingPropertyObject::removeProperty().
| Store * Dataquay::PropertyObject::getStore | ( | Transaction * | tx | ) | const |
Return the Store object that will be used for modifications in the given transaction.
If the transaction is not NoTransaction, then the returned Store will simply be the transaction itself; otherwise it will be the store that was passed to the constructor.
Definition at line 121 of file PropertyObject.cpp.
References Dataquay::NoTransaction.
Referenced by getProperty(), Dataquay::CacheingPropertyObject::getStore(), hasProperty(), removeProperty(), and setProperty().
| QUrl Dataquay::PropertyObject::getPropertyUri | ( | QString | name | ) | const |
Return the URI used for the "predicate" part of any triple referring to the given property name.
See the general PropertyObject documentation for details of how these names are expanded.
Definition at line 128 of file PropertyObject.cpp.
References Dataquay::Store::expand().
Referenced by getProperty(), Dataquay::CacheingPropertyObject::getPropertyUri(), hasProperty(), removeProperty(), and setProperty().
| void Dataquay::PropertyObject::setDefaultPropertyPrefix | ( | QString | prefix | ) | [static] |
Set the global default property prefix.
This will be used as the prefix for all PropertyObjects subsequently constructed using the two-argument (prefixless) constructors.
Definition at line 136 of file PropertyObject.cpp.
1.5.7.1