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 TypeMethodDescriptionbooleanReport whether empty tags will be treated as continuations of the last non -empty tag.Get the explicit end-of-record string.booleanReport whether empty tags will be treated as continuations of the last non -empty tag.Get the Pattern currently used to split lines.intGet the group number that matches the tag.booleanSee if trimming of tags is enabled.booleanSee if trimming of values is enabled.intGet the group number that matches the value.voidsetContinueOnEmptyTag(boolean continueOnEmptyTag) Decide whether to treat empty tags as continuations of the previous non -empty tag.voidsetEndOfRecord(String endOfRecord) Set the explicit end-of-record string.voidsetMergeSameTag(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.voidsetPattern(Pattern pattern) Set the Pattern used to split lines.voidsetTagGroup(int group) Set the group number that will match the tag.voidsetTrimTag(boolean trimTag) Enable trimming of the tag using String.trim().voidsetTrimValue(boolean trimValue) Enable trimming of the value using String.trim().voidsetValueGroup(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:
parsein interfaceTagValueParser- Throws:
ParserException
-