All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jsapar.concurrent.ConcurrentText2TextConverter Maven / Gradle / Ivy

Go to download

JSaPar is a Java library providing a schema based parser and composer of almost collected sorts of delimited and fixed width files.

The newest version!
package org.jsapar.concurrent;

import org.jsapar.Text2TextConverter;
import org.jsapar.compose.Composer;
import org.jsapar.convert.AbstractConverter;
import org.jsapar.convert.ConvertTask;
import org.jsapar.parse.ParseTask;
import org.jsapar.text.TextParseConfig;
import org.jsapar.schema.Schema;

/**
 * A multi-threaded version of {@link org.jsapar.Text2TextConverter} where the composer is started in a separate worker
 * thread.
 * See {@link AbstractConverter} for details about error handling and manipulating data.
 * 

* As a rule of thumb while working with normal files on disc, don't use this concurrent version unless your input * normally exceeds at least 1MB of data, as the overhead of starting * a new thread and synchronizing threads is otherwise greater than the gain by the concurrency. * * @see ConcurrentConvertTask * @see org.jsapar.Text2TextConverter */ public class ConcurrentText2TextConverter extends Text2TextConverter implements ConcurrentStartStop{ private final ConcurrentConvertTaskFactory convertTaskFactory = new ConcurrentConvertTaskFactory(); /** * Creates a concurrent text to text converter that can be used to convert between different text based formats. * @param parseSchema The schema to use while parsing * @param composeSchema The schema to use wile composing. */ public ConcurrentText2TextConverter(Schema parseSchema, Schema composeSchema) { super(parseSchema, composeSchema); } /** * Creates a concurrent text to text converter that can be used to convert between different text based formats. * @param parseSchema The schema to use while parsing * @param composeSchema The schema to use wile composing. * @param parseConfig Configuration about parsing behavior. */ public ConcurrentText2TextConverter(Schema parseSchema, Schema composeSchema, TextParseConfig parseConfig) { super(parseSchema, composeSchema, parseConfig); } @Override protected ConvertTask makeConvertTask(ParseTask parseTask, Composer composer) { return convertTaskFactory.makeConvertTask(parseTask, composer, getErrorConsumer(), getTransformer(), getManipulators()); } public void registerOnStart(Runnable onStart) { this.convertTaskFactory.registerOnStart(onStart); } public void registerOnStop(Runnable onStop) { this.convertTaskFactory.registerOnStop(onStop); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy