Package org.biojava.bio.program.tagvalue
Class LineSplitParser
java.lang.Object
org.biojava.bio.program.tagvalue.LineSplitParser
- All Implemented Interfaces:
Cloneable
,TagValueParser
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
FieldsModifier and TypeFieldDescriptionstatic final LineSplitParser
A LineSplitParser pre-configured to process EMBL-style flat files.static final LineSplitParser
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 -
Method Summary
Modifier and TypeMethodDescriptionclone()
boolean
See if empty tags are treated as a continuation of previous tags or as a new tag with the value of the empty string.Get the current string indicating that a record has ended.boolean
See if tags are being merged.int
Get the current offset at which lines are split.boolean
See if tag trimming is enabled.boolean
See if value trimming is enabled.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 Details
-
EMBL
A LineSplitParser pre-configured to process EMBL-style flat files. -
GENBANK
A LineSplitParser pre-configured to process GENBANK-style flat files.
-
-
Constructor Details
-
LineSplitParser
public LineSplitParser() -
LineSplitParser
-
-
Method Details
-
setEndOfRecord
Set the string indicating that a record has ended.- Parameters:
endOfRecord
- the new String delimiting records
-
getEndOfRecord
Get the current string indicating that a record has ended.- Returns:
- the current string delimiting records.
-
setSplitOffset
Set the offset to split lines at.- Parameters:
splitOffset
- the new offset to split at
-
getSplitOffset
Get the current offset at which lines are split.- Returns:
- the offset to split at
-
setTrimTag
Enable or disable trimming of tags.- Parameters:
trimTag
- true if tags should be trimmed, otherwise false
-
getTrimTag
See if tag trimming is enabled.- Returns:
- true if tags are trimmed, otherwise false
-
setTrimValue
Enable or disable trimming of values.- Parameters:
trimValue
- true if values should be trimmed, otherwise false
-
getTrimValue
See if value trimming is enabled.- Returns:
- true if values are trimmed, otherwise false
-
setContinueOnEmptyTag
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
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
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
See if tags are being merged.- Returns:
- true if merging is enabled, false otherwise
-
parse
- Specified by:
parse
in interfaceTagValueParser
-
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-