com.univocity.parsers.common
Interface Result<R extends com.univocity.parsers.common.record.Record,C extends com.univocity.parsers.common.Context>

Type Parameters:
R - the type of Record that this result stores.
C - the type of Context used when the results where parsed.
All Superinterfaces:
Closeable

public interface Result<R extends com.univocity.parsers.common.record.Record,C extends com.univocity.parsers.common.Context>
extends Closeable

An interface used to store the result of parsing some input with a parser implementing EntityParserInterface. The fields that are captured and the order that they appear in each row depend on how they were configured using EntitySettings before parsing.

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
EntityParserInterface, EntitySettings, Record

Method Summary
 void close()
          Closes the row processing so no more rows will be added to the Result
<T> List<T>
getBeans(Class<T> beanType)
          Using the beanType that has to contain one or more annotations from com.univocity.parsers.annotations, the fields of this result are parsed into the matching fields of the beanType.
<T> List<T>
getBeans(Class<T> beanType, com.univocity.parsers.common.ProcessorErrorHandler<C> errorHandler)
          Using the beanType that has to contain one or more annotations from com.univocity.parsers.annotations, the fields of this result are parsed into the matching fields of the beanType.
 C getContext()
           
 String getEntityName()
          Get the name of the entity that this result belongs to.
 String[] getHeaders()
          Get an array of the headers of each field in the order that they were created and match the order that they appear in the methods that return a String[] for each row.
 Results<? extends Result<R,C>> getLinkedEntityData(int rowIndex)
          Gets all of the Result associated with the specific rowIndex in a Results list.
 Result<R,C> getLinkedFieldData(int rowIndex)
          Gets then result with data for additional fields linked to the record at rowIndex.
 com.univocity.parsers.common.record.RecordMetaData getRecordMetaData()
           
 List<R> getRecords()
          Get a List of Record where each record represents a row in the results.
 List<String[]> getRows()
          Get a List of String[] where each array is a row of results.
 boolean isComplete()
          Whether or not all input has been parsed and no more row entries are to be added.
<T> com.univocity.parsers.common.IterableResult<T,C>
iterateBeans(Class<T> beanType)
          Using the beanType that has to contain one or more annotations from com.univocity.parsers.annotations, the fields of this result are parsed into the matching fields of the beanType.
<T> com.univocity.parsers.common.IterableResult<T,C>
iterateBeans(Class<T> beanType, com.univocity.parsers.common.ProcessorErrorHandler<C> errorHandler)
          Using the beanType that has to contain one or more annotations from com.univocity.parsers.annotations, the fields of this result are parsed into the matching fields of the beanType.
 Iterable<R> iterateRecords()
          Get an iterable of records that iterates over each row.
 Iterable<String[]> iterateRows()
          Get an iterable of String[] that iterates over each row.
 Result<R,C> join(Result<R,C> result, String... fieldNames)
          Joins rows of a given result with the rows of the current one.
 void link(Result<R,C> result, String... fieldNames)
          Links rows of a given result with the rows of the current one.
 void process(com.univocity.parsers.common.processor.core.Processor<C> processor)
          Uses the provided Processor to process each row of the result using a default NoopProcessorErrorHandler to not handle any errors and simply rethrow them.
 void process(com.univocity.parsers.common.processor.core.Processor<C> processor, com.univocity.parsers.common.ProcessorErrorHandler<C> errorHandler)
          Uses the provided Processor to process each row of the result using the ProcessorErrorHandler to handle any errors that occur.
 void waitForCompletion()
          Pauses the processing of rows until all rows are captured and the queue is closed.
 

Method Detail

getEntityName

String getEntityName()
Get the name of the entity that this result belongs to.

Returns:
the name of the entity that the result is for.

getContext

C getContext()
Returns:
the context used when creating the result.

getRecordMetaData

com.univocity.parsers.common.record.RecordMetaData getRecordMetaData()
Returns:
the meta data of the record

getHeaders

String[] getHeaders()
Get an array of the headers of each field in the order that they were created and match the order that they appear in the methods that return a String[] for each row. e.g. getRows() and iterateRows().

Returns:
the headers of each field for the result.

getRows

List<String[]> getRows()
Get a List of String[] where each array is a row of results. The order of fields in each row matches the order they were added to the EntityList and the order they appear in getHeaders().

Returns:
a List of String[] for each row of the result.

iterateRows

Iterable<String[]> iterateRows()
Get an iterable of String[] that iterates over each row.

Returns:
an Iterable over each row.

getRecords

List<R> getRecords()
Get a List of Record where each record represents a row in the results. Each record contains the String captured for each field and also many convenience methods for further data manipulation.

Returns:
a list of records for each row of the result.

iterateRecords

Iterable<R> iterateRecords()
Get an iterable of records that iterates over each row.

Returns:
an Iterable over each row

process

void process(com.univocity.parsers.common.processor.core.Processor<C> processor)
Uses the provided Processor to process each row of the result using a default NoopProcessorErrorHandler to not handle any errors and simply rethrow them.

Parameters:
processor - the Processor used to process each row of the result.

process

void process(com.univocity.parsers.common.processor.core.Processor<C> processor,
             com.univocity.parsers.common.ProcessorErrorHandler<C> errorHandler)
