本文整理汇总了Java中org.gbif.dwc.terms.Term类的典型用法代码示例。如果您正苦于以下问题:Java Term类的具体用法?Java Term怎么用?Java Term使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Term类属于org.gbif.dwc.terms包,在下文中一共展示了Term类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
}
示例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);
}
示例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();
}
示例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();
}
示例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");
}
}
示例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");
}
}
示例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());
}
示例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);
}
示例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);
}
}
示例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;
}
示例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());
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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");
}
}