/** Guess the language/type of model data. * * <ul> * <li> If the URI ends ".rdf", it is assumed to be RDF/XML</li> * <li> If the URI ends ".nt", it is assumed to be N-Triples</li> * <li> If the URI ends ".ttl", it is assumed to be Turtle</li> * <li> If the URI ends ".owl", it is assumed to be RDF/XML</li> * </ul> * @param name URL to base the guess on * @param otherwise Default guess * @return String Guessed syntax - or the default supplied */ public static String guessLang( String name, String otherwise ) { String suffix = getFilenameExt( name ); if (suffix.equals( "n3" )) return langN3; if (suffix.equals( "nt" )) return langNTriple; if (suffix.equals( "ttl" )) return langTurtle ; if (suffix.equals( "rdf" )) return langXML; if (suffix.equals( "owl" )) return langXML; return otherwise; }
/** Guess the language/type of model data. * * <ul> * <li> If the URI ends ".rdf", it is assumed to be RDF/XML</li> * <li> If the URI ends ".nt", it is assumed to be N-Triples</li> * <li> If the URI ends ".ttl", it is assumed to be Turtle</li> * <li> If the URI ends ".owl", it is assumed to be RDF/XML</li> * </ul> * @param name URL to base the guess on * @param otherwise Default guess * @return String Guessed syntax - or the default supplied */ public static String guessLang( String name, String otherwise ) { String suffix = getFilenameExt( name ); if (suffix.equals( "n3" )) return langN3; if (suffix.equals( "nt" )) return langNTriple; if (suffix.equals( "ttl" )) return langTurtle ; if (suffix.equals( "rdf" )) return langXML; if (suffix.equals( "owl" )) return langXML; return otherwise; }
/** Try to map a URI or file name to a {@link Lang}; return null on no registered mapping. */ public static Lang filenameToLang(String filename) { if ( filename == null ) return null; // Remove any URI fragment (there can be only one # in a URI). // Pragmatically, assume any # is URI related. // URIs can be relative. int iHash = filename.indexOf('#'); if ( iHash > 0 ) filename = filename.substring(0, iHash); // Gzip or BZip2 compressed? filename = IO.filenameNoCompression(filename); return fileExtToLang(FileUtils.getFilenameExt(filename)); }