You might look at how PA4RDF handled the problem.
https://github.com/Claudenw/PA4RDF

in
https://github.com/Claudenw/PA4RDF/blob/master/src/main/java/org/xenei/jena/entities/impl/PredicateInfoImpl.java
the method getHandler() has code that determines what the return type is
for a literal.  The LiteralHandler then performs the task of converting the
RDFNode into the type specified by the literal.

The PA4RDF code has the advantage of knowing what datatype is expected as
the return from the getter method and will use that if the RDFNode is not a
literal, or does not have a datatype. (naked string).

Claude

On Thu, Jan 12, 2017 at 11:09 AM, George News <george.n...@gmx.net> wrote:

> On 12/01/2017 11:31, Dave Reynolds wrote:
> >
> > On 12/01/17 10:15, George News wrote:
> >> BTW I think I found a bug:
> >>
> >> String b = "http://datypic.com/fraf1";;
> >> Literal a = (Literal) ResourceFactory.createTypedLiteral(b,
> >> XSDDatatype.XSDanyURI);
> >> System.out.println(a.getDatatype());
> >> System.out.println(a.getValue().getClass());
> >>
> >> a = (Literal) ResourceFactory.createTypedLiteral(URI.create(b));
> >> System.out.println(a.getDatatype());
> >> System.out.println(a.getValue().getClass());
> >>
> >> Output:
> >> Datatype[http://www.w3.org/2001/XMLSchema#anyURI -> class java.net.URI]
> >> class java.lang.String
> >> Datatype[http://www.w3.org/2001/XMLSchema#anyURI -> class java.net.URI]
> >> class java.net.URI
> >>
> >> Shouldn't both getValue() be java.net.URI? I guess this needs to be
> >> fixed as in both cases the DataType indicastes it's an URI, so when
> >> casting the String to URI the system complains ;)
> >
> > Up till now we've never included a mapping from xsd:anyURI to
> > java.net.URI in the type mapping table. I seem to recall that was
> > originally because of some doubt as to whether, if there was a mapping,
> > it should use java.net.URI or the IRI machinery built into jena and
> > partly because the rest Jena uses strings so much for URI references.
> >
> > I think you could register such a mapping yourself in your application.
> >
> > Whether that should be added as a default I'm not sure.
>
> I got your point, but the problem is that is confusing when you are
> trying to automate the code. If getValue() returns an String but
> datatype is saying it is an URI then you have a reflection problem.
>
> I just wanted to pointed this out. I'm newbie and not maintainer of the
> code. I accept the internal decisions of people that knows much more
> than I do for sure.
>
> Thanks a lot for the help you all have provided!!!!
> Jorge
>



-- 
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren

Reply via email to