当前位置: 首页>>代码示例>>Java>>正文


Java UnsupportedArchiveException类代码示例

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


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

示例1: getFirstChar

import org.gbif.dwc.text.UnsupportedArchiveException; //导入依赖的package包/类
private static Character getFirstChar(String x) throws UnsupportedArchiveException {
	if (x == null || x.length() == 0) {
		return null;
	}
	if (x.length() == 1) {
		return x.charAt(0);
	}
	if (x.equalsIgnoreCase("\\t")) {
		return '\t';
	}
	if (x.equalsIgnoreCase("\\n")) {
		return '\n';
	}
	if (x.equalsIgnoreCase("\\r")) {
		return '\r';
	}
	if (x.length() > 1) {
		throw new UnsupportedArchiveException(
				"Only darwin core archives with a single quotation character are supported, but found >>>" + x + "<<<");
	}
	return ' ';
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:23,代码来源:ArchiveFactory.java

示例2: buildArchiveFile

import org.gbif.dwc.text.UnsupportedArchiveException; //导入依赖的package包/类
private ArchiveFile buildArchiveFile(Attributes attr) throws UnsupportedArchiveException {
	ArchiveFile dwcFile = new ArchiveFile();

	// extract the File attributes
	if (getAttr(attr, "encoding") != null) {
		dwcFile.setEncoding(getAttr(attr, "encoding"));
	}
	if (getAttr(attr, "fieldsTerminatedBy") != null) {
		dwcFile.setFieldsTerminatedBy(unescapeBackslash(getAttr(attr, "fieldsTerminatedBy")));
	}
	if (getAttr(attr, "fieldsEnclosedBy") != null) {
		dwcFile.setFieldsEnclosedBy(getFirstChar(getAttr(attr, "fieldsEnclosedBy")));
	}
	if (getAttr(attr, "linesTerminatedBy") != null) {
		dwcFile.setLinesTerminatedBy(unescapeBackslash(getAttr(attr, "linesTerminatedBy")));
	}
	if (getAttr(attr, "rowType") != null) {
		dwcFile.setRowType(getAttr(attr, "rowType"));
	}
	String ignoreHeaderLines = getAttr(attr, "ignoreHeaderLines");
	try {
		dwcFile.setIgnoreHeaderLines(Integer.parseInt(ignoreHeaderLines));
	} catch (NumberFormatException ignored) { // swallow null or bad value
	}
	return dwcFile;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:27,代码来源:ArchiveFactory.java

示例3: buildField

import org.gbif.dwc.text.UnsupportedArchiveException; //导入依赖的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

示例4: openArchive

import org.gbif.dwc.text.UnsupportedArchiveException; //导入依赖的package包/类
/**
 * Opens an archive from a URL, downloading and decompressing it.
 *
 * @param archiveUrl the location of a compressed archive or single data file
 * @param workingDir writable directory to download to and decompress archive
 */
public static Archive openArchive(URL archiveUrl, File workingDir) throws IOException, UnsupportedArchiveException {
	File downloadTo = new File(workingDir, "dwca-download");
	File dwca = new File(workingDir, "dwca");
	DownloadUtil.download(archiveUrl, downloadTo);
	return openArchive(downloadTo, dwca);
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:13,代码来源:ArchiveFactory.java

示例5: readFileHeaders

import org.gbif.dwc.text.UnsupportedArchiveException; //导入依赖的package包/类
private static ArchiveFile readFileHeaders(File dataFile) throws UnsupportedArchiveException, IOException {
	ArchiveFile dwcFile = new ArchiveFile();
	dwcFile.addLocation(null);
	dwcFile.setIgnoreHeaderLines(1);

	CSVReader reader = CSVReaderFactory.build(dataFile);

	// copy found delimiters & encoding
	dwcFile.setEncoding(reader.encoding);
	dwcFile.setFieldsTerminatedBy(reader.delimiter);
	dwcFile.setFieldsEnclosedBy(reader.quoteChar);

	// detect dwc terms as good as we can based on header row
	String[] headers = reader.header;
	int index = 0;
	for (String head : headers) {
		// there are never any quotes in term names - remove them just in case the csvreader didnt recognize them
		if (head != null && head.length() > 1) {
			Term dt = TERM_FACTORY.findTerm(head);
			if (dt != null) {
				ArchiveField field = new ArchiveField(index, dt, null, DataType.string);
				if (dwcFile.getId() == null &&
						(dt.equals(DwcTerm.occurrenceID) || dt.equals(DwcTerm.taxonID) || dt.equals(DcTerm.identifier))) {
					dwcFile.setId(field);
				} else {
					dwcFile.addField(field);
				}
			}
		}
		index++;
	}

	return dwcFile;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:35,代码来源:ArchiveFactory.java

示例6: readMetaDescriptor

import org.gbif.dwc.text.UnsupportedArchiveException; //导入依赖的package包/类
private static void readMetaDescriptor(Archive archive, InputStream metaDescriptor, boolean normaliseTerms)
		throws UnsupportedArchiveException {

	try {
		SAXParser p = SAX_FACTORY.newSAXParser();
		MetaHandler mh = new MetaHandler(archive);
		LOG.debug("Reading archive metadata file");
		//    p.parse(metaDescriptor, mh);
		p.parse(new BomSafeInputStreamWrapper(metaDescriptor), mh);
	} catch (Exception e1) {
		LOG.warn("Exception caught", e1);
		throw new UnsupportedArchiveException(e1);
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:15,代码来源:ArchiveFactory.java

示例7: validateCoreFile

import org.gbif.dwc.text.UnsupportedArchiveException; //导入依赖的package包/类
private static void validateCoreFile(ArchiveFile f, boolean hasExtensions) throws UnsupportedArchiveException {
	if (hasExtensions) {
		if (f.getId() == null) {
			LOG.warn(
					"DwC-A core data file " + f.getTitle() + " is lacking an id column. No extensions allowed in this case");
		}
	}
	validateFile(f);
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:10,代码来源:ArchiveFactory.java

示例8: validateExtensionFile

import org.gbif.dwc.text.UnsupportedArchiveException; //导入依赖的package包/类
private static void validateExtensionFile(ArchiveFile f) throws UnsupportedArchiveException {
	if (f.getId() == null) {
		throw new UnsupportedArchiveException(
				"DwC-A data file " + f.getTitle() + " requires an id or foreign key to the core id");
	}
	validateFile(f);
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:8,代码来源:ArchiveFactory.java

示例9: validateFile

import org.gbif.dwc.text.UnsupportedArchiveException; //导入依赖的package包/类
private static void validateFile(ArchiveFile f) throws UnsupportedArchiveException {
	if (f == null) {
		throw new UnsupportedArchiveException("DwC-A data file is NULL");
	}
	if (f.getLocationFile() == null) {
		throw new UnsupportedArchiveException("DwC-A data file " + f.getTitle() + " requires a location");
	}
	if (f.getEncoding() == null) {
		throw new UnsupportedArchiveException("DwC-A data file " + f.getTitle() + " requires a character encoding");
	}

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

示例10: validateArchive

import org.gbif.dwc.text.UnsupportedArchiveException; //导入依赖的package包/类
private static void validateArchive(Archive archive) throws UnsupportedArchiveException {
	validateCoreFile(archive.getCore(), !archive.getExtensions().isEmpty());
	for (ArchiveFile af : archive.getExtensions()) {
		validateExtensionFile(af);
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:7,代码来源:ArchiveFactory.java


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