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


Java StringHandle类代码示例

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


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

示例1: setupData

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
private void setupData() {
	DatabaseClient dbClient = DatabaseClientFactory.newClient(host, restPort, "admin", "admin",
			Authentication.DIGEST);
	String tripleDocOne = "<semantic-document>\n" + "<title>First Title</title>\n" + "<popularity>1</popularity>\n"
			+ "<size>100</size>\n" + "<sem:triples xmlns:sem=\"http://marklogic.com/semantics\">"
			+ "<sem:triple><sem:subject>http://example.org/r9928</sem:subject>"
			+ "<sem:predicate>http://example.org/p3</sem:predicate>"
			+ "<sem:object datatype=\"http://www.w3.org/2001/XMLSchema#int\">1</sem:object></sem:triple>"
			+ "</sem:triples>\n" + "</semantic-document>";

	String tripleDocTwo = "<semantic-document>\n" + "<title>Second Title</title>\n" + "<popularity>5</popularity>\n"
			+ "<size>500</size>\n" + "<sem:triples xmlns:sem=\"http://marklogic.com/semantics\">"
			+ "<sem:triple><sem:subject>http://example.org/r9929</sem:subject>"
			+ "<sem:predicate>http://example.org/p3</sem:predicate>"
			+ "<sem:object datatype=\"http://www.w3.org/2001/XMLSchema#int\">2</sem:object></sem:triple>"
			+ "</sem:triples>\n" + "</semantic-document>";

	DataMovementManager dmManager = dbClient.newDataMovementManager();
	WriteBatcher batcher = dmManager.newWriteBatcher();
	batcher.add("/directory1/doc1.xml", new StringHandle().with(tripleDocOne)).add("/directory2/doc2.xml",
			new StringHandle().with(tripleDocTwo));
	batcher.flushAndWait();
	dbClient.release();

}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:26,代码来源:MarkLogicRepositoryConnectionTest.java

