• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Language类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.gbif.api.vocabulary.Language的典型用法代码示例。如果您正苦于以下问题:Java Language类的具体用法?Java Language怎么用?Java Language使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Language类属于org.gbif.api.vocabulary包,在下文中一共展示了Language类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testVernacularNames

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testVernacularNames() throws Exception {
  ExtensionInterpreter interp = new ExtensionInterpreter();
  NameUsage u = new NameUsage();
  VerbatimNameUsage v = new VerbatimNameUsage();

  Map<Term, String> v1 = Maps.newHashMap();
  v1.put(DwcTerm.vernacularName, "palmeirinha");
  v1.put(DcTerm.language, "PORTUGUES");
  v1.put(DwcTerm.locality, "Acre");

  Map<Term, String> v2 = Maps.newHashMap();
  v2.put(DwcTerm.vernacularName, "ubim");
  v2.put(DcTerm.language, "PORTUGUES");
  v2.put(DwcTerm.locality, "Acre");

  v.getExtensions().put(Extension.VERNACULAR_NAME, Lists.newArrayList(v1, v2));

  UsageExtensions ext = interp.interpret(u, v);
  assertEquals(2, ext.vernacularNames.size());
  assertTrue(u.getIssues().isEmpty());
  assertEquals("palmeirinha", ext.vernacularNames.get(0).getVernacularName());
  assertEquals(Language.PORTUGUESE, ext.vernacularNames.get(0).getLanguage());
  assertEquals("Acre", ext.vernacularNames.get(0).getArea());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:26,代码来源:ExtensionInterpreterTest.java


示例2: testAnalyse

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testAnalyse() {
    final Date downloaded = new Date();
    DatasetMetrics d = service.analyse(ClbDbTestRule.SQUIRRELS_DATASET_KEY, downloaded);
    System.out.println(d);
    assertEquals(ClbDbTestRule.SQUIRRELS_DATASET_KEY, d.getDatasetKey());
    assertEquals(downloaded, d.getDownloaded());
    assertEquals(44, d.getUsagesCount());
    assertEquals(16, d.getSynonymsCount());
    assertEquals(44, d.getDistinctNamesCount());
    assertEquals(2, d.getNubMatchingCount());
    assertEquals(4, d.getNubCoveragePct());
    assertEquals(0, d.getColCoveragePct());
    assertEquals(0, d.getColMatchingCount());
    assertEquals(1, d.getCountByKingdom().size());
    // there are more animal records in this dataset, but only 2 are mapped to the nub!
    assertEquals(2, d.getCountByKingdom(Kingdom.ANIMALIA));
    assertEquals(0, d.getCountByKingdom(Kingdom.PLANTAE));
    assertEquals(10, d.getCountByRank(Rank.SUBSPECIES));
    assertEquals(3, d.getCountByRank(Rank.SPECIES));
    assertEquals(2, d.getCountByRank(Rank.GENUS));
    assertEquals(1, d.getCountByRank(Rank.PHYLUM));
    assertEquals(4, d.getCountNamesByLanguage(Language.ENGLISH));
    assertEquals(2, d.getCountNamesByLanguage(Language.GERMAN));
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:26,代码来源:DatasetAnalysisServiceMyBatisIT.java


示例3: testMapper

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testMapper() throws Exception {
    assertTrue(mapper.listByChecklistUsage(usageKey, new PagingRequest()).isEmpty());
    assertTrue(mapper.listByNubUsage(usageKey, new PagingRequest()).isEmpty());

    Description obj = new Description();
    obj.setContributor("contribtr");
    obj.setCreator("creatr");
    obj.setDescription("description");
    obj.setLanguage(Language.ABKHAZIAN);
    obj.setLicense("license");
    obj.setType("myType");
    // these should get ignored
    obj.setSource("sourcy s");
    obj.setSourceTaxonKey(123);

    mapper.insert(usageKey, obj, citationKey1);

    Description obj2 = mapper.listByChecklistUsage(usageKey, new PagingRequest()).get(0);
    assertObject(obj, obj2, citation1, null);


    obj2 = mapper.listByNubUsage(nubKey, new PagingRequest()).get(0);
    // these are now nub source usage values
    assertObject(obj, obj2, datasetTitle, usageKey);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:27,代码来源:DescriptionMapperTest.java


示例4: addDescription

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
public void addDescription(int key, Language lang, String topic) {
  topic = Strings.isNullOrEmpty(topic) ? DEFAULT_TOPIC : topic.toLowerCase().trim();

  if (lang == null) {
    // default to english
    lang = Language.ENGLISH;
  }

  if (!toc.containsKey(lang)) {
    toc.put(lang, Maps.<String, List<Integer>>newTreeMap());
  }
  if (!toc.get(lang).containsKey(topic)) {
    toc.get(lang).put(topic, Lists.<Integer>newArrayList());
  }
  toc.get(lang).get(topic).add(key);
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:17,代码来源:TableOfContents.java


示例5: getFacetEnumValue

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
/**
 * Gets the facet value of Enum type parameter.
 * If the Enum is either a Country or a Language, its iso2Letter code it's used.
 */
public static <P extends SearchParameter> String getFacetEnumValue(P facetParam, String value) {
  // the expected enum type for the value if it is an enum - otherwise null
  final Enum<?>[] enumValues = ((Class<? extends Enum<?>>) facetParam.type()).getEnumConstants();
  // if we find integers these are ordinals, translate back to enum names
  final Integer intValue = Ints.tryParse(value);
  if (null != intValue) {
    final Enum<?> enumValue = enumValues[intValue];
    if (Country.class.equals(facetParam.type())) {
      return ((Country) enumValue).getIso2LetterCode();
    } else if (Language.class.equals(facetParam.type())) {
      return ((Language) enumValue).getIso2LetterCode();
    } else {
      return enumValue.name();
    }
  } else {
    if (Country.class.equals(facetParam.type())) {
      return Country.fromIsoCode(value).getIso2LetterCode();
    } else if (Language.class.equals(facetParam.type())) {
      return Language.fromIsoCode(value).getIso2LetterCode();
    } else {
      return VocabularyUtils.lookupEnum(value, (Class<? extends Enum<?>>) facetParam.type()).name();
    }
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:29,代码来源:SolrQueryUtils.java


示例6: testGetResult

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testGetResult() throws ServiceUnavailableException {
  try {
    when(mockedRs.getObject("language_i")).thenReturn("en");
    assertThat(th.getResult(mockedRs, "language_i"), is(Language.ENGLISH));
  } catch (SQLException e) {
  }
}
 
开发者ID:gbif,项目名称:common-mybatis,代码行数:9,代码来源:LanguageTypeHandlerTest.java


示例7: testCompleteness

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testCompleteness() {
  for (Language t : Language.values()) {
    if (t == Language.UNKNOWN) {
      assertTrue(conv.fromEnum(t) == null);
    } else {
      assertTrue(conv.fromEnum(t) != null);
    }
  }
}
 
开发者ID:gbif,项目名称:common-mybatis,代码行数:11,代码来源:LanguageConverterTest.java


示例8: testToEnum

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testToEnum() {
  assertEquals(Language.DANISH, conv.toEnum("DA"));
  assertEquals(Language.DANISH, conv.toEnum("da"));
  assertEquals(Language.ENGLISH, conv.toEnum("EN"));
  assertEquals(Language.SPANISH, conv.toEnum("ES"));
  assertEquals(Language.UNKNOWN, conv.toEnum("ZZ"));
  assertEquals(Language.UNKNOWN, conv.toEnum("nothing"));
  assertEquals(Language.UNKNOWN, conv.toEnum(""));
  assertEquals(Language.UNKNOWN, conv.toEnum(" "));
  assertEquals(Language.UNKNOWN, conv.toEnum(null));
}
 
开发者ID:gbif,项目名称:common-mybatis,代码行数:13,代码来源:LanguageConverterTest.java


示例9: testGet

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testGet() {
  final Integer KEY = 14;
  Description d = wsClient.get(KEY);
  assertEquals("introduction", d.getType());
  assertEquals(Language.ENGLISH, d.getLanguage());

  assertNull(wsClient.get(-2));
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:10,代码来源:DescriptionWsClientIT.java


示例10: testGet

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testGet() {
  DatasetMetrics d = wsClient.get(CHECKLIST_KEY);
  assertEquals(CHECKLIST_KEY, d.getDatasetKey());
  assertEquals(1000, d.getUsagesCount());
  assertEquals(25, d.getColCoveragePct());
  assertEquals(250, d.getColMatchingCount());
  assertEquals(100, d.getCountByKingdom(Kingdom.ANIMALIA));
  assertEquals(700, d.getCountByKingdom(Kingdom.PLANTAE));
  assertEquals(0, d.getCountByKingdom(Kingdom.FUNGI));
  assertEquals(120, d.getCountByRank(Rank.GENUS));
  assertEquals(10, d.getCountByRank(Rank.PHYLUM));
  assertEquals(4, d.getCountNamesByLanguage(Language.DANISH));
  assertEquals(132, d.getCountNamesByLanguage(Language.GERMAN));
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:16,代码来源:DatasetMetricsWsClientIT.java


示例11: bindTypeHandlers

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Override
protected void bindTypeHandlers() {
  // mybatis type handler
  handleType(Country.class).with(CountryTypeHandler.class);
  handleType(Language.class).with(LanguageTypeHandler.class);
  handleType(UUID.class).with(UuidTypeHandler.class);
  handleType(URI.class).with(UriTypeHandler.class);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:9,代码来源:InternalChecklistBankServiceMyBatisModule.java


示例12: testInsert

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testInsert() {
    DatasetMetricsServiceMyBatis srv = (DatasetMetricsServiceMyBatis) service;

    srv.create(ClbDbTestRule.SQUIRRELS_DATASET_KEY, new Date());

    DatasetMetrics d = service.get(ClbDbTestRule.SQUIRRELS_DATASET_KEY);
    assertEquals(ClbDbTestRule.SQUIRRELS_DATASET_KEY, d.getDatasetKey());
    assertEquals(44, d.getUsagesCount());
    assertEquals(16, d.getSynonymsCount());
    assertEquals(44, d.getDistinctNamesCount());
    assertEquals(2, d.getNubMatchingCount());
    assertEquals(0, d.getColMatchingCount());
    assertEquals(0, d.getColCoveragePct());

    assertEquals(44, d.getCountByOrigin(Origin.SOURCE));
    assertEquals(2, d.getCountByKingdom(Kingdom.ANIMALIA));
    assertEquals(0, d.getCountByKingdom(Kingdom.FUNGI));
    assertEquals(2, d.getCountByRank(Rank.GENUS));
    assertEquals(1, d.getCountByRank(Rank.PHYLUM));
    assertEquals(10, d.getCountByRank(Rank.SUBSPECIES));
    assertEquals(1, d.getCountByRank(Rank.FAMILY));
    assertEquals(0, d.getCountNamesByLanguage(Language.DANISH));
    assertEquals(2, d.getCountNamesByLanguage(Language.GERMAN));
    assertEquals(1, d.getCountByIssue(NameUsageIssue.RANK_INVALID));
    assertEquals(0, d.getCountByIssue(NameUsageIssue.BACKBONE_MATCH_NONE));
    assertEquals(0, d.getCountByIssue(NameUsageIssue.CLASSIFICATION_NOT_APPLIED));
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:29,代码来源:DatasetMetricsServiceMyBatisIT.java


示例13: testGet

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testGet() {
    DatasetMetrics d = service.get(ClbDbTestRule.SQUIRRELS_DATASET_KEY);
    assertEquals(ClbDbTestRule.SQUIRRELS_DATASET_KEY, d.getDatasetKey());
    assertEquals(1000, d.getUsagesCount());
    assertEquals(25, d.getColCoveragePct());
    assertEquals(250, d.getColMatchingCount());
    assertEquals(100, d.getCountByKingdom(Kingdom.ANIMALIA));
    assertEquals(700, d.getCountByKingdom(Kingdom.PLANTAE));
    assertEquals(0, d.getCountByKingdom(Kingdom.FUNGI));
    assertEquals(120, d.getCountByRank(Rank.GENUS));
    assertEquals(10, d.getCountByRank(Rank.PHYLUM));
    assertEquals(4, d.getCountNamesByLanguage(Language.DANISH));
    assertEquals(132, d.getCountNamesByLanguage(Language.GERMAN));
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:16,代码来源:DatasetMetricsServiceMyBatisIT.java


示例14: testGet

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testGet() {
    Description description = service.get(26);
    assertEquals((Integer) 100000040, description.getSourceTaxonKey());
    assertEquals(
            "The Caucasian squirrel (or Persian squirrel) is a tree squirrel in the genus Sciurus endemic to Armenia, Azerbaijan, Georgia, Greece, Iran, Iraq, Israel, Jordan, Lebanon, Syria, and Turkey. Its natural habitat is temperate broadleaf and mixed forests.[1]",
            description.getDescription());
    assertEquals(Language.ENGLISH, description.getLanguage());
    assertEquals("general", description.getType());
    assertNull(description.getSource());
    assertNull(description.getContributor());
    assertNull(description.getCreator());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:14,代码来源:DescriptionServiceMyBatisIT.java


示例15: listTopicEntries

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
/**
 * @return map of all topics for a given language with a list of entry keys for each language
 */
@JsonIgnore
public Map<String, List<Integer>> listTopicEntries(Language lang) {
  if (toc.containsKey(lang)) {
    return toc.get(lang);
  }
  return Maps.newHashMap();
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:11,代码来源:TableOfContents.java


示例16: testEquals

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testEquals() {
  Description d1 = new Description();
  d1.setLanguage(Language.ENGLISH);
  d1.setType("morphology");

  Description d2 = new Description();
  d2.setLanguage(Language.ENGLISH);
  d2.setType("morphology");

  assertEquals(d1, d2);

}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:14,代码来源:DescriptionTest.java


示例17: testValidations

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Test
public void testValidations() {
  ValidatorFactory validatorFactory =
    Validation.byProvider(ApacheValidationProvider.class).configure().buildValidatorFactory();
  Validator validator = validatorFactory.getValidator();

  Organization org = new Organization();
  org.setTitle("a");  // too short
  org.setHomepage(Lists.newArrayList(URI.create("www.gbif.org"))); // doesn't start with http or https
  org.setLogoUrl(URI.create("file:///tmp/aha")); // bad http URI

  // perform validation
  Set<ConstraintViolation<Organization>> violations = validator.validate(org);
  assertTrue("Violations were expected", !violations.isEmpty());

  // ensure all expected properties are caught
  Set<String> propertiesInViolation = Sets.newHashSet("title", "logoUrl");
  for (ConstraintViolation<?> cv : violations) {
    propertiesInViolation.remove(cv.getPropertyPath().toString());
  }
  assertTrue("Properties incorrectly passed validation " + propertiesInViolation, propertiesInViolation.isEmpty());

  // fix validation problems
  org.setTitle("Academy of Natural Sciences");
  org.setHomepage(Lists.newArrayList(URI.create("http://www.gbif.org")));
  org.setLogoUrl(URI.create("http://www.gbif.org/logo.png"));
  org.setLanguage(Language.ENGLISH);
  org.setEndorsingNodeKey(UUID.randomUUID());

  // perform validation again
  violations = validator.validate(org);
  assertTrue("No violations were expected", violations.isEmpty());
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:34,代码来源:OrganizationTest.java


示例18: setVernacularName

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
public void setVernacularName(VernacularName vernacularName)
throws RuntimeException
   {
NameUsage<? extends VernacularNameUsage> n = getNameUsage();
if(n != this) {
    if(n instanceof VernacularNameUsage) {
	((VernacularNameUsage)n).setVernacularName(vernacularName);
    }
    return;
}

if(this.vernacularName == vernacularName)
    return;

clearVernacularName();
if(vernacularName != null) {
    setLiteral(vernacularName.getVernacularName());
    Language language = vernacularName.getLanguage();
    Country country = vernacularName.getCountry();
    String languageCode = (language == null)? null:language.getIso3LetterCode();
    String countryCode = (country == null)? null:country.getIso3LetterCode();
    if(languageCode != null)  {
	Locale locale = null;
	Set<Locale> locales = Locales.get(languageCode, countryCode);
	for(Locale l : locales) {
	    String variant = l.getVariant();
	    if(variant == null || variant.length() ==0) {
		locale = l;
		break;
	    }
	}
	setLocale(locale);
    }
    String source = vernacularName.getSource();
    if(source != null) {
	Publication publication = new Publication();
	publication.setCitationTitle(source);
	Appearance appearance = new Appearance();
	appearance.setAppearance(source);
	appearance.setPublication(publication);
	setAppearance(appearance);
    }
}
this.vernacularName = vernacularName;
   }
 
开发者ID:nomencurator,项目名称:taxonaut,代码行数:46,代码来源:VernacularNameUsage.java


示例19: fromEnum

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Override
public String fromEnum(Language value) {
  return value == null || value == Language.UNKNOWN  ? null : value.getIso2LetterCode();
}
 
开发者ID:gbif,项目名称:common-mybatis,代码行数:5,代码来源:LanguageConverter.java


示例20: toEnum

import org.gbif.api.vocabulary.Language; //导入依赖的package包/类
@Override
public Language toEnum(String key) {
  return Language.fromIsoCode(key);
}
 
开发者ID:gbif,项目名称:common-mybatis,代码行数:5,代码来源:LanguageConverter.java



注:本文中的org.gbif.api.vocabulary.Language类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CommandOverload类代码示例发布时间:2022-05-22
下一篇:
Java ServletRequestHandledEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap