RDF Core Library 1.1.7

Delphi 2009 Implementation

Dieter Köhler

LICENSE

The contents of the Extended Document Object Model files are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this files except in compliance with the License. You may obtain a copy of the License at "http://www.mozilla.org/MPL/"

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.

The Original Code is "Rdf_1_1.pas".

The Initial Developer of the Original Code is Dieter Köhler (Heidelberg, Germany, "http://www.philo.de/"). Portions created by the Initial Developer are Copyright (C) 2003-2010 Dieter Köhler. All Rights Reserved.

Alternatively, the contents of this files may be used under the terms of the GNU General Public License Version 2 or later (the "GPL"), in which case the provisions of the GPL are applicable instead of those above. If you wish to allow use of your version of this files only under the terms of the GPL, and not to allow others to use your version of this files under the terms of the MPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL. If you do not delete the provisions above, a recipient may use your version of this file under the terms of any one of the MPL or the GPL.

2010


Table of Contents

Introduction
Exception Classes
ERdfException
General Classes and Constants
TRdfReferenceType
TRdfStmtAttr
TRdfStmtAttrs
TRdfSortType
UTF8String
Event Prototypes
TRdfFilterStatementEvent
TRdfFilterStringEvent
TRdfStringEvent
RDF Statement Maintenance
TRdfStatement = class(TPersistent)
Filter Classes
TRdfCustomFilter = class
TRdfUriFilter = class(TRdfCustomFilter)
TRdfObjectFilter = class(TRdfCustomFilter)
TRdfStatementFilter = class(TPersistent)
RDF Graph Classes
TRdfGraph = class(TUtilsCustomObjectIteratorList)
TRdfCustomFilteredGraph = class(TRdfGraph)
TRdfFilteredGraph = class(TRdfCustomFilteredGraph)
TRdfCustomDetailGraph = class(TRdfCustomFilteredGraph)
TRdfDetailGraph = class(TRdfCustomDetailGraph)
TRdfCustomRestricterGraph = class(TRdfCustomDetailGraph)
TRdfRestricterGraph = class(TRdfCustomRestricterGraph)
RDF Iterator Classes
TRdfGraphIterator = class(TUtilsCustomIterator)
TRdfIteratorAdapter = class(TUtilsIteratorAdapter)
RDF List Classes
TRdfCustomGraphList = class(TUtilsCustomAliasedStrings)
TRdfGraphList = class(TRdfCustomGraphList)
TRdfResourceList = class(TRdfCustomGraphList)
RDF Alias Classes
TRdfAliases = class(TUtilsCustomIteratorAliases)

Introduction

The RDF Core Library is under permanent development. The latest version of this Software can be obtained via the Open RDF web-site at "http://www.philo.de/rdf/". The preferred way to contact the author is via the Open RDF mailing list. Instructions how to join the mailing list can be found at "http://www.philo.de/rdf/" as well.

Exception Classes

ERdfException

ERdfException = class(Exception);

This is the fundamental class of all RDF specific exceptions.

General Classes and Constants

TRdfReferenceType

TRdfReferenceType = (rtNone, rtGlobal, rtLocal);

Constants internally used in TRdfGraph.

TRdfStmtAttr

TRdfStmtAttr = (saSubject, saPredicate, saObject,
                  saObjectLexical, saObjectLanguage, saObjectDatatype);

Constants used to distinguish between different elements of an RDF statement.

TRdfStmtAttrs

TRdfStmtAttrs = set of TRdfStmtAttr;

A set of TRdfStmtAttrs constants.

TRdfSortType

TRdfSortType = (stNone, stSPO, stSOP, stPSO, stPOS, stOSP, stOPS);

Constants used to specify the order of the statement in an RDF graph. 'S' means 'Subject', 'P' means 'Predicate', and 'O' means 'Object'. So for example the sort type stPSO specifies that the statements are ordered first according to their predicates, statements with the same predicate are then ordered according to their subjects, and statements with both, equivalent predicate and subject, are order according to their objects.

UTF8String

UTF8String = string;

Defines a specialized class for UTF-8 encoded strings.

Event Prototypes

TRdfFilterStatementEvent

