/** * @author Christoph Böhme * */ @FluxCommand("read-triples") public final class TripleReader extends DefaultObjectPipe<String, ObjectReceiver<Triple>> { public static final int BUFFERSIZE = 2048; @Override public void process(final String filename) { try { final ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(filename), BUFFERSIZE)); try { while (true) { getReceiver().process(Triple.read(in)); } } catch (EOFException e) { } finally { in.close(); } } catch (IOException e) { throw new MetafactureException(e); } } }
/** * A simple pass-through module. * * @author Christoph Böhme */ @Description("A simple pass-through module") @In(StreamReceiver.class) @Out(StreamReceiver.class) @FluxCommand("pass-through") public final class IdentityStreamPipe extends ForwardingStreamPipe { }
@FluxCommand("string-list-map-to-stream") public final class StringListMapToStream extends DefaultObjectPipe<ListMap<String, String>, StreamReceiver> {
@FluxCommand("object-to-literal") public final class ObjectToLiteral<T> extends DefaultObjectPipe<T, StreamReceiver> {
@FluxCommand("from-jdom-document") public final class JDomDocumentToStream implements ObjectPipe<Document, StreamReceiver> {
/** * Creates a reader for the supplied string and sends it to the receiver. * * @author Christoph Böhme * */ @Description("Creates a reader for the supplied string and sends it to the receiver") @In(String.class) @Out(java.io.Reader.class) @FluxCommand("read-string") public final class StringReader extends DefaultObjectPipe<String, ObjectReceiver<Reader>> { @Override public void process(final String str) { getReceiver().process(new java.io.StringReader(str)); } }
@FluxCommand("print") public final class ObjectStdoutWriter<T> extends AbstractObjectWriter<T> {
/** * Sends an object to more than one receiver. * * @param <T> Object type * * @author Christoph Böhme * */ @Description("Sends an object to more than one receiver.") @In(Object.class) @Out(Object.class) @FluxCommand("object-tee") public final class ObjectTee<T> extends DefaultTee<ObjectReceiver<T>> implements ObjectPipe<T, ObjectReceiver<T>> { @Override public void process(final T obj) { for (ObjectReceiver<T> receiver : getReceivers()) { receiver.process(obj); } } }
/** * Sorts triples * @author markus geipel * */ @Description("Sorts triples") @In(Triple.class) @Out(Triple.class) @FluxCommand("sort-triples") public final class TripleSort extends AbstractTripleSort { @Override protected void sortedTriple(final Triple triple) { getReceiver().process(triple); } public void setBy(final Compare compare){ setCompare(compare); } public void setOrder(final Order order){ setSortOrder(order); } }
/** * Splits a string at new lines and sends each line to the receiver. * * @author Christoph Böhme * */ @Description("Splits a string at new lines and sends each line to the receiver.") @In(String.class) @Out(String.class) @FluxCommand("split-lines") public final class LineSplitter extends DefaultObjectPipe<String, ObjectReceiver<String>> { private static final char NEWLINE = '\n'; private static final Pattern LINE_PATTERN = Pattern.compile( String.valueOf(NEWLINE), Pattern.LITERAL); @Override public void process(final String lines) { assert !isClosed(); for (final String record : LINE_PATTERN.split(lines)) { getReceiver().process(record); } } }
@In(String.class) @Out(StreamReceiver.class) @FluxCommand("decode-formeta") public final class FormetaDecoder extends DefaultObjectPipe<String, StreamReceiver> {
@In(Object.class) @Out(Object.class) @FluxCommand("filter-duplicate-objects") public final class DuplicateObjectFilter<T> extends DefaultObjectPipe<T, ObjectReceiver<T>> {
@Out(Object.class) @Description("Benchmarks the execution time of the downstream modules.") @FluxCommand("log-time") public final class ObjectTimer<T> extends TimerBase<ObjectReceiver<T>> implements ObjectPipe<T, ObjectReceiver<T>> {
@In(Reader.class) @Out(String.class) @FluxCommand("as-lines") public final class LineReader extends DefaultObjectPipe<Reader, ObjectReceiver<String>> {
@In(Triple.class) @Out(StreamReceiver.class) @FluxCommand("triples-to-stream") public final class TriplesToStream extends DefaultObjectPipe<Triple, StreamReceiver> {
@In(String.class) @Out(String.class) @FluxCommand("match") public final class StringMatcher extends DefaultObjectPipe<String, ObjectReceiver<String>> {
@In(String.class) @Out(String.class) @FluxCommand("filter-strings") public final class StringFilter extends DefaultObjectPipe<String, ObjectReceiver<String>> {
@In(String.class) @Out(java.io.Reader.class) @FluxCommand("open-resource") public final class ResourceOpener extends DefaultObjectPipe<String, ObjectReceiver<Reader>> {
@Out(StreamReceiver.class) @Description("Benchmarks the execution time of the downstream modules.") @FluxCommand("log-stream-time") public final class StreamTimer extends TimerBase<StreamReceiver> implements StreamPipe<StreamReceiver> {
@In(Object.class) @Out(Object.class) @FluxCommand("log-object") public final class ObjectLogger<T> extends DefaultObjectPipe<T, ObjectReceiver<T>> {