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

Java TermFactory类代码示例

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

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



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

示例1: testGetVerbatim

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
@Test
public void testGetVerbatim() {
  VerbatimOccurrence expected = new VerbatimOccurrence();
  expected.setKey(KEY);
  expected.setDatasetKey(DATASET_KEY);
  expected.setPublishingOrgKey(PUBLISHING_ORG_KEY);
  expected.setPublishingCountry(PUB_COUNTRY);
  expected.setLastCrawled(LAST_CRAWLED);
  expected.setLastParsed(LAST_PARSED);
  expected.setCrawlId(CRAWL_ID);
  expected.setProtocol(PROTOCOL);
  addTerms(expected, TERM_VALUE_PREFIX);
  assertTrue(expected.hasVerbatimField(DwcTerm.basisOfRecord));

  VerbatimOccurrence verb = occurrenceService.getVerbatim(KEY);
  assertNotNull(verb);
  assertNotNull(verb.getLastParsed());
  assertEquivalence(expected, verb);
  assertTrue(verb.hasVerbatimField(DwcTerm.basisOfRecord));
  Term term = TermFactory.instance().findTerm("fancyUnknownTerm");
  assertTrue(verb.hasVerbatimField(term));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:23,代码来源:OccurrencePersistenceServiceImplTest.java


示例2: testDwcXMLDocumentTryAppend

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
@Test
public void testDwcXMLDocumentTryAppend() throws ParserConfigurationException {

  DwcXMLDocument doc = DwcXMLDocument.newInstance(DwcTerm.Occurrence);
  assertTrue(doc.tryAppend(DwcTerm.behavior, "calm"));
  // This UnknownTerm should be ignored
  assertFalse(doc.tryAppend(TermFactory.instance().findTerm("myTerm"), "my term value"));

  Document xmlDoc = doc.getDocument();
  assertEquals(1, xmlDoc.getChildNodes().getLength());

  Node occurrenceElement = xmlDoc.getChildNodes().item(0);
  assertEquals("Occurrence element has only one child", 1, occurrenceElement.getChildNodes().getLength());
  Node firstChild = occurrenceElement.getFirstChild();

  assertEquals(DwcTerm.PREFIX + ":" + DwcTerm.behavior.simpleName(), firstChild.getNodeName());
  assertEquals("calm", firstChild.getTextContent());
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:19,代码来源:DwcXMLDocumentTest.java


示例3: testOccurrenceXML

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
@Test
public void testOccurrenceXML() throws IOException {
  MessageBodyWriter<Occurrence> occurrenceDwcXMLBodyWriter = new OccurrenceDwcXMLBodyWriter();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  Occurrence occ = new Occurrence();

  occ.setCountry(Country.MADAGASCAR);
  occ.setVerbatimField(DwcTerm.verbatimLocality, "mad");
  occ.setReferences(URI.create("http://www.gbif.org"));

  Term customTerm = TermFactory.instance().findTerm("MyTerm");
  occ.setVerbatimField(customTerm, "MyTerm value");

  occurrenceDwcXMLBodyWriter.writeTo(occ, null, null, null, null, null, baos);

  String expectedContent = IOUtils.toString(new FileInputStream(FileUtils.getClasspathFile("dwc_xml/occurrence.xml")));
  assertEquals(CharMatcher.WHITESPACE.removeFrom(expectedContent), CharMatcher.WHITESPACE.removeFrom(baos.toString()));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:19,代码来源:OccurrenceDwcXMLBodyWriterTest.java


示例4: addJsonVerbatimField

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
/**
 * This private method is only for deserialization via jackson and not exposed anywhere else!
 */
@JsonAnySetter
private void addJsonVerbatimField(String key, String value) {
  if(!Strings.isNullOrEmpty(value)) {
    Term t = TermFactory.instance().findTerm(key);
    verbatimFields.put(t, value);
  }
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:11,代码来源:VerbatimOccurrence.java


示例5: testFieldFromTermFactory

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
@Test
public void testFieldFromTermFactory() {
  VerbatimNameUsage occ = new VerbatimNameUsage();
  String prefix = "t_";
  String colName = "t_dwc:basisOfRecord";
  Term term = TermFactory.instance().findTerm(colName.substring(prefix.length()));
  occ.setCoreField(term, "PreservedSpecimen");
  assertEquals(1, occ.getFields().size());
  assertTrue(occ.hasCoreField(DwcTerm.basisOfRecord));
  assertEquals("PreservedSpecimen", occ.getCoreField(DwcTerm.basisOfRecord));
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:12,代码来源:VerbatimNameUsageTest.java


示例6: testFieldFromTermFactory

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
@Test
public void testFieldFromTermFactory() {
  VerbatimOccurrence occ = new VerbatimOccurrence();
  String prefix = "t_";
  String colName = "t_dwc:basisOfRecord";
  Term term = TermFactory.instance().findTerm(colName.substring(prefix.length()));
  occ.setVerbatimField(term, "PreservedSpecimen");
  assertEquals(1, occ.getVerbatimFields().size());
  assertTrue(occ.hasVerbatimField(DwcTerm.basisOfRecord));
  assertEquals("PreservedSpecimen", occ.getVerbatimField(DwcTerm.basisOfRecord));
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:12,代码来源:VerbatimOccurrenceTest.java


示例7: termFromVerbatimColumn

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
/**
 * Returns the term for a strictly verbatim column.
 * If the column given is not a verbatim column, null will be returned.
 */
@Nullable
public static Term termFromVerbatimColumn(byte[] qualifier) {
  checkNotNull(qualifier, "qualifier can't be null");
  String colName = Bytes.toString(qualifier);

  if (!colName.startsWith(VERBATIM_TERM_PREFIX)) {
    // we asked for a verbatim column but this one lacks the verbatim prefix!
    return null;
  }

  // this is a verbatim term column
  return TermFactory.instance().findTerm(colName.substring(VERBATIM_TERM_PREFIX.length()));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:18,代码来源:Columns.java


示例8: testVerbatimOccurrenceXML

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
@Test
public void testVerbatimOccurrenceXML() throws IOException{
  MessageBodyWriter<VerbatimOccurrence> occurrenceDwcXMLBodyWriter = new OccurrenceVerbatimDwcXMLBodyWriter();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  VerbatimOccurrence occ = new VerbatimOccurrence();

  occ.setVerbatimField(DwcTerm.verbatimLocality, "mad");
  Term customTerm = TermFactory.instance().findTerm("MyTerm");
  occ.setVerbatimField(customTerm, "MyTerm value");

  occurrenceDwcXMLBodyWriter.writeTo(occ, null, null, null, null, null, baos);

  String expectedContent = IOUtils.toString(new FileInputStream(FileUtils.getClasspathFile("dwc_xml/verbatim_occurrence.xml")));
  assertEquals(CharMatcher.WHITESPACE.removeFrom(expectedContent), CharMatcher.WHITESPACE.removeFrom(baos.toString()));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:16,代码来源:VerbatimOccurrenceDwcXMLBodyWriterTest.java


示例9: testExtensionTerms

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
@Test
public void testExtensionTerms() throws Exception {
  System.out.println("\n\nEXTENSION TERMS");
  for (Extension e : Extension.values()) {
    Term term = TermFactory.instance().findTerm(e.getRowType());
    System.out.println(term.toString());
    assertTrue(TermUtils.isExtensionTerm(term));
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:10,代码来源:TermUtilsTest.java


示例10: qualifiedNormalisedName

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
public String qualifiedNormalisedName() {
  return TermFactory.normaliseTerm(qualifiedName());
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:4,代码来源:ExtensionProperty.java


示例11: simpleNormalisedName

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
public String simpleNormalisedName() {
  return TermFactory.normaliseTerm(simpleName());
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:4,代码来源:ExtensionProperty.java


示例12: setRowType

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
public void setRowType(String rowType) {
  setRowType(TermFactory.instance().findTerm(rowType));
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:4,代码来源:Extension.java


示例13: addJsonVerbatimField

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
/**
 * This private method is only for deserialization via jackson and not exposed anywhere else!
 */
@JsonAnySetter
private void addJsonVerbatimField(String key, String value) {
  Term t = TermFactory.instance().findTerm(key);
  fields.put(t, value);
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:9,代码来源:VerbatimNameUsage.java


示例14: testParsePreferred

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
@Test
public void testParsePreferred() throws IOException {
  UUID datasetKey = UUID.randomUUID();
  String json = Resources.toString(Resources.getResource("fragment.json"), Charsets.UTF_8);
  Fragment fragment = new Fragment(datasetKey, json.getBytes("UTF-8"), DigestUtils.md5(json.getBytes("UTF-8")),
    Fragment.FragmentType.JSON, EndpointType.DWC_ARCHIVE, new Date(), 1,
    OccurrenceSchemaType.DWCA, null, null);
  VerbatimOccurrence verb = JsonFragmentParser.parseRecord(fragment);
  assertNotNull(verb);

  assertEquals("Plantae", verb.getVerbatimField(DwcTerm.kingdom));
  assertNull(verb.getVerbatimField(DwcTerm.scientificNameAuthorship));
  assertEquals("2400", verb.getVerbatimField(DwcTerm.minimumElevationInMeters));
  assertEquals("Magnoliophyta", verb.getVerbatimField(DwcTerm.phylum));
  assertEquals("BGBM", verb.getVerbatimField(DwcTerm.institutionCode));
  assertEquals("specimen", verb.getVerbatimField(DwcTerm.basisOfRecord));
  assertEquals("Verbascum cheiranthifolium var. cheiranthifolium", verb.getVerbatimField(DwcTerm.scientificName));
  assertEquals("Pontaurus", verb.getVerbatimField(DwcTerm.collectionCode));
  assertEquals("Markus Döring", verb.getVerbatimField(DwcTerm.recordedBy));
  assertNull(verb.getVerbatimField(DwcTerm.locality));
  assertEquals("7", verb.getVerbatimField(DwcTerm.month));
  assertEquals("988", verb.getVerbatimField(DwcTerm.catalogNumber));
  assertEquals("37.42123", verb.getVerbatimField(DwcTerm.decimalLatitude));
  assertEquals("1999", verb.getVerbatimField(DwcTerm.year));
  assertEquals("Verbascum", verb.getVerbatimField(DwcTerm.genus));
  assertEquals("Markus Döring", verb.getVerbatimField(DwcTerm.identifiedBy));
  assertEquals("Scrophulariales", verb.getVerbatimField(DwcTerm.order));
  assertEquals("30", verb.getVerbatimField(DwcTerm.day));
  assertEquals("Fake", verb.getVerbatimField(DwcTerm.country));
  assertEquals("TR", verb.getVerbatimField(DwcTerm.countryCode));
  assertEquals("34.5681234", verb.getVerbatimField(DwcTerm.decimalLongitude));
  assertEquals("Magnoliopsida", verb.getVerbatimField(DwcTerm.class_));
  assertEquals("Scrophulariaceae", verb.getVerbatimField(DwcTerm.family));
  assertEquals("Asia", verb.getVerbatimField(DwcTerm.continent));
  assertNull(verb.getVerbatimField(TermFactory.instance().findTerm("extensions")));

  // test image extension
  for (Extension ext : Extension.values()) {
    if (ext == Extension.IMAGE) continue;
    assertFalse(verb.getExtensions().containsKey(ext));
  }
  assertTrue(verb.getExtensions().containsKey(Extension.IMAGE));
  assertEquals(1, verb.getExtensions().get(Extension.IMAGE).size());
  assertEquals("http://digit.snm.ku.dk/www/Aves/full/AVES-100348_Caprimulgus_pectoralis_fervidus_ad____f.jpg", verb.getExtensions().get(Extension.IMAGE).get(0).get(DcTerm.identifier));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:46,代码来源:JsonFragmentParserTest.java


示例15: apply

import org.gbif.dwc.terms.TermFactory; //导入依赖的package包/类
@Nullable
@Override
public Term apply(@Nullable Extension e) {
  return TermFactory.instance().findTerm(e.getRowType());
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:6,代码来源:TermUtils.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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