|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectome.services.fulltext.FileParser
public class FileParser
Object which attempts to parse any file given to it. On an exception or
empty/missing file, an empty Iterable
should be returned
rather than throwing an exception.
Subclases should follow
Field Summary | |
---|---|
protected OmeroContext |
context
|
static Iterable<Reader> |
EMPTY
Iterable which returns an empty Iterator . |
Constructor Summary | |
---|---|
FileParser()
|
Method Summary | |
---|---|
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)
|
Iterable<Reader> |
wrap(Iterator<Reader> it)
Wraps an Iterator with an Iterable instance. |
Iterable<Reader> |
wrap(Reader r)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected OmeroContext context
public static final Iterable<Reader> EMPTY
Iterable
which returns an empty Iterator
. This will be
used in case
Constructor Detail |
---|
public FileParser()
Method Detail |
---|
public void setApplicationContext(org.springframework.context.ApplicationContext arg0) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
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.
public Iterable<Reader> wrap(Reader r)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Version: Beta-4.2.0-r7571-b29
Copyright © 2009 The University of Dundee. All Rights Reserved.