This content has been marked as final. Show 3 replies
No. Jena Adapter does not just return strings for typed literals.
If literal type is not null, then we invoke Node.createLiteral(str, null, literalType) to create the literal.
If language is not null, we invoke Node.createLiteral(str, language, null) to create the literal.
Otherwise, it is a plain literal.
For the first case, we rely on Jena's TypeMapper to retrieve the right type given the datatype uri.
I'm not sure that is the behavior that we are seeing. Let me try to detail this a bit further.
We have a custom datatype, ns:dollar. We have implemented a subclass to handle this and added that class to the Jena TypeMapper.
If I execute this sparql:
select o, p, P$RDFLTYP
FROM TABLE (SEM_MATCH(
ns:Application-99001761 ?o ?p
order by 1
I get these values:
ns#extendedCosts 1179.98 ns#dollar
The problem appears to be that the value of the triple is treated as a String rather than an Object. This means that when the createLiteral method is called it passes a string, which it turns passes a string to the LiteralLabelFactory. Looking at the code for LiteralLabelFactory, when a String is provided to the createLiteralLabel method, sets the lexicalForm to that string and never calls the "unparse" method of our extended datatype.
The result is my value out of the database gets treated as the LexicalForm rather than the value, and my call to getLexicalForm always returns 1179.98 rather than the lexicalForm of $1179.98 since the value of lexicalForm is already set when the LiteralLabel is created.