TRdfFilterStatementEvent = procedure(Sender: TObject; RdfSubject,
    RdfPredicate, RdfObject, RdfObjectLexical, RdfObjectLanguage,
    RdfObjectDatatype: UTF8String; var Accept: Boolean) of object;

TRdfFilterStringEvent

TRdfFilterStringEvent = procedure(Sender: TObject; var S: string;
    var Accept: Boolean) of object;

TRdfStringEvent

TRdfStringEvent = procedure(Sender: TObject; var S: string) of object;

RDF Statement Maintenance

TRdfStatement = class(TPersistent)

TRdfStatement represents a single RDF statement

Public Properties

property Object_Datatype: UTF8String (readonly)

The datatype of the object if this statement has a literal object, or an empty string otherwise.

property Object_Language: UTF8String (readonly)

The language of the object if this statement has a literal object, or an empty string otherwise.

property Object_Lexical: UTF8String (readonly)

The lexical of the object if this statement has a literal object, or an empty string otherwise.

property Object_Reference: UTF8String (readonly)

The object URI of this statement, or an empty string if this statement has a literal object.

property Owner: TObject (readonly)

The owner object (typically a TRdfGraph object) of this TRdfStatement object.

property Predicate_Reference: UTF8String (readonly)

The predicate URI of this statement.

property Subject_Reference: UTF8String (readonly)

The subject URI of this statement.

Public Methods

constructor Create(AOwner: TObject;
                   ASubject_Reference,
                   APredicate_Reference,
                   AObject_Reference,
                   AObject_Lexical,
                   AObject_Language,
                   AObject_Datatype: UTF8String);

Creates a new TRdfStatement statement.

AOwner specifies the owner object which is responsible for freeing this TRdfStatement object. The other parameters specify the properties of the RDF statement (for details see the description of the public properties).

procedure Assign(Source: TPersistent); override;

Copies the properties of another TRdfStatement object.

function GetAttribute(Kind: TRdfStmtAttr): UTF8String;

Returns the property of the RDF statement which is indicated by the Kind parameter.

Filter Classes

TRdfCustomFilter = class

TRdfCustomFilter is the abstract base class of TRdfUriFilter and TRdfObjectFilter.

Public Properties

property Qualifier: string

A filter expression.

TRdfUriFilter = class(TRdfCustomFilter)

TRdfUriFilter is a filter for URI's enclosed in angular brackets, i.e. of the form <URI>.

Public Properties

property Qualifier: string

A filter expression of the form <uri>, where uri contains only characters allowed in URIs (see [RFC 2396]). No complete URI syntax check is performed.

Public Methods

function Match(AUri: UTF8String): Boolean; virtual;

Tests whether the specified URI matches the filter specified in the Qualifier property. The function returns 'true' if the specified URI matches the Qualifier character by character (including the leading '<' and trailing '>') or if the Qualifier is '*' or '<*>'; otherwise 'false' is returned.

TRdfObjectFilter = class(TRdfCustomFilter)

TRdfObjectFilter is a filter for the complex object structure of an RDF statement.

Public Properties

property Qualifier: string

If the Qualifier is '*' the filter matches any object structure. If the Qualifier is '<*>' it matches any object URI of the form '<uri>'. If the Qualifier is '<uri>' it matches the object URI of the form '<uri>' which is character by character identical with it.