Uses the provided Processor to process each row of the result using the ProcessorErrorHandler to handle any errors that occur.

Parameters:
processor - the Processor used to process each row of the result.
errorHandler - the ProcessorErrorHandler used to handle any error in a specific way that occurs during processing.

getBeans

<T> List<T> getBeans(Class<T> beanType)
Using the beanType that has to contain one or more annotations from com.univocity.parsers.annotations, the fields of this result are parsed into the matching fields of the beanType. Each row of this result, if successfully parsed, will be returned as an object in a List of the specified type <T>. A null value for a field linked to a property of the bean encountered during parsing results in the default value for primitives and a null value for objects being set. The default NoopProcessorErrorHandler will be used as a ProcessorErrorHandler to not handle any errors.

Type Parameters:
T - the type of the bean that is returned.
Parameters:
beanType - the type of the bean that is created using the fields of this Result.
Returns:
a List that contains <T> for each bean successfully parsed from a row.

getBeans

<T> List<T> getBeans(Class<T> beanType,
                     com.univocity.parsers.common.ProcessorErrorHandler<C> errorHandler)
Using the beanType that has to contain one or more annotations from com.univocity.parsers.annotations, the fields of this result are parsed into the matching fields of the beanType. Each row of this result, if successfully parsed, will be returned as an object in a List of the specified type <T>. A null value for a field linked to a property of the bean encountered during parsing results in the default value for primitives and a null value for objects being set. Any errors during parsing will be handled by the errorHandler.

Type Parameters:
T - the type of the bean that is returned.
Parameters:
beanType - the type of the bean that is created using the fields of this Result.
errorHandler - the ProcessorErrorHandler to handle any errors that occur during the processing of beans.
Returns:
a List that contains <T> for each bean successfully parsed from a row.

iterateBeans

<T> com.univocity.parsers.common.IterableResult<T,C> iterateBeans(Class<T> beanType)
Using the beanType that has to contain one or more annotations from com.univocity.parsers.annotations, the fields of this result are parsed into the matching fields of the beanType. Returns an IterableResult of beanType which is just like an Iterator except it has the added Context for the parsing session. A default NoopProcessorErrorHandler will be used as a ProcessorErrorHandler to not handle any errors.

Type Parameters:
T - the type of bean to iterate over.
Parameters:
beanType - the Class of the bean to create using fields of this Result.
Returns:
an IterableResult iterating over beans of the type beanType.

iterateBeans

<T> com.univocity.parsers.common.IterableResult<T,C> iterateBeans(Class<T> beanType,
                                                                  com.univocity.parsers.common.ProcessorErrorHandler<C> errorHandler)
Using the beanType that has to contain one or more annotations from com.univocity.parsers.annotations, the fields of this result are parsed into the matching fields of the beanType. Returns an IterableResult of beanType which is just like an Iterator except it has the added Context for the parsing session. Any errors during parsing will be handled by the errorHandler.

Type Parameters:
T - the type of bean to iterate over.
Parameters:
beanType - the Class of the bean to create using fields of this Result.
errorHandler - the ProcessorErrorHandler to handle any errors during the parsing of the bean.
Returns:
an IterableResult iterating over beans of the type beanType.

isComplete

boolean isComplete()
Whether or not all input has been parsed and no more row entries are to be added. If this is true then no more rows will be added.

Returns:
whether or not no more rows will be added.

waitForCompletion

void waitForCompletion()
                       throws InterruptedException
Pauses the processing of rows until all rows are captured and the queue is closed.

Throws:
InterruptedException - if the thread is interrupted

join

Result<R,C> join(Result<R,C> result,
                 String... fieldNames)
Joins rows of a given result with the rows of the current one. Rows are joined by matching values of a given set of field names that are common to both Result instances.

Parameters:
result - the input result whose rows will be associated with the current.
fieldNames - fields common to the given result and the current, whose values will be used to identify which rows should be associated. If none provided the fields that are common to current and given results will be used.
Returns:
a Result with the associated data.

link

void link(Result<R,C> result,
          String... fieldNames)
Links rows of a given result with the rows of the current one. Rows are linked by matching values of a given set of field names that are common to both Result instances. The linked data is then accessible using getLinkedEntityData(int)

Parameters:
result - the other Result whose rows will be added to this Result's linked entity data.
fieldNames - the common field names used to determine which fields to link. If none provided then all fields that are common will be used.

getLinkedFieldData

Result<R,C> getLinkedFieldData(int rowIndex)
Gets then result with data for additional fields linked to the record at rowIndex.

Parameters:
rowIndex - which row to get the linked field data from
Returns:
the result linked to the row at rowIndex

getLinkedEntityData

Results<? extends Result<R,C>> getLinkedEntityData(int rowIndex)
Gets all of the Result associated with the specific rowIndex in a Results list.

Parameters:
rowIndex - which row to get the linked entity data from
Returns:
all of the results linked to the row at rowIndex

close

void close()
Closes the row processing so no more rows will be added to the Result

Specified by:
close in interface Closeable


Copyright © 2018 uniVocity Software Pty Ltd. All rights reserved.