Serializer Class Reference
from PyKDE4.soprano import *
Inherits: Soprano.Plugin,Soprano::Error::ErrorCache
Namespace: Soprano
Detailed Description
- Abstract class:
- This class can be used as a base class for new classes, but can not be instantiated directly.
\class Serializer serializer.h Soprano/Serializer
Soprano.Serializer defines the interface for a Soprano RDF serializer plugin.
Each serializer plugin may support multiple RDF serializations (supportedSerializations()).
Usage
Using a Serializer is straightforward. One starts by getting a plugin that supports the requested RDF data serialization:
Soprano.Serializer* s = Soprano.PluginManager.instance()->discoverSerializerForSerialization( Soprano.SerializationRdfXml );
Then serializing RDF data is done in a single method call which writes the serialized data to a QTextStream:
QTextStream stream( stdout ); s->serialize( model->listStatements(), stream, Soprano.SerializationRdfXml );
\sa soprano_writing_plugins
Methods | |
__init__ (self, QString name) | |
bool | serialize (self, Soprano.StatementIterator it, QTextStream stream, Soprano.RdfSerialization serialization, QString userSerialization=QString()) |
Soprano.RdfSerializations | supportedSerializations (self) |
QStringList | supportedUserSerializations (self) |
bool | supportsSerialization (self, Soprano.RdfSerialization s, QString userSerialization=QString()) |
Method Documentation
__init__ | ( | self, | ||
QString | name | |||
) |
bool serialize | ( | self, | ||
Soprano.StatementIterator | it, | |||
QTextStream | stream, | |||
Soprano.RdfSerialization | serialization, | |||
QString | userSerialization=QString() | |||
) |
- Abstract method:
- This method is abstract and can be overridden but not called directly.
Serialize a list of statements.
- Parameters:
-
it An iterator containing the statements to be serialized.
- Parameters:
-
stream The stream the serialized data should be written to.
- Parameters:
-
serialization The encoding to be used.
- Parameters:
-
userSerialization If serialization is set to Soprano.SerializationUser this parameter specifies the serialization to use. It allows the extension of the %Soprano Serializer interface with new RDF serializations that are not officially supported by %Soprano.
- Returns:
- true if the %serialization was successful, false otherwise.
Soprano.RdfSerializations supportedSerializations | ( | self ) |
- Abstract method:
- This method is abstract and can be overridden but not called directly.
The serialiazation types supported by this serializer.
- Returns:
- A combination of Soprano.RdfSerialization types. If the list contains Soprano.SerializationUser the serializer supports additional RDF serialiazations not officially supported by %Soprano.
QStringList supportedUserSerializations | ( | self ) |
A serializer can support additional RDF serializations that are not defined in Soprano.RdfSerialization. In that case supportedSerializations() has to include Soprano.SerializationUser.
The default implementation returns an empty list.
- Returns:
- A list of supported user RDF serializations.
bool supportsSerialization | ( | self, | ||
Soprano.RdfSerialization | s, | |||
QString | userSerialization=QString() | |||
) |
Check if a plugin supports a specific serialization.
- Parameters:
-
s The requested serialization.
- Parameters:
-
userSerialization If serialization is set to Soprano.SerializationUser this parameter specifies the requested serialization. It allows the extension of the %Soprano Serializer interface with new RDF serializations that are not officially supported by %Soprano.
- Returns:
- true if the serializer is able to parse RDF data encoded in serialization s, false otherwise.