本文整理汇总了Java中eu.fusepool.p3.transformer.commons.util.WritingEntity类的典型用法代码示例。如果您正苦于以下问题:Java WritingEntity类的具体用法?Java WritingEntity怎么用?Java WritingEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WritingEntity类属于eu.fusepool.p3.transformer.commons.util包,在下文中一共展示了WritingEntity类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: transform
import eu.fusepool.p3.transformer.commons.util.WritingEntity; //导入依赖的package包/类
@Override
public Entity transform(HttpRequestEntity entity) throws IOException {
final MimeType mimeType = entity.getType();
final InputStream in = entity.getData();
final Entity output = new WritingEntity() {
@Override
public MimeType getType() {
return mimeType;
}
@Override
public void writeData(OutputStream out) throws IOException {
IOUtils.copy(in, out);
}
};
return output;
}
开发者ID:fusepoolP3,项目名称:p3-pipeline-transformer,代码行数:19,代码来源:SimpleTransformer.java
示例2: testXML
import eu.fusepool.p3.transformer.commons.util.WritingEntity; //导入依赖的package包/类
@Test
public void testXML() throws Exception {
Transformer t = new TransformerClientImpl(setUpDataServer());
// the transformer fetches the xml data from the data server, geocode the address
// and sends the RDF result to the client
{
Entity response = t.transform(new WritingEntity() {
@Override
public MimeType getType() {
return inputDataMimeType;
}
@Override
public void writeData(OutputStream out) throws IOException {
out.write(inputData);
}
}, transformerMimeType );
// the client receives the response from the transformer
Assert.assertEquals("Wrong media Type of response", TRANSFORMER_MIME_TYPE, response.getType().toString());
// Parse the RDF data returned by the transformer after the geocoding
final Graph responseGraph = Parser.getInstance().parse(response.getData(), "text/turtle");
//checks for the presence of a specific property added by the transformer to the input data
final Iterator<Triple> propertyIter = responseGraph.filter(null, geo_lat, null);
Assert.assertTrue("No specific property found in response", propertyIter.hasNext());
//verify that the xml has been loaded from the data server (one call)
//verify(1,getRequestedFor(urlEqualTo("/xml/" + XML_DATA)));
}
}
开发者ID:fusepoolP3,项目名称:p3-osm-transformer,代码行数:33,代码来源:OsmRdfTransformerTest.java
示例3: transform
import eu.fusepool.p3.transformer.commons.util.WritingEntity; //导入依赖的package包/类
@Override
public Entity transform(HttpRequestEntity entity) throws IOException {
logMessage(entity.getRequest());
final HttpRequestEntity request = cast(entity);
final ImmutablePair<MimeType, Properties> options = exporterOptions(request);
options.right.putAll(transformerConfig);
final File input = downloadInput(entity);
final File output = File.createTempFile("reply", "tmp");
final ITransformEngine engine = getEngine();
return new WritingEntity() {
@Override
public void writeData(OutputStream out) throws IOException {
try {
// Can't allow more than one transform at a time as OpenRefine is not
// designed for that.
synchronized (SynchronousTransformer.this) {
engine.transform(input.toURI(), fetchTransform(request), output.toURI(),
options.right);
}
try (FileInputStream stream = new FileInputStream(output)) {
IOUtils.copy(stream, out);
}
} finally {
input.delete();
output.delete();
}
}
@Override
public MimeType getType() {
return options.left;
}
};
}
开发者ID:fusepoolP3,项目名称:p3-batchrefine,代码行数:40,代码来源:SynchronousTransformer.java
示例4: testTransformation
import eu.fusepool.p3.transformer.commons.util.WritingEntity; //导入依赖的package包/类
/**
* The transformer receives RDF data and a url from the client, fetches the SILK config file from the url, applies the linkage rules
* and then check if the transformation is compatible with the expected result.
* @throws Exception
*/
@Test
public void testTransformation() throws Exception {
Transformer t = new TransformerClientImpl(setUpMockServer());
// the transformer fetches the SILK config file from the mock server, applies its rules and sends the RDF result to the client
{
Entity response = t.transform(new WritingEntity() {
@Override
public MimeType getType() {
return clientDataMimeType;
}
@Override
public void writeData(OutputStream out) throws IOException {
out.write(ttlData);
}
}, transformerMimeType);
// the client receives the response from the transformer
Assert.assertEquals("Wrong media Type of response", transformerMimeType.toString(), response.getType().toString());
// Parse the RDF data returned by the transformer after the xslt transformation has been applied to the xml data
final Graph responseGraph = Parser.getInstance().parse(response.getData(), "text/turtle");
//checks for the presence of a specific property added by the transformer
final Iterator<Triple> propertyIter = responseGraph.filter(null, OWL.sameAs, null);
Assert.assertTrue("No specific property found in response", propertyIter.hasNext());
}
}
开发者ID:fusepoolP3,项目名称:p3-silkdedup,代码行数:37,代码来源:DuplicatesTransformerTest.java
示例5: wrapInEntity
import eu.fusepool.p3.transformer.commons.util.WritingEntity; //导入依赖的package包/类
private WritingEntity wrapInEntity(final String transformed) {
return new WritingEntity() {
@Override
public MimeType getType() {
return MIME_TEXT_PLAIN;
}
@Override
public void writeData(OutputStream out) throws IOException {
out.write(transformed.getBytes());
}
};
}
开发者ID:fusepoolP3,项目名称:p3-transformer-howto,代码行数:14,代码来源:SedTransformer.java
注:本文中的eu.fusepool.p3.transformer.commons.util.WritingEntity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论