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


Java DocumentRecord类代码示例

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


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

示例1: accept

import com.marklogic.client.document.DocumentRecord; //导入依赖的package包/类
@Override
public void accept(DocumentRecord documentRecord) {
	String uri = documentRecord.getUri();
	File outputFile = getOutputFile(documentRecord);
	if (logger.isDebugEnabled()) {
		logger.debug("Writing document with URI " + uri + " to file: " + outputFile);
	}
	try {
		writeDocumentToFile(documentRecord, outputFile);
	} catch (IOException e) {
		String message = "Unable to write document to file; URI: " + uri + "; file: " + outputFile;
		if (logErrors) {
			logger.warn(message, e);
		} else {
			throw new RuntimeException(message, e);
		}
	}
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:19,代码来源:WriteDocumentToFileConsumer.java

示例2: accept

import com.marklogic.client.document.DocumentRecord; //导入依赖的package包/类
@Override
public void accept(DocumentRecord documentRecord) {
	String uri = documentRecord.getUri();
	ZipEntry zipEntry = buildZipEntry(documentRecord);
	synchronized (this.zipOutputStream) {
		try {
			zipOutputStream.putNextEntry(zipEntry);
			if (logger.isDebugEnabled()) {
				logger.debug("Writing zip entry, name: " + zipEntry.getName());
			}
			zipOutputStream.write(documentRecord.getContent(new BytesHandle()).get());
			zipOutputStream.closeEntry();
		} catch (IOException e) {
			throw new RuntimeException("Unable to write zip entry for URI: " + uri + "; cause: " + e.getMessage(), e);
		}
	}
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:18,代码来源:WriteToZipConsumer.java

示例3: generateOutput

import com.marklogic.client.document.DocumentRecord; //导入依赖的package包/类
@Override
public String generateOutput(DocumentRecord documentRecord) {
	if (Format.XML.equals(documentRecord.getFormat())) {
		DOMHandle handle = documentRecord.getContent(new DOMHandle());
		Document document = handle.get();

		OutputFormat format = new OutputFormat(handle.get());
		format.setOmitXMLDeclaration(omitXmlDeclaration);

		StringWriter writer = new StringWriter();
		try {
			new XMLSerializer(writer, format).serialize(document);
			return writer.toString();
		} catch (IOException e) {
			throw new RuntimeException("Unable to serialize XML document to string: " + e.getMessage(), e);
		}
	} else if (logger.isDebugEnabled()) {
		logger.debug(format("Document '%s' has a format of '%s', so will not attempt to remove the XML declaration from it",
			documentRecord.getUri(), documentRecord.getFormat().name()));
	}

	return documentRecord.getContent(new StringHandle()).get();
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:24,代码来源:XmlOutputListener.java

示例4: read

import com.marklogic.client.document.DocumentRecord; //导入依赖的package包/类
@Override
public DocumentRecord read() throws Exception {
    if (page.hasNext()) {
        return page.next();
    } else if (page.hasNextPage()) {
        page = docMgr.search(queryDef, start);
        start += page.getPageSize();
        return page.next();
    } else {
        return null;
    }
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:13,代码来源:DocumentItemReader.java

示例5: writeDocumentToFile

import com.marklogic.client.document.DocumentRecord; //导入依赖的package包/类
protected void writeDocumentToFile(DocumentRecord documentRecord, File file) throws IOException {
	file.getParentFile().mkdirs();
	FileOutputStream fos = new FileOutputStream(file);
	try {
		InputStreamHandle handle = documentRecord.getContent(new InputStreamHandle());
		FileCopyUtils.copy(handle.get(), fos);
	} finally {
		fos.close();
	}
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:11,代码来源:WriteDocumentToFileConsumer.java

示例6: buildZipEntry

import com.marklogic.client.document.DocumentRecord; //导入依赖的package包/类
protected ZipEntry buildZipEntry(DocumentRecord documentRecord) {
	String uri = documentRecord.getUri();
	if (flattenUri) {
		int pos = uri.lastIndexOf("/");
		uri = pos > -1 ? uri.substring(pos + 1) : uri;
	}

	if (uriPrefix != null) {
		uri = uriPrefix + uri;
	}

	return new ZipEntry(uri);
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:14,代码来源:WriteToZipConsumer.java

示例7: SimpleExportJob

import com.marklogic.client.document.DocumentRecord; //导入依赖的package包/类
public SimpleExportJob(Consumer<DocumentRecord>... consumers) {
	exportListener = new ExportListener();
	for (Consumer<DocumentRecord> consumer : consumers) {
		exportListener.onDocumentReady(consumer);
	}
	this.addUrisReadyListener(exportListener);
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:8,代码来源:SimpleExportJob.java

示例8: getOutputFile

import com.marklogic.client.document.DocumentRecord; //导入依赖的package包/类
protected File getOutputFile(DocumentRecord documentRecord) {
	return new File(baseDir, documentRecord.getUri());
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:4,代码来源:WriteDocumentToFileConsumer.java


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