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

Java MarcReader类代码示例

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

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



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

示例1: readMARCRecords

import org.marc4j.MarcReader; //导入依赖的package包/类
private Sequence readMARCRecords(final MarcReader aReader) throws XPathException {
    final MemTreeBuilder builder = context.getDocumentBuilder();
    final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder);
    final SAXResult saxResult = new SAXResult(receiver);
    final MarcWriter writer = new MarcXmlWriter(saxResult);

    writer.setConverter(new AnselToUnicode());

    while (aReader.hasNext()) {
        final Record record = aReader.next();
        final String recordId = record.getControlNumber();

        if (LOGGER.isDebugEnabled() && recordId != null) {
            LOGGER.debug("Reading MARC record: " + recordId);
        }

        writer.write(record);
    }

    writer.close();

    return (DocumentImpl) receiver.getDocument();
}
 
开发者ID:ksclarke,项目名称:freelib-marc4j-exist,代码行数:24,代码来源:ReadFromFile.java


示例2: read

import org.marc4j.MarcReader; //导入依赖的package包/类
public static List<Record> read(String fileName) throws Exception {
	InputStream in = new FileInputStream(fileName);
	MarcReader reader = new MarcStreamReader(in);

	List<Record> records = new ArrayList<>();
	while (reader.hasNext()) {
		Record marc4jRecord = reader.next();
		records.add(marc4jRecord);
		// System.out.println(record.toString());
	}
	return records;
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:13,代码来源:ReadMarc.java


示例3: getReader

import org.marc4j.MarcReader; //导入依赖的package包/类
public static MarcReader getReader(String fileName, boolean isMarcxml, boolean isLineSeaparated) throws Exception {
	MarcReader reader = null;
	if (isLineSeaparated)
		reader = ReadMarc.getLineSeparatedMarcReader(fileName);
	else
		reader = (isMarcxml) ? ReadMarc.getXmlReader(fileName) : ReadMarc.getStreamReader(fileName);

	return reader;
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:10,代码来源:ReadMarc.java


示例4: main

import org.marc4j.MarcReader; //导入依赖的package包/类
public static void main(String[] args) throws ParseException {

		final Validator validator = new Validator(args);
		ValidatorParameters params = validator.getParameters();
		validator.setDoPrintInProcessRecord(false);

		logger.info("Input file is " + params.getArgs());
		SparkConf conf = new SparkConf().setAppName("MarcCompletenessCount");
		JavaSparkContext context = new JavaSparkContext(conf);

		System.err.println(validator.getParameters().formatParameters());

		JavaRDD<String> inputFile = context.textFile(validator.getParameters().getArgs()[0]);

		JavaRDD<String> baseCountsRDD = inputFile
			.flatMap(content -> {
				MarcReader reader = ReadMarc.getMarcStringReader(content);
				Record marc4jRecord = reader.next();
				MarcRecord marcRecord = MarcFactory.createFromMarc4j(
					marc4jRecord, params.getDefaultRecordType(), params.getMarcVersion(), params.fixAlephseq());
				validator.processRecord(marcRecord, 1);
				return ValidationErrorFormatter
					.formatForSummary(marcRecord.getValidationErrors(), params.getFormat())
					.iterator();
			}
		);
		baseCountsRDD.saveAsTextFile(validator.getParameters().getFileName());
	}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:29,代码来源:ParallelValidator.java


示例5: toMarcXml

import org.marc4j.MarcReader; //导入依赖的package包/类
/** Converts Marc21 to MarcXML */
public static Document toMarcXml(byte[] marc21, String charset) {
    MarcReader reader = new MarcStreamReader(new ByteArrayInputStream(marc21), charset);
    DOMResult result = new DOMResult();
    MarcXmlWriter writer = new MarcXmlWriter(result);
    if (reader.hasNext()) {
        Record record = reader.next();
        writer.write(record);
    }
    writer.close();

    Document retval = (Document) result.getNode();
    return retval;
}
 
开发者ID:proarc,项目名称:proarc,代码行数:15,代码来源:Z3950Client.java


示例6: convertRawMarcToXML

import org.marc4j.MarcReader; //导入依赖的package包/类
/**
 * @param inputFile
 * @return converted marc xml File Name
 * @throws java.io.FileNotFoundException This method takes in a raw marc file and converts into a marc xml file.
 */
public String convertRawMarcToXML(File inputFile) throws FileNotFoundException {
    InputStream input = new FileInputStream(inputFile);
    String fileName = inputFile.getName().replace(".mrc", ".xml");
    FileOutputStream fileOutputStream = new FileOutputStream(new File(fileName));
    MarcReader reader = new MarcStreamReader(input);
    MarcWriter writer = new MarcXmlWriter(fileOutputStream, true);

    while (reader.hasNext()) {
        Record record = reader.next();
        writer.write(record);
    }
    writer.close();
    return fileName;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:20,代码来源:MarcXMLConverter.java


示例7: convert

import org.marc4j.MarcReader; //导入依赖的package包/类
/**
 * @param content
 * @return converted marc xml
 */
public String convert(String content) {
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content.getBytes());
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

    MarcReader reader = new MarcStreamReader(byteArrayInputStream);
    MarcWriter writer = new MarcXmlWriter(byteArrayOutputStream, true);

    while (reader.hasNext()) {
        Record record = reader.next();
        writer.write(record);
    }
    writer.close();
    return new String(byteArrayOutputStream.toByteArray());
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:19,代码来源:MarcXMLConverter.java


示例8: next

import org.marc4j.MarcReader; //导入依赖的package包/类
@Override
public Record next() {
	InputStream is = new ByteArrayInputStream(line.getBytes());
	MarcReader reader = new MarcStreamReader(is);
	Record marc4jRecord = null;
	if (reader.hasNext()) {
		marc4jRecord = reader.next();
	}
	nextIsConsumed = true;
	return marc4jRecord;
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:12,代码来源:LineSeparatedMarcReader.java


示例9: getStreamReader

import org.marc4j.MarcReader; //导入依赖的package包/类
public static MarcReader getStreamReader(String fileName) throws Exception {
	InputStream in = new FileInputStream(fileName);
	MarcReader reader = new MarcStreamReader(in);
	return reader;
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:6,代码来源:ReadMarc.java


示例10: getXmlReader

import org.marc4j.MarcReader; //导入依赖的package包/类
public static MarcReader getXmlReader(String fileName) throws Exception {
	InputStream in = new FileInputStream(fileName);
	MarcReader reader = new MarcXmlReader(in);
	return reader;
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:6,代码来源:ReadMarc.java


示例11: getLineSeparatedMarcReader

import org.marc4j.MarcReader; //导入依赖的package包/类
public static MarcReader getLineSeparatedMarcReader(String fileName) throws Exception {
	MarcReader reader = new LineSeparatedMarcReader(fileName);
	return reader;
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:5,代码来源:ReadMarc.java


示例12: getMarcStringReader

import org.marc4j.MarcReader; //导入依赖的package包/类
public static MarcReader getMarcStringReader(String content) throws Exception {
	InputStream is = new ByteArrayInputStream(content.getBytes());
	MarcReader reader = new MarcStreamReader(is);
	return reader;
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:6,代码来源:ReadMarc.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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