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

Java Term类代码示例

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

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



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

示例1: mapField

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
@Override
public final void mapField(final Identifier object, final String fieldName,
		final String value) throws BindException {

	super.mapField(object, fieldName, value);
	Term term = getTermFactory().findTerm(fieldName);
	if (term instanceof DcTerm) {
		DcTerm dcTerm = (DcTerm) term;
		switch (dcTerm) {
		case format:
			object.setFormat(value);
			break;
		case identifier:
			object.setIdentifier(value);
			break;
		case subject:
			object.setSubject(value);
			break;
		case title:
			object.setTitle(value);
			break;
		default:
			break;
		}
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:27,代码来源:FieldSetMapper.java


示例2: buildField

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
/**
 * Build an ArchiveField object based on xml attributes.
 */
private ArchiveField buildField(Attributes attributes) {
	// build field
	Term term = TermFactory.findTerm(getAttr(attributes, "term"));
	String defaultValue = getAttr(attributes, "default");
	DataType type = DataType.findByXmlSchemaType(getAttr(attributes, "type"));
	if (type == null) {
		type = DataType.string;
	}
	String indexAsString = getAttr(attributes, "index");
	Integer index = null;
	if (indexAsString != null) {
		// let bad errors be thrown up
		try {
			index = Integer.parseInt(indexAsString);
		} catch (NumberFormatException e) {
			throw new UnsupportedArchiveException(e);
		}
	}
	return new ArchiveField(index, term, defaultValue, type);
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:24,代码来源:ArchiveFactory.java


示例3: toParameter

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
private String toParameter(Collection<Term> terms) {

		StringBuffer stringBuffer = new StringBuffer();
		if (terms != null && !terms.isEmpty()) {
			boolean isFirst = true;
			for (Term term : terms) {
				if(!isFirst) {
					stringBuffer.append(",");
				} else {
					isFirst = false;
				}
				stringBuffer.append(term.simpleName());
			}
		}
		return stringBuffer.toString();
	}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:17,代码来源:FlatFileCreatorIntegrationTest.java


示例4: toParameter

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
private String toParameter(Collection<Term> terms) {

		StringBuffer stringBuffer = new StringBuffer();
		if (terms != null && !terms.isEmpty()) {
			boolean isFirst = true;
			for (Term term : terms) {
				if(!isFirst) {
					stringBuffer.append(",");
				} else {
					isFirst = false;
				}
				stringBuffer.append(term.qualifiedName());
			}
		}
		return stringBuffer.toString();
	}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:17,代码来源:DwcaCreationIntegrationTest.java


示例5: getPropertyMap

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
public static Map<Term, String> getPropertyMap(Term conceptTerm) {
	if(conceptTerm.equals(DwcTerm.Taxon)) {
		return taxonTerms;
	} else if(conceptTerm.equals(GbifTerm.Description)) {
		return descriptionTerms;
	} else if(conceptTerm.equals(GbifTerm.Distribution)) {
		return distributionTerms;
	} else if(conceptTerm.equals(GbifTerm.Identifier)) {
		return identifierTerms;
	} else if(conceptTerm.equals(DwcTerm.MeasurementOrFact)) {
		return measurementOrFactTerms;
	} else if(conceptTerm.equals(GbifTerm.VernacularName)) {
		return vernacularNameTerms;
	} else if(conceptTerm.equals(GbifTerm.Image)) {
		return imageTerms;
	} else if(conceptTerm.equals(GbifTerm.TypesAndSpecimen)) {
		return typeAndSpecimenTerms;
	} else if(conceptTerm.equals(GbifTerm.Reference)) {
		return referenceTerms;
	} else if(conceptTerm.equals(SkosTerm.Concept)) {
		return skosTerms;
	} else {
		throw new IllegalArgumentException(conceptTerm.qualifiedName() + " is not a supported term");
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:26,代码来源:DarwinCorePropertyMap.java


示例6: getPropertyMap

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
public static Map<Term, String> getPropertyMap(Term conceptTerm) {
	if(conceptTerm.equals(DwcTerm.Taxon)) {
		return taxonTerms;
	} else if(conceptTerm.equals(GbifTerm.Description)) {
		return descriptionTerms;
	} else if(conceptTerm.equals(GbifTerm.Distribution)) {
		return distributionTerms;
	} else if(conceptTerm.equals(GbifTerm.Identifier)) {
		return identifierTerms;
	} else if(conceptTerm.equals(DwcTerm.MeasurementOrFact)) {
		return measurementOrFactTerms;
	} else if(conceptTerm.equals(GbifTerm.VernacularName)) {
		return vernacularNameTerms;
	} else if(conceptTerm.equals(ExtendedAcTerm.Multimedia)) {
		return imageTerms;
	} else if(conceptTerm.equals(GbifTerm.TypesAndSpecimen)) {
		return typeAndSpecimenTerms;
	} else if(conceptTerm.equals(GbifTerm.Reference)) {
		return referenceTerms;
	} else if(conceptTerm.equals(SkosTerm.Concept)) {
		return skosTerms;
	} else {
		throw new IllegalArgumentException(conceptTerm.qualifiedName() + " is not a supported term");
	}
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:26,代码来源:DarwinCorePropertyMap.java


示例7: read

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
/**
 *
 * @return
 * @throws IOException
 */
public TermTabularDataLine read() throws IOException {
  List<String> tabularLine = tabularDataFileReader.read();

  // check for end of file
  if(tabularLine == null){
    return null;
  }
  int numOfColumns = Math.min(columnMapping.length, tabularLine.size());
  Map<Term, String> line = Maps.newHashMapWithExpectedSize(numOfColumns);
  for (int i = 0; i < numOfColumns; i++) {
    line.put(columnMapping[i], tabularLine.get(i));
  }
  lineNumber++;

  //if the line contains more data than the number of declared column, set it as unamppedData
  if(tabularLine.size() > columnMapping.length) {
    return new TermTabularDataLine(lineNumber, line, tabularLine.size() ,
            tabularLine.subList(columnMapping.length, tabularLine.size()));
  }
  return new TermTabularDataLine(lineNumber, line, tabularLine.size());
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:27,代码来源:TermTabularDataFileReader.java


示例8: buildField

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
/**
 * Build an ArchiveField object based on xml attributes.
 */
private ArchiveField buildField(Attributes attributes) {
  // build field
  Term term = TERM_FACTORY.findTerm(getAttr(attributes, "term"));
  String defaultValue = getAttr(attributes, "default");
  String vocabulary = getAttr(attributes, "vocabulary");
  ArchiveField.DataType type = ArchiveField.DataType.findByXmlSchemaType(getAttr(attributes, "type"));
  if (type == null) {
    type = ArchiveField.DataType.string;
  }
  String indexAsString = getAttr(attributes, "index");
  Integer index = null;
  if (indexAsString != null) {
    // let bad errors be thrown up
    try {
      index = Integer.parseInt(indexAsString);
    } catch (NumberFormatException e) {
      throw new UnsupportedArchiveException(e);
    }
  }
  String delimiter = getAttr(attributes, "delimitedBy");
  return new ArchiveField(index, term, defaultValue, type, delimiter, vocabulary);
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:26,代码来源:MetaXMLSaxHandler.java


示例9: RecordIterator

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
/**
 * @param replaceNulls if true record values will have literal nulls replaced with NULL.
 * @param replaceEntities if true html & xml entities in record values will be replaced with the interpreted value.
 */
public RecordIterator(ClosableIterator<String[]> recordSource, ArchiveField id, Map<Term, ArchiveField> fields,
  Term rowType, boolean replaceNulls, boolean replaceEntities) {
  this.id = id;
  this.fields = fields;
  this.rowType = rowType;
  this.replaceNulls = replaceNulls;
  this.replaceEntities = replaceEntities;
  closable = recordSource;
  if (closable == null) {
    Iterator<String[]> empty = Iterators.emptyIterator();
    iter = Iterators.peekingIterator(empty);
  } else {
    iter = Iterators.peekingIterator(closable);
  }
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:20,代码来源:RecordIterator.java


示例10: next

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
public DarwinCoreRecord next() {
  DarwinCoreRecord dwc = new DarwinCoreRecord();
  lineCount++;
  try {
    for (Term term : mappedTerms) {
      dwc.setProperty(term, record.value(term));
    }
    dwc.setId(record.id());
    // read next line to see if it exists at all
    record.setRow(coreReader.next());
    if (!record.hasRow()) {
      hasNext = false;
    }

  } catch (Exception e) {
    LOG.warn("Bad row somewhere around core line: {}", lineCount, e);
  }
  return dwc;
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:20,代码来源:Archive.java


示例11: close

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
@Override
public void close() {
  coreIter.close();
  for (ClosableIterator<Record> it : closables) {
    try {
      it.close();
    } catch (Exception e) {
      LOG.debug("Can't close ClosableIterator", e);
    }
  }
  for (Map.Entry<Term, Integer> stringIntegerEntry : extensionRecordsSkipped.entrySet()) {
    Integer skipped = stringIntegerEntry.getValue();
    if (skipped > 0) {
      LOG.debug("{} {} extension records without matching core", skipped, stringIntegerEntry.getKey());
    }
  }
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:18,代码来源:Archive.java


示例12: getHeader

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
/**
 * Deprecated: use getFieldsSorted(), see https://github.com/gbif/dwca-io/issues/41 for details
 *
 * Generates an ordered array representing all the {@link Term} matching the position in the underlying file.
 * The array can contain {@code null} if no {@link Term} is mapped at a specific position.
 * The size of the array is defined by the maximum index used within {@link ArchiveField} + 1 (since indices are 0
 * based).
 *
 * @return Array of {@link Term} representing the header or an empty Array if no headers are present.
 */
@Deprecated
public Term[] getHeader() {
  List<ArchiveField> archiveFieldsWithIndex = getFieldsSorted()
          .stream().filter(af -> af.getIndex() != null)
          .collect(Collectors.toList());

  Optional<Integer> idIndex = id != null ? Optional.of(id.getIndex()) : Optional.empty();

  if(archiveFieldsWithIndex.isEmpty() && !idIndex.isPresent()){
    return new Term[0];
  }

  int maxIndex = archiveFieldsWithIndex.stream()
          .mapToInt(ArchiveField::getIndex).max().getAsInt();
  maxIndex = Math.max(maxIndex, idIndex.orElse(-1));

  Term[] terms = new Term[maxIndex + 1];
  // handle id column, assign default Term, it will be rewritten below if assigned to a term
  idIndex.ifPresent(idx -> terms[idx] = DEFAULT_ID_TERM);
  archiveFieldsWithIndex.stream().forEach(af -> terms[af.getIndex()] = af.getTerm());
  return terms;
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:33,代码来源:ArchiveFile.java


示例13: writeRow

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
private void writeRow(Map<Term, String> rowMap, Term rowType) throws IOException {
  TabWriter writer = writers.get(rowType);
  List<Term> columns = terms.get(rowType);
  if (useHeaders && !headersOut.contains(rowType)){
    // write header row
    writeHeader(writer, rowType, columns);
  }

  // make sure coreId is not null for extensions
  if (coreRowType != rowType && coreId == null){
    log.warn("Adding an {} extension record to a core without an Id! Skip this record", rowType);

  } else {
    String[] row = new String[columns.size() + 1];
    row[0] = coreId;
    for (Map.Entry<Term, String> conceptTermStringEntry : rowMap.entrySet()) {
      int column = 1 + columns.indexOf(conceptTermStringEntry.getKey());
      row[column] = conceptTermStringEntry.getValue();
    }
    writer.write(row);
  }
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:23,代码来源:DwcaWriter.java


示例14: writeHeader

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
private void writeHeader(TabWriter writer, Term rowType, List<Term> columns) throws IOException {
  int idx = 0;
  String[] row = new String[columns.size() + 1];
  Term idTerm;
  if (DwcTerm.Taxon == coreRowType){
    idTerm = DwcTerm.taxonID;
  } else if (DwcTerm.Occurrence == coreRowType){
    idTerm = DwcTerm.occurrenceID;
  } else if (DwcTerm.Identification == coreRowType){
    idTerm = DwcTerm.identificationID;
  } else if (DwcTerm.Event == coreRowType){
    idTerm = DwcTerm.eventID;
  } else {
    // default to generic dc identifier for id column
    idTerm = DcTerm.identifier;
  }
  row[idx] = idTerm.simpleName();

  for (Term term : columns) {
    idx ++;
    row[idx] = term.simpleName();
  }
  writer.write(row);

  headersOut.add(rowType);
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:27,代码来源:DwcaWriter.java


示例15: addCoreColumn

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
/**
 * Add a single value for the current core record.
 * Calling this method requires that #newRecord() has been called at least once,
 * otherwise an IllegalStateException is thrown.
 * @param term
 * @param value
 */
public void addCoreColumn(Term term, String value) {
  // ensure we do not overwrite the coreIdTerm if one is defined
  if (coreIdTerm != null && coreIdTerm.equals(term)) {
    throw new IllegalStateException("You cannot add a term that was specified as coreId term");
  }
  
  List<Term> coreTerms = terms.get(coreRowType);
  if (!coreTerms.contains(term)) {
    if (useHeaders && recordNum>1){
      throw new IllegalStateException("You cannot add new terms after the first row when headers are enabled");
    }
    coreTerms.add(term);
  }
  try {
    coreRow.put(term, value);
  } catch (NullPointerException e) {
    // no core record has been started yet
    throw new IllegalStateException("No core record has been created yet. Call newRecord() at least once");
  }
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:28,代码来源:DwcaWriter.java


示例16: testHeaders3

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testHeaders3() throws Exception {
  File dwcaDir = FileUtils.createTempDir();
  dwcaDir.deleteOnExit();
  DwcaWriter writer = new DwcaWriter(DwcTerm.Taxon, dwcaDir, true);

  writer.newRecord("dummy1");
  writer.addCoreColumn(DwcTerm.parentNameUsageID);
  writer.addCoreColumn(DwcTerm.acceptedNameUsageID);

  // define extension columns
  Map<Term, String> eData = Maps.newHashMap();
  eData.put(DwcTerm.locality, "locality1");
  eData.put(DwcTerm.occurrenceStatus, "present");
  writer.addExtensionRecord(GbifTerm.Distribution, eData);

  eData.put(DwcTerm.establishmentMeans, "alien");
  writer.addExtensionRecord(GbifTerm.Distribution, eData);
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:20,代码来源:DwcaWriterTest.java


示例17: addExtensionRecord

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
/**
 * Add an extension record associated with the current core record.
 * 
 * @param rowType
 * @param row
 * @throws IOException
 */
public void addExtensionRecord(Term rowType, Map<Term, String> row) throws IOException {
  // make sure we know the extension rowtype
  if (!terms.containsKey(rowType)) {
    addRowType(rowType);
  }
  
  // make sure we know all terms
  List<Term> knownTerms = terms.get(rowType);
  final boolean isFirst = knownTerms.isEmpty();
  for (Term term : row.keySet()) {
    if (!knownTerms.contains(term)) {
      if (useHeaders && !isFirst){
        throw new IllegalStateException("You cannot add new terms after the first row when headers are enabled");
      }
      knownTerms.add(term);
    }
  }

  // write extension record
  writeRow(row, rowType);
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:29,代码来源:DwcaWriter.java


示例18: testDetermineRecordIdentifier

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
@Test
public void testDetermineRecordIdentifier() {
  Optional<Term> id = InternalDwcFileFactory.determineRecordIdentifier(Arrays.asList(DwcTerm.decimalLatitude, DwcTerm.occurrenceID));
  assertEquals(DwcTerm.occurrenceID, id.get());

  id = InternalDwcFileFactory.determineRecordIdentifier(Arrays.asList(DwcTerm.taxonID, DwcTerm.scientificName));
  assertEquals(DwcTerm.taxonID, id.get());

  //eventId should be picked even if taxonID is there
  id = InternalDwcFileFactory.determineRecordIdentifier(Arrays.asList(DwcTerm.eventID, DwcTerm.scientificName, DwcTerm.taxonID));
  assertEquals(DwcTerm.taxonID, id.get());

  id = InternalDwcFileFactory.determineRecordIdentifier(Arrays.asList(DwcTerm.decimalLongitude, DwcTerm.scientificName,
          DcTerm.identifier));
  assertEquals(DcTerm.identifier, id.get());

  //eventId should be picked even if taxonID is there
  id = InternalDwcFileFactory.determineRecordIdentifier(Arrays.asList(DwcTerm.decimalLongitude, DwcTerm.scientificName, DwcTerm.decimalLatitude));
  assertFalse(id.isPresent());
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:21,代码来源:InternalDwcFileFactoryTest.java


示例19: createMeasurement

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
/**
 * @param taxon
 *            Set the taxon
 * @param text
 *            Set the text
 * @param feature
 *            Set the fact
 * @param reference
 *            Set the reference
 */
private void createMeasurement(Taxon taxon, String text, Term measurement){
	MeasurementOrFact fact = new MeasurementOrFact();
	fact.setMeasurementValue(text);
	fact.setIdentifier(UUID.randomUUID().toString());
	fact.setTaxon(taxon);
	fact.setMeasurementType(measurement);
	fact.setAuthority(taxon.getAuthority());
	taxon.getMeasurementsOrFacts().add(fact);

}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:21,代码来源:TestDataManager.java


示例20: toParameter

import org.gbif.dwc.terms.Term; //导入依赖的package包/类
private String toParameter(Collection<Term> terms) {
	StringBuffer stringBuffer = new StringBuffer();
	if (terms != null && !terms.isEmpty()) {
		boolean isFirst = true;
		for (Term term : terms) {
			if(!isFirst) {
				stringBuffer.append(",");
			} else {
				isFirst = false;
			}
			stringBuffer.append(term.qualifiedName());
		}
	}
	return stringBuffer.toString();
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:16,代码来源:DownloadServiceImpl.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java SwitchStmt类代码示例发布时间:2022-05-22
下一篇:
Java BenchmarkHistoryChart类代码示例发布时间: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