org.apache.jena.riot.Lang.getFileExtensions()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中org.apache.jena.riot.Lang.getFileExtensions()方法的一些代码示例,展示了Lang.getFileExtensions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lang.getFileExtensions()方法的具体详情如下:
包路径:org.apache.jena.riot.Lang
类名称:Lang
方法名:getFileExtensions

Lang.getFileExtensions介绍

暂无

代码示例

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

public String toLongString() { 
  String x = "Lang:" + label + " " + getContentType() ;
  if (getAltNames().size() > 0)
    x = x + " " + getAltNames() ;
  if (getAltContentTypes().size() > 0)
    x = x + " " + getAltContentTypes() ;
  if (getFileExtensions().size() > 0)
    x = x + " " + getFileExtensions() ;
  return x ;
}

代码示例来源:origin: apache/jena

public String toLongString() { 
    String x = "Lang:" + label + " " + getContentType() ;
    if (getAltNames().size() > 0)
      x = x + " " + getAltNames() ;
    if (getAltContentTypes().size() > 0)
      x = x + " " + getAltContentTypes() ;
    if (getFileExtensions().size() > 0)
      x = x + " " + getFileExtensions() ;

    return x ;
  }
}

代码示例来源:origin: apache/jena

@Test
public void testDefaultInExtensions()
{
  for (Lang lang : RDFLanguages.getRegisteredLanguages() )
  {
    if ( lang.getFileExtensions() == null || lang.getFileExtensions().isEmpty())
      continue ;
    Assert.assertTrue( lang+" default extension not in file extensions list", lang.getFileExtensions().contains( lang.getFileExtensions().get(0))  );
  }
}

代码示例来源:origin: org.aksw.rdfunit/rdfunit-io

public static String getFormatFromExtension(String filename) {
    String format = "TURTLE";
    try {
      // try to get if from Jena first
      String extension;
      Lang jenaLang = RDFLanguages.filenameToLang(filename);
      if (jenaLang != null) {
        extension = jenaLang.getFileExtensions().get(0);
      } else {
        int index = filename.lastIndexOf('.');
        extension = filename.substring(index + 1, filename.length());
      }
      SerializationFormat f = FormatService.getInputFormat(extension);
      if (f != null) {
        format = f.getName();
      }
    } catch (Exception e) {
      log.debug("No format found, using the default one", e);
      return "TURTLE";
    }
    return format;
  }
}

代码示例来源:origin: AKSW/RDFUnit

public static String getFormatFromExtension(String filename) {
    String format = "TURTLE";
    try {
      // try to get if from Jena first
      String extension;
      Lang jenaLang = RDFLanguages.filenameToLang(filename);
      if (jenaLang != null) {
        extension = jenaLang.getFileExtensions().get(0);
      } else {
        int index = filename.lastIndexOf('.');
        extension = filename.substring(index + 1, filename.length());
      }
      SerializationFormat f = FormatService.getInputFormat(extension);
      if (f != null) {
        format = f.getName();
      }
    } catch (Exception e) {
      log.debug("No format found, using the default one", e);
      return "TURTLE";
    }
    return format;
  }
}

代码示例来源:origin: apache/jena

/** Remove a registration of a language - this also removes all recorded mapping
 * of content types and file extensions. 
 */

