Package org.biojava.bio.program.tagvalue
Class LineSplitParser
- java.lang.Object
-
- org.biojava.bio.program.tagvalue.LineSplitParser
-
- All Implemented Interfaces:
Cloneable
,TagValueParser
public class LineSplitParser extends Object implements TagValueParser, Cloneable
A parser that splits a line into tag/value at a given column number. The GENBANK and EMBL constants are parsers pre-configured for genbank and embl style files respectively.
There are many properties of the parser that can be set to change how lines are split, and how the tag and value is produced from that split.
- endOfRecord - string starting lines that mark record boundaries e.g. "//"
- splitOffset - column index of the first character of the value, and the length of the raw tag e.g. 5 for EMBL files
- trimTag - trim white-space from tags
- trimValue - trim white-space from values
- continueOnEmptyTag - if the tag is empty, use the previous tag e.g. this is true for GENBANK files and false for EMBL files
- mergeSameTag - if two consecutive tags have the same value, consider their values to be a continuation of a single value so don't fire start/end tag events e.g. true for EMBL
- Since:
- 1.2
- Author:
- Matthew Pocock, Keith James (enabled empty line EOR)
-
-
Field Summary
Fields Modifier and Type Field Description static LineSplitParser
EMBL
A LineSplitParser pre-configured to process EMBL-style flat files.static LineSplitParser
GENBANK
A LineSplitParser pre-configured to process GENBANK-style flat files.-
Fields inherited from interface org.biojava.bio.program.tagvalue.TagValueParser
EMPTY_LINE_EOR
-
-
Constructor Summary
Constructors Constructor Description LineSplitParser()
LineSplitParser(LineSplitParser parser)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
boolean
getContinueOnEmptyTag()
See if empty tags are treated as a continuation of previous tags or as a new tag with the value of the empty string.String
getEndOfRecord()
Get the current string indicating that a record has ended.boolean
getMergeSameTag()
See if tags are being merged.int
getSplitOffset()
Get the current offset at which lines are split.boolean
getTrimTag()
See if tag trimming is enabled.boolean
getTrimValue()
See if value trimming is enabled.TagValue
parse(Object o)
void
setContinueOnEmptyTag(boolean continueOnEmptyTag)
Choose whether to treat empty tags as a continuation of previous tags or as a new tag with the value of the empty string.void
setEndOfRecord(String endOfRecord)
Set the string indicating that a record has ended.void
setMergeSameTag(boolean mergeSameTag)
Enable or disable treating runs of identical tags as a single tag start event with multiple values or each as a separate tag start, value, and tag end.void
setSplitOffset(int splitOffset)
Set the offset to split lines at.void
setTrimTag(boolean trimTag)
Enable or disable trimming of tags.void
setTrimValue(boolean trimValue)
Enable or disable trimming of values.
-
-
-
Field Detail
-
EMBL
public static final LineSplitParser EMBL
A LineSplitParser pre-configured to process EMBL-style flat files.
-
GENBANK
public static final LineSplitParser GENBANK
A LineSplitParser pre-configured to process GENBANK-style flat files.
-
-
Constructor Detail
-
LineSplitParser
public LineSplitParser()
-
LineSplitParser
public LineSplitParser(LineSplitParser parser)
-
-
Method Detail
-
setEndOfRecord
public void setEndOfRecord(String endOfRecord)
Set the string indicating that a record has ended.- Parameters:
endOfRecord
- the new String delimiting records
-
getEndOfRecord
public String getEndOfRecord()
Get the current string indicating that a record has ended.- Returns:
- the current string delimiting records.
-
setSplitOffset
public void setSplitOffset(int splitOffset)
Set the offset to split lines at.- Parameters:
splitOffset
- the new offset to split at
-
getSplitOffset
public int getSplitOffset()
Get the current offset at which lines are split.- Returns:
- the offset to split at
-
setTrimTag
public void setTrimTag(boolean trimTag)
Enable or disable trimming of tags.- Parameters:
trimTag
- true if tags should be trimmed, otherwise false
-
getTrimTag
public boolean getTrimTag()
See if tag trimming is enabled.- Returns:
- true if tags are trimmed, otherwise false
-
setTrimValue
public void setTrimValue(boolean trimValue)
Enable or disable trimming of values.- Parameters:
trimValue
- true if values should be trimmed, otherwise false
-
getTrimValue
public boolean getTrimValue()
See if value trimming is enabled.- Returns:
- true if values are trimmed, otherwise false
-
setContinueOnEmptyTag
public void setContinueOnEmptyTag(boolean continueOnEmptyTag)
Choose whether to treat empty tags as a continuation of previous tags or as a new tag with the value of the empty string.- Parameters:
continueOnEmptyTag
- true to enable empty tags to be treated as a continuation of the previous tag, false otherwise
-
getContinueOnEmptyTag
public boolean getContinueOnEmptyTag()
See if empty tags are treated as a continuation of previous tags or as a new tag with the value of the empty string.- Returns:
- true if continuation is enabled, false otherwise
-
setMergeSameTag
public void setMergeSameTag(boolean mergeSameTag)
Enable or disable treating runs of identical tags as a single tag start event with multiple values or each as a separate tag start, value, and tag end.- Parameters:
mergeSameTag
- true if tags should be merged, false otherwise
-
getMergeSameTag
public boolean getMergeSameTag()
See if tags are being merged.- Returns:
- true if merging is enabled, false otherwise
-
parse
public TagValue parse(Object o)
- Specified by:
parse
in interfaceTagValueParser
-
clone
public Object clone() throws CloneNotSupportedException
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
-