示例2: getWriteHandleFromBody

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
private XMLWriteHandle getWriteHandleFromBody(Exchange exchange)
		throws Exception {
	XMLWriteHandle writeHandle;
	
	if(exchange.getIn().getBody() instanceof String) {
		StringHandle stringHandle = new StringHandle((String) exchange.getIn().getBody());
		stringHandle.setFormat(Format.XML);
		
		writeHandle = stringHandle;
	} else if (exchange.getIn().getBody() instanceof Document) {
		DOMHandle domHandle = new DOMHandle((Document) exchange.getIn().getBody());
		domHandle.setFormat(Format.XML);
		
		writeHandle = domHandle;
	} else {
		throw new Exception("MLDBProducer can only handle String or XML document, got " + exchange.getIn().getBody().getClass().getName());
	}
	return writeHandle;
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:20,代码来源:MLDBProducer.java

示例3: processResults

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
public void processResults(EvalResultIterator itr) {
    String item = null;
    while (itr.hasNext()) {
        EvalResult result = itr.next();
        switch (result.getType()) {
            case STRING: {
                item = result.getAs(String.class);
                logger.info(item);
                break;
            }
            default: {
                StringHandle handle = result.get(new StringHandle());
                logger.info(handle.get());
                break;
            }
        }
    }
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:19,代码来源:InvokeModuleItemWriter.java

示例4: getDocuments

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
public List<DocumentWriteOperation> getDocuments() {
    List<DocumentWriteOperation> handles = new ArrayList<DocumentWriteOperation>();

    DocumentWriteOperation handle = new DocumentWriteOperationImpl(
            DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
            "abc.xml",
            new DocumentMetadataHandle().withCollections("raw"),
            new StringHandle("<hello />"));
    handles.add(handle);

    DocumentWriteOperation handle2 = new DocumentWriteOperationImpl(
            DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
            "abc2.xml",
            new DocumentMetadataHandle().withCollections("raw"),
            new StringHandle("<hello2 />"));
    handles.add(handle2);

    return handles;
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:20,代码来源:MarkLogicItemWriterTest.java

示例5: getBadDocument

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
public List<DocumentWriteOperation> getBadDocument() {
    List<DocumentWriteOperation> handles = new ArrayList<DocumentWriteOperation>();
    
    DocumentWriteOperation handle2 = new DocumentWriteOperationImpl(
            DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
            "good.xml",
            new DocumentMetadataHandle().withCollections("raw"),
            new StringHandle("<hello />"));
    handles.add(handle2);

    DocumentWriteOperation handle = new DocumentWriteOperationImpl(
            DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
            "fail.xml",
            new DocumentMetadataHandle().withCollections("raw"),
            new StringHandle("<hello #&3; />"));
    handles.add(handle);

    return handles;
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:20,代码来源:MarkLogicItemWriterTest.java

示例6: writeDocumentWithTransformNoParametersTest

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
@Test
public void writeDocumentWithTransformNoParametersTest() {
    DocumentWriteOperation writeOp = new DocumentWriteOperationImpl(DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
            "hello.xml", new DocumentMetadataHandle(), new StringHandle(xml));
    List<DocumentWriteOperation> writeOps = new ArrayList<DocumentWriteOperation>();
    writeOps.add(writeOp);

    try {
        itemWriter = new MarkLogicItemWriter(client, new ServerTransform(transformName));
        write(writeOps);
    } catch (Exception e) {
        e.printStackTrace();
    }

    StringHandle handle = docMgr.read("hello.xml", new StringHandle());
    Fragment frag = new Fragment(handle.toString());
    frag.assertElementExists("//hello[text() = 'world']");
    frag.assertElementExists("//transform");
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:20,代码来源:MarkLogicItemWriterTest.java

示例7: writeDocumentWithTransformWithParametersTest

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
@Test
public void writeDocumentWithTransformWithParametersTest() {
    DocumentWriteOperation writeOp = new DocumentWriteOperationImpl(DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
            "hello.xml", new DocumentMetadataHandle(), new StringHandle(xml));
    List<DocumentWriteOperation> writeOps = new ArrayList<DocumentWriteOperation>();
    writeOps.add(writeOp);
    try {
        ServerTransform serverTransform = new ServerTransform(transformName);
        serverTransform.addParameter("monster", "grover");
        serverTransform.addParameter("trash-can", "oscar");
        itemWriter = new MarkLogicItemWriter(client, serverTransform, Format.XML);
        write(writeOps);
    } catch (Exception e) {
        e.printStackTrace();
    }
    StringHandle handle = docMgr.read("hello.xml", new StringHandle());
    Fragment frag = new Fragment(handle.toString());
    frag.assertElementExists("//transform");
    frag.assertElementExists("//monster[text() = 'grover']");
    frag.assertElementExists("//trash-can[text() = 'oscar']");
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:22,代码来源:MarkLogicItemWriterTest.java

示例8: testTransformDocTest

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
@Test
public void testTransformDocTest() {
    StringHandle handle = new StringHandle("<hello />");
    ServerTransform serverTransform = new ServerTransform(transformName);
    serverTransform.addParameter("monster", "grover");
    serverTransform.addParameter("trash-can", "oscar");
    GenericDocumentManager genDocMgr = testDatabaseClient.newDocumentManager();
    DocumentWriteSet writeSet = genDocMgr.newWriteSet();
    writeSet.add("aaa.xml", handle);

    //if this line is omitted then the test fails
    genDocMgr.setContentFormat(Format.XML);

    genDocMgr.write(writeSet, serverTransform);

}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:17,代码来源:MarkLogicItemWriterTest.java

示例9: setup

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
@Before
public void setup() {
    DatabaseClientFactory.SecurityContext securityContext =
            new DatabaseClientFactory.DigestAuthContext(databaseClientConfig.getUsername(),
                    databaseClientConfig.getPassword());
    client = DatabaseClientFactory.newClient(databaseClientConfig.getHost(),
            databaseClientConfig.getPort(), securityContext);
    helper = new ClientTestHelper();
    helper.setDatabaseClientProvider(getClientProvider());

    XMLDocumentManager docMgr = client.newXMLDocumentManager();

    StringHandle xml1 = new StringHandle("<hello />");
    DocumentMetadataHandle metadata = new DocumentMetadataHandle();
    metadata.withCollections("a");

    DocumentMetadataHandle metadata2 = new DocumentMetadataHandle();
    metadata2.withCollections("b");

    for (int i = 0; i < 600; i++) {
        DocumentMetadataHandle h = (i % 2 == 0) ? metadata : metadata2;
        docMgr.write("hello" + i + ".xml", h, xml1);
    }
    helper.assertCollectionSize("a = 300", "a", 300);
    helper.assertCollectionSize("b = 300", "b", 300);
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:27,代码来源:ValuesItemReaderTest.java

示例10: columnMapSimpleXmlTest

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
@Test
public void columnMapSimpleXmlTest() throws Exception {
    ColumnMapProcessor columnMapProcessor = new ColumnMapProcessor(new DefaultStaxColumnMapSerializer());
    columnMapProcessor.setRootLocalName("test");

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("sample", "value");

    DocumentWriteOperation handle = columnMapProcessor.process(map);
    logger.info(handle.getUri());
    StringHandle strHandle = (StringHandle) handle.getContent();
    logger.info(strHandle.get());
    assertTrue("<test><sample>value</sample></test>".equals(strHandle.get()));
    assertNotNull(handle);

}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:17,代码来源:ColumnMapProcessorTest.java

示例11: getRootNameFromMapTest

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
@Test
public void getRootNameFromMapTest() throws Exception {
    ColumnMapProcessor columnMapProcessor = new ColumnMapProcessor(new DefaultStaxColumnMapSerializer());
    columnMapProcessor.setRootLocalName("type");

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("type", "junk");
    map.put("sample", "value");

    DocumentWriteOperation handle = columnMapProcessor.process(map);
    logger.info(handle.getUri());
    StringHandle strHandle = (StringHandle) handle.getContent();
    logger.info(strHandle.get());
    assertTrue("<junk><type>junk</type><sample>value</sample></junk>".equals(strHandle.get()));
    assertNotNull(handle);

}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:18,代码来源:ColumnMapProcessorTest.java

示例12: installService

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
/**
 *
 * @param r
 * @param metadata
 * @param methodParams
 * @return
 */
public Resource installService(Resource r, final ExtensionMetadata metadata, final MethodParameters... methodParams) {
	if (!hasFileBeenModified(r) || ignoreResource(r)) {
		return null;
	}
	final ResourceExtensionsManager extMgr = client.newServerConfigManager().newResourceExtensionsManager();
	final String resourceName = getExtensionNameFromFile(r);
	if (metadata.getTitle() == null) {
		metadata.setTitle(resourceName + " resource extension");
	}
	logger.info(String.format("Loading %s resource extension from file %s", resourceName, r.getFilename()));

	StringHandle h = new StringHandle(readAndReplaceTokens(r));
	executeTask(() -> extMgr.writeServices(resourceName, h, metadata, methodParams));

	updateTimestamp(r);
	return r;
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:25,代码来源:DefaultModulesLoader.java

示例13: installTransform

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
/**
 *
 * @param r
 * @param metadata
 * @return
 */
public Resource installTransform(Resource r, final ExtensionMetadata metadata) {
	if (!hasFileBeenModified(r) || ignoreResource(r)) {
		return null;
	}
	final String filename = r.getFilename();
	final TransformExtensionsManager mgr = client.newServerConfigManager().newTransformExtensionsManager();
	final String transformName = getExtensionNameFromFile(r);
	logger.info(String.format("Loading %s transform from resource %s", transformName, filename));

	StringHandle h = new StringHandle(readAndReplaceTokens(r));
	executeTask(() -> {
           if (FilenameUtil.isXslFile(filename)) {
               mgr.writeXSLTransform(transformName, h, metadata);
           } else if (FilenameUtil.isJavascriptFile(filename)) {
               mgr.writeJavascriptTransform(transformName, h, metadata);
           } else {
               mgr.writeXQueryTransform(transformName, h, metadata);
           }
       });
	updateTimestamp(r);

	return r;
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:30,代码来源:DefaultModulesLoader.java

示例14: installQueryOptions

import com.marklogic.client.io.StringHandle; //导入依赖的package包/类
/**
 *
 * @param r
 * @return
 */
public Resource installQueryOptions(Resource r) {
	if (!hasFileBeenModified(r) || ignoreResource(r)) {
		return null;
	}

	final String filename = r.getFilename();
	final String name = getExtensionNameFromFile(r);
	logger.info(String.format("Loading %s query options from file %s", name, filename));
	final QueryOptionsManager mgr = client.newServerConfigManager().newQueryOptionsManager();

	StringHandle h = new StringHandle(readAndReplaceTokens(r));
	executeTask(() -> {
           if (filename.endsWith(".json")) {
               mgr.writeOptions(name, h.withFormat(Format.JSON));
           } else {
               mgr.writeOptions(name, h);
           }
       });
	updateTimestamp(r);
	return r;
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:27,代码来源:DefaultModulesLoader.java

示例15: generateOutput

import com.marklogic.client.io.StringHandle; //导入依赖的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


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