public class SDRFParser extends AbstractParser<SDRF>
SDRF. The SDRFImporter implements a parser for SDRF documents, creating an
in-memory object model to cache this date. The data contained in the cache is then converted to AE2 object model
instances, and stored in a MAGETABObjectBag that can be validated, manipulated or persisted as appropriate.
As for the IDFParser, this importer processes the document in parallel and uses Handlers to distribute the work. As handlers may, at some point, require
data that is being processed by another handler that is running in a parallel process, there is a degree of waiting
and communication between threads.
This class also supports the ability to validate and convert the SDRF, by supplying Validator and Converter
instances on creation.
In addition, SDRF parsing requires resolution of objects that are only present in the IDF document. This means that
SDRF files cannot easily be loaded in isolation. As such, several SDRF handler implementations require data in the
IDF portion of the cache to be present before they procede. If these objects are missing, it may not be possible to
complete SDRF import, resulting in timeout issues.
Generally, it is advisable to use the MAGETABImporter rather than the SDRFImporter in isolation.MAGETABParser,
IDFParser,
SDRFAbstractParser.DefaultHandlerListenerDEFAULT_ENCODING| Constructor and Description |
|---|
SDRFParser() |
| Modifier and Type | Method and Description |
|---|---|
SDRF |
parse(File sdrfFile) |
SDRF |
parse(InputStream sdrfIn)
Performs parsing from the specified input stream source, populating an
SDRF object which is returned. |
SDRF |
parse(InputStream sdrfIn,
SDRF sdrf)
Alternate form of the
parse(java.io.InputStream) method that allows callers to specify the SDRF object
they want to be populated. |
SDRF |
parse(InputStream sdrfIn,
SDRF sdrf,
ExecutorService service)
Alternate form of the
parse(java.io.InputStream) method that allows callers to specify both the SDRF
object they wish to be populated and an executor service that should be used to execute all SDRF handler tasks. |
SDRF |
parse(URL sdrfURL) |
protected void |
read(String[][] sdrfData,
SDRF sdrf,
ExecutorService service)
Reads tabulated SDRF data into the supplied SDRF object, delegating the execution of handling tasks to the
supplied ExecutorService.
|
addErrorItemListener, addProgressListener, fireErrorItemEvent, fireParseEvent, fireParsingCompletedEvent, fireParsingFailedEvent, fireParsingStartedEvent, getEncoding, getErrorItemListeners, getLog, getProgressListeners, isStrippingEscaping, removeErrorItemListener, removeProgressListener, setEncoding, setStripEscapingpublic SDRF parse(File sdrfFile) throws ParseException
ParseExceptionpublic SDRF parse(URL sdrfURL) throws ParseException
ParseExceptionpublic SDRF parse(InputStream sdrfIn) throws ParseException
SDRF object which is returned.
This class will generate ErrorItems in response to any errors in the SDRF file it detects, and report
them via any registered ErrorItemListeners.
A ParseException will be thrown if and only if there was a problem with the SDRF input stream that meant
the document was unparseable. You not use the absence of a parse exception to indicate that parsing was
successful, rather you should register an ErrorItemListener and check any generated error items to determine
whether the SDRF is suitable for your own purposes.
Calling this method is equivalent to calling parse(sdrfIn, new SDRF());.
SDRF files will be parsed in a single threaded manner when calling this form of the parse() method.
This method blocks until parsing is complete.sdrfIn - the input stream to use to read SDRF data for parsingParseException - if the input stream was unparseablepublic SDRF parse(InputStream sdrfIn, SDRF sdrf) throws ParseException
parse(java.io.InputStream) method that allows callers to specify the SDRF object
they want to be populated. The SDRF returned from this method is in fact a reference to the supplied parameter.
Calling this method is equivalent to calling parse(sdrfIn, sdrf, Executors.newSingleThreadExecutor());
and then blocking until completion.
SDRF files will be parsed in a single threaded manner when calling this form of the parse() method.
This method blocks until parsing is complete.sdrfIn - the source to read fromsdrf - the SDRF that will be populatedParseException - if the input stream was unparseablepublic SDRF parse(InputStream sdrfIn, SDRF sdrf, ExecutorService service) throws ParseException
parse(java.io.InputStream) method that allows callers to specify both the SDRF
object they wish to be populated and an executor service that should be used to execute all SDRF handler tasks.
This method takes an executor service as a parameter, supporting parallel parsing of the SDRF. For parsing a
single file, this is unlikely to be useful. By calling parse(java.io.InputStream,
uk.ac.ebi.arrayexpress2.magetab.datamodel.SDRF) operation supplies a single thread to this class. If parsing
many SDRF files, you may want to tailor this performance to suit your needs. This method does not shutdown the
executor service on completion, so you can reuse the same service if required. Once all parsing operations
finish, calling classes are responsible for releasing any resources used.
SDRF files will be parsed in a manner appropriate for the supplied ExecutorService when calling this form of the
parse() method. This method executes asynchronouslysdrfIn - the source to read fromsdrf - the SDRF that will be populatedservice - the executor service to use to execute parsing tasksParseException - if the input stream was unparseableprotected void read(String[][] sdrfData, SDRF sdrf, ExecutorService service) throws ExecutionException, InterruptedException
sdrfData - the SDRF data to handlesdrf - the SDRF into which parsed data should be addedservice - the service to execute handlers withinExecutionException - if any handling tasks failed to executeInterruptedException - if the service was interrupted whilst parsing was ongoingCopyright © 2014. All rights reserved.