public static TypedLiteral toLiteral ( Object value ) { if ( value == null ) throw new IllegalArgumentException ( "Can't convert null value" ) ; Conversion < ? > c = classConversions . get ( value . getClass ( ) ) ; if ( c != null ) return c . literal ( value ) ; // The object has an unrecognized type that doesn't translate directly to XSD. // Omitting the datatype would imply a type of xsd:string, so use xsd:anySimpleType instead. // The use of xsd:anySimpleType prevents round-tripping; in the future we could possibly // serialize this as a byte array and use xsd:hexBinary or xsd:base64Binary. return new TypedLiteralImpl ( value . toString ( ) , XsdTypes . ANY_SIMPLE_TYPE ) ; }
Convert from an arbitrary Java object to an RDF typed literal using an XSD datatype if possible .