本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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();
}
示例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;
}
}
示例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();
}
}
示例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);
}
示例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);
}
示例8: getOutputFile
import com.marklogic.client.document.DocumentRecord; //导入依赖的package包/类
protected File getOutputFile(DocumentRecord documentRecord) {
return new File(baseDir, documentRecord.getUri());
}