public class FileParser extends Object implements org.springframework.context.ApplicationContextAware
Iterable
should be returned
rather than throwing an exception.
Subclases 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(org.springframework.context.ApplicationContext arg0)
Set the ApplicationContext that this object runs in.
|
void |
setMaxFileSize(Long size) |
Iterable<Reader> |
wrap(Iterator<Reader> it)
|
Iterable<Reader> |
wrap(Reader r) |
protected OmeroContext context
protected long maxFileSize
public void setApplicationContext(org.springframework.context.ApplicationContext arg0) throws org.springframework.beans.BeansException
org.springframework.context.ApplicationContextAware
Invoked after population of normal bean properties but before an init callback such
as InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,
ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
and
MessageSourceAware
, if applicable.
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
arg0
- the ApplicationContext object to be used by this objectorg.springframework.context.ApplicationContextException
- in case of context initialization errorsorg.springframework.beans.BeansException
- if thrown by application context methodsBeanInitializationException
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.1.2-ice35-b45
Copyright © 2015 The University of Dundee & Open Microscopy Environment. All Rights Reserved.