Interface AccJson
- All Known Subinterfaces:
AccJsonEdge,AccJsonNode,AccJsonObjectLike
- All Known Implementing Classes:
AccJsonBase,AccJsonFragmentBody,AccJsonFragmentHead,AccJsonLiteral,AccJsonObject,AccJsonObjectLikeBase,AccJsonProperty
public interface AccJson
Interface for accumulating a JSON object from a stream of triples (edges in a graph).
The accumulator is like a (stateful) state in a state automaton:
An accumulator receives an individual edge in order to decide whether it can transition to a child state.
If it can't then it returns null.
AccJsonDriver drives the lookup. If a state (=accumulator) cannot handle the edge, it searches whether
any of that state's ancestors accepts it.
It is an error if no suitable accumulator is found for an edge - because that means that it is unclear
which accumulator should match the subsequent edges.-
Method Summary
Modifier and TypeMethodDescriptionvoidacceptContribution(RdfElement value, AccContextRdf context) For materialization: Whenever end() is called on a state with materialization enabled, then it passes its accumulated value to the parent using this method.voidbegin(org.apache.jena.graph.Node node, AccContextRdf context, boolean skipOutput) Start accumulation based on a given node in the underlying graph.voidend(AccContextRdf cxt) End the accumulator's current nodeInternal method, mainly for processing fragments.Get the parent of this accumulator.org.aksw.commons.path.json.PathJsongetPath()getValue()If cxt.isMaterialize is enabled then this method returns the json data assembled for the current node.booleanhasBegun()True after begin() and before end()voidSets the parent of this accumulator.transition(org.apache.jena.graph.Triple edge, AccContextRdf cxt) Process an edge.
-
Method Details
-
getPath
org.aksw.commons.path.json.PathJson getPath() -
setParent
Sets the parent of this accumulator. Can only be called once. This method should never be called by application code. -
getParent
AccJson getParent()Get the parent of this accumulator. Null if there is none. -
begin
void begin(org.apache.jena.graph.Node node, AccContextRdf context, boolean skipOutput) throws IOException Start accumulation based on a given node in the underlying graph. Calls cannot be nested.- Parameters:
node- The source node to which the next incoming edge(s) will connect tocontext- The context which holds the JSON serializersskipOutput- When output should be disabled (used e.g. to skip over lists of items where just one was expected)- Throws:
IllegalStateException- if there was a prior call to begin() without corresponding end()IOException
-
transition
Process an edge. Based on the given edge, this accumulator attempts to transition to another AccJson instance and return it. If there is no valid transition then this method returns null.- Throws:
IOException
-
end
End the accumulator's current node- Throws:
IllegalStateException- if there was no prior call to begin()IOException
-
hasBegun
boolean hasBegun()True after begin() and before end() -
getValue
RdfElement getValue()If cxt.isMaterialize is enabled then this method returns the json data assembled for the current node. It is only valid to call this method after end(). -
getInternalValue
RdfElement getInternalValue()Internal method, mainly for processing fragments. Unchecked access to the current value under construction. Should hardly be used. -
acceptContribution
For materialization: Whenever end() is called on a state with materialization enabled, then it passes its accumulated value to the parent using this method.
-