RDFResource

open class RDFResource : Resource

An RDF source: a resource whose representation is a set of RDF triples.

The triples are held in memory as a list of RdfQuads and serialized to JSON-LD by getEntity. You read and edit individual properties with findProperty / findAllProperties (and their per-subject variants) and addQuad / addQuadLiteral / clearProperties, rather than manipulating raw RDF text.

By convention the resource's own primary subject is the document URI with the fragment #it; the per-subject query/mutation overloads default to that subject.

For resources fetched from a Solid server, prefer the SolidRDFResource subtype, which also exposes the response SolidMetadata. Use this base type for RDF documents you construct locally.

See the Solid Protocol (https://solidproject.org/TR/protocol) and LDP (http://www.w3.org/TR/ldp/) for the RDF source model.

Inheritors

Constructors

Link copied to clipboard
constructor(identifier: String)
constructor(identifier: String, quads: List<RdfQuad>?)
constructor(identifier: String, quads: List<RdfQuad>?, headers: SolidHeaders?)
constructor(identifier: String, contentType: String, quads: List<RdfQuad>?)
constructor(identifier: String, contentType: String, quads: List<RdfQuad>?, headers: SolidHeaders?)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun addQuad(subject: String, predicate: String, obj: String, maxNumber: Int = 1)

Adds a triple whose object is an IRI (or blank node).

Link copied to clipboard
fun addQuadLiteral(subject: String, predicate: String, value: String, datatype: String? = XSD.STRING, language: String? = null, maxNumber: Int = 1)

Adds a triple whose object is a literal.

Link copied to clipboard
fun clearProperties(predicate: String, subject: String = itselfSubject)

Removes every triple with the given predicate for subject.

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun describeContents(): Int
Link copied to clipboard
fun ensureType(subject: String, typeIri: String)

Ensures subject carries an rdf:type triple with typeIri, preserving any other type triples already present.

Link copied to clipboard

Returns the object values of every triple with the given predicate, across all subjects.

Link copied to clipboard

Returns the object values of every triple matching the given subject and predicate.

Link copied to clipboard
fun findProperty(predicate: String): String?

Returns the object value of the first triple with the given predicate, or null if none.

Link copied to clipboard
fun findPropertyForSubject(subject: String, predicate: String): String?

Returns the object value of the first triple matching subject and predicate, or null.

Link copied to clipboard

Returns a snapshot copy of all triples held by this resource.

Link copied to clipboard
open override fun getContentType(): String

The media type of the resource representation (the value of its Content-Type).

Link copied to clipboard
open override fun getEntity(): InputStream

Returns the resource representation as a byte stream.

Link copied to clipboard
open override fun getHeaders(): SolidHeaders

The HTTP headers associated with this resource (empty when constructed locally).

Link copied to clipboard
open override fun getIdentifier(): String

The URI that identifies this resource on the pod.

Link copied to clipboard
open override fun writeToParcel(dest: Parcel, flags: Int)