public static void unregister(Lang lang)
{
  if ( lang == null )
    throw new IllegalArgumentException("null for language") ;
  checkRegistration(lang) ; 
  mapLabelToLang.remove(canonicalKey(lang.getLabel())) ;
  mapContentTypeToLang.remove(canonicalKey(lang.getContentType().getContentType())) ;
  
  for ( String ct : lang.getAltContentTypes() )
    mapContentTypeToLang.remove(canonicalKey(ct)) ;
  for ( String ext : lang.getFileExtensions() )
    mapFileExtToLang.remove(canonicalKey(ext)) ;
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

/** Remove a regsitration of a language - this also removes all recorded mapping
 * of content types and file extensions. 
 */

public static void unregister(Lang lang)
{
  if ( lang == null )
    throw new IllegalArgumentException("null for language") ;
  checkRegistration(lang) ; 
  mapLabelToLang.remove(canonicalKey(lang.getLabel())) ;
  mapContentTypeToLang.remove(canonicalKey(lang.getContentType().getContentType())) ;
  
  for ( String ct : lang.getAltContentTypes() )
    mapContentTypeToLang.remove(canonicalKey(ct)) ;
  for ( String ext : lang.getFileExtensions() )
    mapFileExtToLang.remove(canonicalKey(ext)) ;
}

代码示例来源:origin: apache/jena

private static void checkRegistration(Lang lang)
{
  if ( lang == null )
    return ;
  String label = canonicalKey(lang.getLabel()) ;
  Lang lang2 = mapLabelToLang.get(label) ;
  if ( lang2 == null )
    return ;
  if ( lang.equals(lang2) )
    return ;
  
  // Content type.
  if ( mapContentTypeToLang.containsKey(lang.getContentType().getContentType()))
  {
    String k = lang.getContentType().getContentType() ;
    error("Language overlap: " +lang+" and "+mapContentTypeToLang.get(k)+" on content type "+k) ;
  }
  for (String altName : lang.getAltNames() )
    if ( mapLabelToLang.containsKey(altName) )
      error("Language overlap: " +lang+" and "+mapLabelToLang.get(altName)+" on name "+altName) ;
  for (String ct : lang.getAltContentTypes() )
    if ( mapContentTypeToLang.containsKey(ct) )
      error("Language overlap: " +lang+" and "+mapContentTypeToLang.get(ct)+" on content type "+ct) ;
  for (String ext : lang.getFileExtensions() )
    if ( mapFileExtToLang.containsKey(ext) )
      error("Language overlap: " +lang+" and "+mapFileExtToLang.get(ext)+" on file extension type "+ext) ;
}

代码示例来源:origin: apache/jena

/** Register a language.
 * To create a {@link Lang} object use {@link LangBuilder}.
 * See also 
 * {@link RDFParserRegistry#registerLang}
 * for registering a language and it's RDF parser factory.
 * 
 * @see RDFParserRegistry
 */
public static void register(Lang lang)
{
  if ( lang == null )
    throw new IllegalArgumentException("null for language") ;
  checkRegistration(lang) ;
  mapLabelToLang.put(canonicalKey(lang.getLabel()),  lang) ;
  
  for (String altName : lang.getAltNames() )
    mapLabelToLang.put(canonicalKey(altName), lang) ;
  
  mapContentTypeToLang.put(canonicalKey(lang.getContentType().getContentType()), lang) ;
  for ( String ct : lang.getAltContentTypes() )
    mapContentTypeToLang.put(canonicalKey(ct), lang) ;
  for ( String ext : lang.getFileExtensions() )
  {
    if ( ext.startsWith(".") ) 
      ext = ext.substring(1) ;
    mapFileExtToLang.put(canonicalKey(ext), lang) ;
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

/** Register a language.
 * To create a {@link Lang} object use {@link LangBuilder}.
 * See also 
 * {@link RDFParserRegistry#registerLang}
 * for registering a language and it's RDF parser fatory.
 * 
 * @see RDFParserRegistry
 */
public static void register(Lang lang)
{
  if ( lang == null )
    throw new IllegalArgumentException("null for language") ;
  checkRegistration(lang) ;
  mapLabelToLang.put(canonicalKey(lang.getLabel()),  lang) ;
  
  for (String altName : lang.getAltNames() )
    mapLabelToLang.put(canonicalKey(altName), lang) ;
  
  mapContentTypeToLang.put(canonicalKey(lang.getContentType().getContentType()), lang) ;
  for ( String ct : lang.getAltContentTypes() )
    mapContentTypeToLang.put(canonicalKey(ct), lang) ;
  for ( String ext : lang.getFileExtensions() )
  {
    if ( ext.startsWith(".") ) 
      ext = ext.substring(1) ;
    mapFileExtToLang.put(canonicalKey(ext), lang) ;
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

private static void checkRegistration(Lang lang)
{
  if ( lang == null )
    return ;
  String label = canonicalKey(lang.getLabel()) ;
  Lang lang2 = mapLabelToLang.get(label) ;
  if ( lang2 == null )
    return ;
  if ( lang.equals(lang2) )
    return ;
  
  // Content type.
  if ( mapContentTypeToLang.containsKey(lang.getContentType().getContentType()))
  {
    String k = lang.getContentType().getContentType() ;
    error("Language overlap: " +lang+" and "+mapContentTypeToLang.get(k)+" on content type "+k) ;
  }
  for (String altName : lang.getAltNames() )
    if ( mapLabelToLang.containsKey(altName) )
      error("Language overlap: " +lang+" and "+mapLabelToLang.get(altName)+" on name "+altName) ;
  for (String ct : lang.getAltContentTypes() )
    if ( mapContentTypeToLang.containsKey(ct) )
      error("Language overlap: " +lang+" and "+mapContentTypeToLang.get(ct)+" on content type "+ct) ;
  for (String ext : lang.getFileExtensions() )
    if ( mapFileExtToLang.containsKey(ext) )
      error("Language overlap: " +lang+" and "+mapFileExtToLang.get(ext)+" on file extension type "+ext) ;
}

代码示例来源:origin: apache/jena

@Test
public void testFileExtensionUnique()
{
  Map<String, Lang> exts = new HashMap<>();
  
  for (Lang lang1 : RDFLanguages.getRegisteredLanguages() )
  {
    for (String ext : lang1.getFileExtensions())
    {
      Lang lang2 = exts.get(ext) ;
      Assert.assertTrue( "The "+ext+" file extensions in "+lang1+" was already used", lang2 == null || lang1 == lang2) ;
      exts.put(ext, lang1) ;
    }
  }
  
}

代码示例来源:origin: apache/jena

@Test
public void testFileExtensionsProvided()
{
  for (Lang l : RDFLanguages.getRegisteredLanguages() )
  {
    if ( RDFLanguages.RDFNULL.equals(l) )
      continue ;
    if ( ResultSetLang.SPARQLResultSetNone.equals(l) ) 
      continue ;
    Assert.assertNotNull( l+" does not have file extensions defined", l.getFileExtensions());
    Assert.assertTrue( l+" does not have file extensions defined", l.getFileExtensions().size() > 0);
  }
}

相关文章