public class FileParser extends Object implements ApplicationContextAware
Iterable
should be returned
rather than throwing an exception.
Subclasses should followModifier and Type | Field and Description |
---|---|
protected OmeroContext |
context |
static Iterable<Reader> |
EMPTY
|
protected long |
maxFileSize |
Constructor and Description |
---|
FileParser() |
Modifier and Type | Method and Description |
---|---|
Iterable<Reader> |
doParse(File file)
Template method to parse a
File into manageable chunks. |
Iterable<Reader> |
parse(File file)
Uses
doParse(File) to create manageable chunks of a file for
indexing. |
void |
setApplicationContext(ApplicationContext arg0) |
void |
setMaxFileSize(Long size) |
Iterable<Reader> |
wrap(Iterator<Reader> it)
|
Iterable<Reader> |
wrap(Reader r) |
protected OmeroContext context
protected long maxFileSize
public void setApplicationContext(ApplicationContext arg0) throws BeansException
setApplicationContext
in interface ApplicationContextAware
BeansException
public void setMaxFileSize(Long size)
public final Iterable<Reader> parse(File file)
doParse(File)
to create manageable chunks of a file for
indexing. If the File
argument is null or unreadable, then the
EMPTY
Iterable
will be returned. The same holds if a
null Iterable
is returned or an Exception
is thrown.
The Iterator
returned from the instance should always be
completely iterated through so that resources can be released. For
example,
for (String string : parse(file)) {
/* possibly ignore string *\/
}
file
- Can be null.Iterable
which is never null.public Iterable<Reader> doParse(File file) throws Exception
File
into manageable chunks.
The default implementation reads from the file lazily with chunks
overlapping on the final white space. For example a file with:
The quick brown fox jumps over the lazy dog
might be
parsed to: The quick brown fox jumps
and
jumps over the lazy dog
.
Receives a non-null, readable
File
instance from parse(File)
and can return a possible null
Iterable
or throw an Exception
.
In any of the non-successful cases, the EMPTY
Iterable
will be returned to the consumer.Exception
public Iterable<Reader> wrap(Iterator<Reader> it)
Iterator
with an Iterable
instance. If the
Iterator
is null, the EMPTY
Iterable
will be
returned.it
- Can be null.
Version: 5.2.0-ice35-b12
Copyright © 2015 The University of Dundee & Open Microscopy Environment. All Rights Reserved.