/** * Version of getTypeByName which will treat unknown URIs as typed literals but with just the * default implementation * * @param uri the URI of the desired datatype * @return Datatype the datatype definition registered at uri, if there is no such registered type * it returns a new instance of the default datatype implementation, if the uri is null it * returns null (indicating a plain RDF literal). */ public RDFDatatype getSafeTypeByName(String uri) { RDFDatatype dtype = (RDFDatatype) uriToDT.get(uri); if (dtype == null) { if (uri == null) { // Plain literal return null; } else { // Uknown datatype if (JenaParameters.enableSilentAcceptanceOfUnknownDatatypes) { dtype = new BaseDatatype(uri); registerDatatype(dtype); } else { throw new DatatypeFormatException( "Attempted to created typed literal using an unknown datatype - " + uri); } } } return dtype; }
/** Static initializer. Adds builtin datatypes to the mapper. */ static { theTypeMap = new TypeMapper(); theTypeMap.registerDatatype(XMLLiteralType.theXMLLiteralType); XSDDatatype.loadXSDSimpleTypes(theTypeMap); }