You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Nathanael Thompson <th...@gmail.com> on 2011/03/30 17:52:45 UTC

build Node from string

Is there a best practice for building Node objects from Strings (when you
don't know what type of Node the string represents before hand)?

eg.
"Hi Bob!" -> Node_Literal
http://www.bob.com/Bob -> Node_URI

Thanks,
Nate

Re: build Node from string

Posted by Andy Seaborne <an...@epimorphics.com>.

On 30/03/11 16:52, Nathanael Thompson wrote:
> Is there a best practice for building Node objects from Strings (when you
> don't know what type of Node the string represents before hand)?
>
> eg.
> "Hi Bob!" ->  Node_Literal
> http://www.bob.com/Bob ->  Node_URI

If you can use

"'Hi Bob!'" -> Node_Literal
"<http://www.bob.com/Bob>" --> Node_URI

i.e a Java string of the valid Turtle syntax.

then SSE.parseNode will do it (bad name but that's history for you).

NodeFactory.parseNode(string) is a recent attempt to put a better name 
and then redirect to the current best place to do this.  It will 
eventually be straight into the RIOT tokenizer.

Chris has some code in the test code that parses a more lenient form, I 
think.

	HTH
	Andy

>
> Thanks,
> Nate
>