I am using FmtUtils.stringForNode(...) from ARQ to encode a Node to a
String. Now, I have to perform the reverse operation: from the String
I want to create the Node. Is there a class and method to do that from
the ARQ library?
It seems that NodecLib.decode(...) do the trick but it is in the TDB
library and I am not sure that it works with any output from
There are ways to reverse the process - too many in fact.
Simple: SSE.parseNode: String -> Node
It uses a javacc parser so the overall efficiency isn't ideal.
But RIOT is in the process of reworking I/O for efficiency; the input
side is the area that is most finished. The tokenizer will do what you
What's missing in RIOT is Node to stream writing without using FmtUtils
-- this is OutputLangUtils which is unfinished. FmtUtils creates
intermediate strings, when the output could be straight to a stream,
avoiding a copy and the temporary object allocation.
The Tokenizer is:
interface Tokenizer extends Iterator<Token>
and see org.openjena.riot.tokens.TokenizerFactory
especially if you have a sequence of them to parse ... like a TSV file.
But you will have to manage newlines as to the tokenizer they are
whitespace like anything else.
There is some stuff in my scratch area for streams of tuples of RDF
terms and variables: