| From | Sent On | Attachments |
|---|---|---|
| Laurent Pellegrino | May 26, 2011 7:37 am | |
| Andy Seaborne | May 27, 2011 2:37 am | |
| Andy Seaborne | May 27, 2011 3:29 am | |
| Paolo Castagna | Jun 13, 2011 8:54 am | |
| Andy Seaborne | Jun 13, 2011 1:32 pm | |
| Andy Seaborne | Jun 13, 2011 2:35 pm | |
| Paolo Castagna | Jun 14, 2011 2:24 am | |
| Andy Seaborne | Jun 14, 2011 2:28 am | |
| Paolo Castagna | Jun 14, 2011 4:11 am | |
| Andy Seaborne | Jun 14, 2011 5:02 am |
| Subject: | Re: Reverse operation for FmtUtils.stringForNode(...) | |
|---|---|---|
| From: | Andy Seaborne (andy...@epimorphics.com) | |
| Date: | May 27, 2011 2:37:42 am | |
| List: | org.apache.incubator.jena-users | |
On 26/05/11 15:37, Laurent Pellegrino wrote:
Hi all,
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 FmtUtils.stringForNode(...)?
Kind Regards,
Laurent
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 want.
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:
https://svn.apache.org/repos/asf/incubator/jena/Scratch/AFS/trunk/src/riot/io/
TokenInputStream and TokenOutputStream might be useful.
Until TSV, a tuple of terms is a number of RDF terms, terminated by a DOT (not newline).
This could be useful to JENA-44, JENA-45 and JENA-69
I'm keen that we create a single solid I/O layer so it can teste and optimized then shared amongst all the code doing I/O related things.
Nodec is an interface specializes attempt to ByteBuffers for file, not stream I/O. File I/O can be random access.
Andy