To match a particular literal object the Qualifier must have the form '"lexical" @language <datatypeQualifier>'; the quotation marks (") surrounding the lexical are mandatory, the other elements are optional. If the filter lexical is '\*' it matches any object lexical. If the datatype lexical is '<*>' it matches any object datatype.

Public Methods

function Match(AObjectUri,
               AObjectLexical,
               AObjectLanguage,
               AObjectDatatype: UTF8String): Boolean; virtual;

Tests whether the specified statement object matches the filter specified in the Qualifier property. The function returns 'true' if the specified statement object matches the Qualifier, otherwise 'false' is returned.

TRdfStatementFilter = class(TPersistent)

TRdfStatementFilter is a filter for RDF statements.

Public Properties

property Enabled: Boolean

If Enabled is 'false' calling the match function returns always 'true'.

property ObjectQualifier: string

The filter statement the object of an RDF statement must match. See the description of the Qualifier property of the TRdfObjectFilter class for details.

property PredicateQualifier: string

The filter statement the predicate of an RDF statement must match. See the description of the Qualifier property of the TRdfUriFilter class for details.

property RejectAll: Boolean

If RejectAll is 'true' and Enabled is 'false' calling the match function returns always 'false'.

property SubjectQualifier: string

The filter statement the subject of an RDF statement must match. See the description of the Qualifier property of the TRdfUriFilter class for details.

Public Methods

procedure Assign(Source: TPersistent); override;

Copies the properties of another TRdfStatementFilter object.

function Match(ASubject,
               APredicate,
               AObject,
               AObjectLexical,
               AObjectLanguage,
               AObjectDatatype: UTF8String): Boolean; virtual;
               

If Enabled is 'false' calling this function returns 'true'. Otherwise and if RejectAll is 'true' calling this function returns 'false'. Otherwise calling this function tests whether the specified statement matches the filters specified in the SubjectQualifier, PredicateQualifier, and ObjectQualifier properties. The function returns 'true' if the specified statement object matches all qualifiers, otherwise 'false' is returned.

RDF Graph Classes

Note

Due to havy work load, a detailed description of the RDF graph classes has been postponed to a future edition of this documentation. Meanwhile, experiment with the example applications.

TRdfGraph = class(TUtilsCustomObjectIteratorList)

TRdfGraph is the common ancestor of all RDF graph classes. Do not use this class directly in your own applications. Instead use one of the derived classes or derive your own specialized RDF graph class from TRdfGraph.

TRdfCustomFilteredGraph = class(TRdfGraph)

TRdfCustomFilteredGraph is the common ancestor of all RDF graph classes which provide automatic filtering. Do not use this class directly in your own applications. Instead use one of the derived classes or derive your own specialized RDF graph class from TRdfCustomFilteredGraph.

TRdfFilteredGraph = class(TRdfCustomFilteredGraph)

TRdfFilteredGraph maintains a list of RDF statements. It publishes a filter object and an OnFilterStatement event which can be used to reject statements of certain kinds. TRdfFilteredGraph components can be connected to TUtilsCustomIteratorAliases components to provide automatic aliases when querying statement attributes such as a statement's subject URI, etc.

TRdfCustomDetailGraph = class(TRdfCustomFilteredGraph)

TRdfCustomDetailGraph is the common ancestor of all RDF detail graph classes which provide automatic filtering of an associated RDF graph. Do not use this class directly in your own applications. Instead use one of the derived classes or derive your own specialized RDF graph class from TRdfCustomDetailGraph.

TRdfDetailGraph = class(TRdfCustomDetailGraph)

TRdfDetailGraph maintains a list of RDF statements automatically generated from the RDF statements of another associated RDF graph. It publishes a filter object and an OnFilterStatement event which can be used to reject statements of certain kinds. TRdfDetailGraph components can be connected to TUtilsCustomIteratorAliases components to provide automatic aliases when querying statement attributes such as a statement's subject URI, etc.

TRdfCustomRestricterGraph = class(TRdfCustomDetailGraph)

TRdfCustomRestricterGraph is the common ancestor of all RDF restricted graph classes which provide automatic advanced filtering of an associated RDF graph. Do not use this class directly in your own applications. Instead use one of the derived classes or derive your own specialized RDF graph class from TRdfCustomRestricterGraph.

TRdfRestricterGraph = class(TRdfCustomRestricterGraph)

TRdfRestricterGraph maintains a list of RDF statements automatically generated from the RDF statements of another associated RDF graph. It publishes a filter object and an OnFilterStatement event which can be used to reject statements of certain kinds. Additional filters can be applied via the SubjectRestricter, PredicateRestricter, and ObjectRestricter properties. TRdfRestricterGraph components can be connected to TUtilsCustomIteratorAliases components to provide automatic aliases when querying statement attributes such as a statement's subject URI, etc.

RDF Iterator Classes

TRdfGraphIterator = class(TUtilsCustomIterator)

TRdfGraphIterator is an iterator class for TRdfGraph (or descendant) objects. It inherits from TUtilsCustomIterator defined in the AutoListUtils unit. For a description of TRdfGraphIterator's inherited properties and methods see the manual of the AutoListUtils unit.

Published Properties

property RdfGraph: TRdfGraph

The TRdfGraph (or descendant) object associated with this iterator.

Public Properties

property RdfSubject: UTF8String (readonly)

The subject of the RDF statement at the current position of the iterator. If no such information is available an empty UTF8String is returned.

property RdfPredicate: UTF8String (readonly)

The predicate of the RDF statement at the current position of the iterator. If no such information is available an empty UTF8String is returned.

property RdfObject: UTF8String (readonly)

The object of the RDF statement at the current position of the iterator. If no such information is available an empty UTF8String is returned.

property RdfObjectLexical: UTF8String (readonly)

The object lexical of the RDF statement at the current position of the iterator. If no such information is available an empty UTF8String is returned.

property RdfObjectLanguage: UTF8String (readonly)

The object language of the RDF statement at the current position of the iterator. If no such information is available an empty UTF8String is returned.

property RdfObjectDatatype: UTF8String (readonly)

The object datatype of the RDF statement at the current position of the iterator. If no such information is available an empty UTF8String is returned.

property CanModify: Boolean (readonly)

Indicates whether the associated RDF graph permits write access to data.

TRdfIteratorAdapter = class(TUtilsIteratorAdapter)

The TRdfIteratorAdapter is used to link a TRdfGraphIterator with an auto-updated view component for its associated list data. It is internally used in some of the other RDF components.

RDF List Classes

Note

Due to havy work load, a detailed description of the RDF list classes has been postponed to a future edition of this documentation. Meanwhile, experiment with the example applications.

TRdfCustomGraphList = class(TUtilsCustomAliasedStrings)

TRdfCustomGraphList is the abstract base class of TRdfGraphList and TRdfResourceList.

TRdfGraphList = class(TRdfCustomGraphList)

An automated string lists, which is synchronized with its associated RDF graph.

TRdfResourceList = class(TRdfCustomGraphList)

An automated string lists, which is synchronized with its associated RDF graph.

RDF Alias Classes

TRdfAliases = class(TUtilsCustomIteratorAliases)

TRdfAliases is an alias list class which can automatically interact with any TUtilsCustomIteratorList (or descendant) component. Its list of aliases is also automatically generated from the statements of an associated TRdfGraph (or descendant) component. TRdfAliases inherits from TUtilsCustomIteratorAliases defined in the AutoListUtils unit. For a description of TRdfAliases's inherited properties and methods see the manual of the AutoListUtils unit.

Published Properties

property NameSource: TRdfGraph

Specifies the TRdfGraph (or descendant) object which provides the list of names to be aliased. For each subject appearing in any statement of this TRdfGraph object, the alias list calculates an alias according to the settings of its other properties.

property PredicateSource: TUtilsStringIterator

Specifies a TUtilsStringIterator (or descendant) object whose string at the iterator's position determines the predicate used to built the the list of aliases while evaluating the AliasSource. If no such iterator is specified the value of the PredicateURI is used instead.

property PredicateURI: UTF8String

If no iterator is specified in the PredicateSource property, the PredicateURI determines the predicate used to built the the list of aliases while evaluating the AliasSource.

property AliasSource: TRdfGraph

Specifies the TRdfGraph (or descendant) object which provides the name-alias mappings for this alias list. These mappings are determined by the statements of the AliasSource RDF graph as follows: For each subject appearing in any statement of the NameSource RDF graph, the first statement in the AliasSource RDF graph with this subject and whose predicate matches the predicates specified by the PredicateSource (or the PredicateURI respectively) is picked out. The subject of this statement determines the name part while the object lexical or (if no object lexical exists) the object reference of this statement determines the alias part of the name-alias pair to be recorded.

Published Events

OnAfterUpdate: TNotifyEvent

Triggered after the list of alias is (re-)built.

OnBeforeUpdate: TNotifyEvent

Triggered before the list of alias is (re-)built.