Class RecordParser<T>
- java.lang.Object
-
- ubic.gemma.core.loader.util.parser.RecordParser<T>
-
- All Implemented Interfaces:
Parser<T>
- Direct Known Subclasses:
FastaParser
,SwissProtParser
public abstract class RecordParser<T> extends Object implements Parser<T>
Abstract record-based parser. Records are defined by lines starting with a given record separator. The default record separator is ">".- Author:
- pavlidis
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.commons.logging.Log
log
-
Fields inherited from interface ubic.gemma.core.loader.util.parser.Parser
PARSE_ALERT_FREQUENCY
-
-
Constructor Summary
Constructors Constructor Description RecordParser()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
addResult(Object obj)
Add an object to the results collection.abstract Collection<T>
getResults()
void
parse(File file)
Parse aFile
void
parse(InputStream is)
Parse aInputStream
.void
parse(String filename)
Parse a file identified by its path.protected abstract Object
parseOneRecord(String record)
Handle the parsing of a single record from the input.void
setRecordSeparator(String recordSeparator)
-
-
-
Method Detail
-
getResults
public abstract Collection<T> getResults()
- Specified by:
getResults
in interfaceParser<T>
- Returns:
- the results of the parse.
-
parse
public void parse(File file) throws IOException
Description copied from interface:Parser
Parse aFile
- Specified by:
parse
in interfaceParser<T>
- Parameters:
file
- file- Throws:
IOException
- if there is a problem while manipulating the file
-
parse
public void parse(InputStream is) throws IOException
Description copied from interface:Parser
Parse aInputStream
.- Specified by:
parse
in interfaceParser<T>
- Parameters:
is
- input stream- Throws:
IOException
- if there is a problem while manipulating the file
-
parse
public void parse(String filename) throws IOException
Description copied from interface:Parser
Parse a file identified by its path.- Specified by:
parse
in interfaceParser<T>
- Parameters:
filename
- Absolute path to the file- Throws:
IOException
- if there is a problem while manipulating the file
-
setRecordSeparator
public void setRecordSeparator(String recordSeparator)
-
parseOneRecord
protected abstract Object parseOneRecord(String record)
Handle the parsing of a single record from the input.- Parameters:
record
- record- Returns:
- parsed object
-
addResult
protected abstract void addResult(Object obj)
Add an object to the results collection.- Parameters:
obj
- object
-
-