JsonLdStreamSerializer
    
            
            in package
            
        
    
            
            implements
                            SerializerInterface                    
    
            
            uses
                            TmpStreamSerializerTrait                    
    
A steaming JsonLD serializer. Generates output in the flatten JsonLD format and does it in a greedy way (meaning subjects/predicates/values are acumulated within graph/subject/predicate only if adjacent triples share the same graph/subject/predicate). On the brigh side it's fast and has minimal memory footprint.
To use this parser with the \quickRdfIo\Util::serialize() use the special
jsonld-stream value as $format.
Tags
Table of Contents
Interfaces
Constants
- DEFAULT_GRAPH_ID = '_:defaultGraph'
- MODE_GRAPH = 2
- MODE_TRIPLES = 1
Properties
- $context : array<string, string>
- $contextJson : string
- $firstValue : bool
- $mode : int
- $prevGraph : TermInterface
- $prevPredicate : TermInterface
- $prevSubject : TermInterface
Methods
- __construct() : mixed
- serialize() : string
- serializeStream() : void
- prepareContext() : void
- processGraph() : void
- processObject() : void
- processPredicate() : void
- processSubject() : void
- serializeId() : string
- serializeNode() : mixed
Constants
DEFAULT_GRAPH_ID
    public
        mixed
    DEFAULT_GRAPH_ID
    = '_:defaultGraph'
    
    
    
    
MODE_GRAPH
    public
        mixed
    MODE_GRAPH
    = 2
    
    
    
    
MODE_TRIPLES
    public
        mixed
    MODE_TRIPLES
    = 1
    
    
    
    
Properties
$context
        private
            array<string, string>
    $context
    
    
    
    
    
    
$contextJson
        private
            string
    $contextJson
    
    
    
    
    
    
$firstValue
        private
            bool
    $firstValue
    
    
    
    
    
    
$mode
        private
            int
    $mode
    
    
    
    
    
    
$prevGraph
        private
            TermInterface
    $prevGraph
    
    
    
    
    
    
$prevPredicate
        private
            TermInterface
    $prevPredicate
    
    
    
    
    
    
$prevSubject
        private
            TermInterface
    $prevSubject
    
    
    
    
    
    
Methods
__construct()
    public
                    __construct([int $mode = self::MODE_GRAPH ]) : mixed
    Parameters
- $mode : int = self::MODE_GRAPH
serialize()
    public
                    serialize(Traversable<string|int, QuadInterface>|array<string|int, QuadInterface> $graph[, RdfNamespaceInterface|null $nmsp = null ]) : string
    Parameters
- $graph : Traversable<string|int, QuadInterface>|array<string|int, QuadInterface>
- $nmsp : RdfNamespaceInterface|null = null
Tags
Return values
stringserializeStream()
    public
                    serializeStream(resource|StreamInterface $output, Traversable<string|int, QuadInterface>|array<string|int, QuadInterface> $graph[, RdfNamespaceInterface|null $nmsp = null ]) : void
    Parameters
- $output : resource|StreamInterface
- 
                    output to serialize to 
- $graph : Traversable<string|int, QuadInterface>|array<string|int, QuadInterface>
- 
                    data to serialize 
- $nmsp : RdfNamespaceInterface|null = null
- 
                    allows to provide context for predicates. For that, register full predicate URIs as namespaces in the $nmspobject.
prepareContext()
    private
                    prepareContext(RdfNamespaceInterface $context) : void
    Parameters
- $context : RdfNamespaceInterface
processGraph()
    private
                    processGraph(StreamInterface $output, DefaultGraphInterface|NamedNodeInterface|BlankNodeInterface $graph) : void
    Parameters
- $output : StreamInterface
- $graph : DefaultGraphInterface|NamedNodeInterface|BlankNodeInterface
processObject()
    private
                    processObject(StreamInterface $output, TermInterface $object) : void
    Parameters
- $output : StreamInterface
- $object : TermInterface
processPredicate()
    private
                    processPredicate(StreamInterface $output, NamedNodeInterface $predicate) : void
    Parameters
- $output : StreamInterface
- $predicate : NamedNodeInterface
processSubject()
    private
                    processSubject(StreamInterface $output, NamedNodeInterface|BlankNodeInterface $subject) : void
    Parameters
- $output : StreamInterface
- $subject : NamedNodeInterface|BlankNodeInterface
serializeId()
    private
                    serializeId(string|TermInterface $term) : string
    Parameters
- $term : string|TermInterface
Return values
stringserializeNode()
    private
                    serializeNode(TermInterface $node) : mixed
    Parameters
- $node : TermInterface