Package org.biojava.bio.program.tagvalue
Class RegexParser
java.lang.Object
org.biojava.bio.program.tagvalue.RegexParser
- All Implemented Interfaces:
TagValueParser
A TagValueParser that splits a line based upon a regular expression. There are configuration parameters analgous to those in LineSplitParser for configuring parsing details.
- Since:
- 1.3
- Author:
- Matthew Pocock, Keith James (enabled empty line EOR)
-
Field Summary
Fields inherited from interface org.biojava.bio.program.tagvalue.TagValueParser
EMPTY_LINE_EOR
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new RegexParser with all boolean values set to false. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Report whether empty tags will be treated as continuations of the last non -empty tag.Get the explicit end-of-record string.boolean
Report whether empty tags will be treated as continuations of the last non -empty tag.Get the Pattern currently used to split lines.int
Get the group number that matches the tag.boolean
See if trimming of tags is enabled.boolean
See if trimming of values is enabled.int
Get the group number that matches the value.void
setContinueOnEmptyTag
(boolean continueOnEmptyTag) Decide whether to treat empty tags as continuations of the previous non -empty tag.void
setEndOfRecord
(String endOfRecord) Set the explicit end-of-record string.void
setMergeSameTag
(boolean mergeSameTag) Decide if multiple examples of a single tag should be merged into a single start/endTag pair with multiple values, or multiple start/endTag pairs each with a single value.void
setPattern
(Pattern pattern) Set the Pattern used to split lines.void
setTagGroup
(int group) Set the group number that will match the tag.void
setTrimTag
(boolean trimTag) Enable trimming of the tag using String.trim().void
setTrimValue
(boolean trimValue) Enable trimming of the value using String.trim().void
setValueGroup
(int group) Set the group number that will match the value.
-
Constructor Details
-
RegexParser
public RegexParser()Create a new RegexParser with all boolean values set to false.
-
-
Method Details
-
setPattern
Set the Pattern used to split lines.- Parameters:
pattern
- the Pattern used to split lines
-
getPattern
Get the Pattern currently used to split lines.- Returns:
- the current Pattern
-
setTagGroup
Set the group number that will match the tag.- Parameters:
group
- the tag group number
-
getTagGroup
Get the group number that matches the tag.- Returns:
- the tag group number
-
setValueGroup
Set the group number that will match the value.- Parameters:
group
- the value group number
-
getValueGroup
Get the group number that matches the value.- Returns:
- the value group number
-
setEndOfRecord
Set the explicit end-of-record string.- Parameters:
endOfRecord
- the new endOfRecord String
-
getEndOfRecord
Get the explicit end-of-record string.- Returns:
- the current endOfRecord String
-
setTrimTag
Enable trimming of the tag using String.trim().- Parameters:
trimTag
- true if tags should be trimmed, false otherwise
-
getTrimTag
See if trimming of tags is enabled.- Returns:
- true if tag trimming is enabled, false otherwise
-
setTrimValue
Enable trimming of the value using String.trim().- Parameters:
trimValue
- true if values should be trimmed, false otherwise
-
getTrimValue
See if trimming of values is enabled.- Returns:
- true if value trimming is enabled, false otherwise
-
setContinueOnEmptyTag
Decide whether to treat empty tags as continuations of the previous non -empty tag.- Parameters:
continueOnEmptyTag
- true if empty tags should be replaced, false otherwise
-
getContinueOnEmptyTag
Report whether empty tags will be treated as continuations of the last non -empty tag.- Returns:
- true if empty tags will be replaced, false otherwise
-
setMergeSameTag
Decide if multiple examples of a single tag should be merged into a single start/endTag pair with multiple values, or multiple start/endTag pairs each with a single value.- Parameters:
mergeSameTag
- true if tags will be merged, false otherwise
-
getMergeSameTag
Report whether empty tags will be treated as continuations of the last non -empty tag.- Returns:
- true if tags will be merged, false otherwise
-
parse
- Specified by:
parse
in interfaceTagValueParser
- Throws:
ParserException
-