Package org.biojava.bio.program.tagvalue
Class RegexParser
- java.lang.Object
-
- org.biojava.bio.program.tagvalue.RegexParser
-
- All Implemented Interfaces:
TagValueParser
public class RegexParser extends Object implements 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
Constructors Constructor Description RegexParser()
Create a new RegexParser with all boolean values set to false.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getContinueOnEmptyTag()
Report whether empty tags will be treated as continuations of the last non -empty tag.String
getEndOfRecord()
Get the explicit end-of-record string.boolean
getMergeSameTag()
Report whether empty tags will be treated as continuations of the last non -empty tag.Pattern
getPattern()
Get the Pattern currently used to split lines.int
getTagGroup()
Get the group number that matches the tag.boolean
getTrimTag()
See if trimming of tags is enabled.boolean
getTrimValue()
See if trimming of values is enabled.int
getValueGroup()
Get the group number that matches the value.TagValue
parse(Object o)
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 Detail
-
RegexParser
public RegexParser()
Create a new RegexParser with all boolean values set to false.
-
-
Method Detail
-
setPattern
public void setPattern(Pattern pattern)
Set the Pattern used to split lines.- Parameters:
pattern
- the Pattern used to split lines
-
getPattern
public Pattern getPattern()
Get the Pattern currently used to split lines.- Returns:
- the current Pattern
-
setTagGroup
public void setTagGroup(int group)
Set the group number that will match the tag.- Parameters:
group
- the tag group number
-
getTagGroup
public int getTagGroup()
Get the group number that matches the tag.- Returns:
- the tag group number
-
setValueGroup
public void setValueGroup(int group)
Set the group number that will match the value.- Parameters:
group
- the value group number
-
getValueGroup
public int getValueGroup()
Get the group number that matches the value.- Returns:
- the value group number
-
setEndOfRecord
public void setEndOfRecord(String endOfRecord)
Set the explicit end-of-record string.- Parameters:
endOfRecord
- the new endOfRecord String
-
getEndOfRecord
public String getEndOfRecord()
Get the explicit end-of-record string.- Returns:
- the current endOfRecord String
-
setTrimTag
public void setTrimTag(boolean trimTag)
Enable trimming of the tag using String.trim().- Parameters:
trimTag
- true if tags should be trimmed, false otherwise
-
getTrimTag
public boolean getTrimTag()
See if trimming of tags is enabled.- Returns:
- true if tag trimming is enabled, false otherwise
-
setTrimValue
public void setTrimValue(boolean trimValue)
Enable trimming of the value using String.trim().- Parameters:
trimValue
- true if values should be trimmed, false otherwise
-
getTrimValue
public boolean getTrimValue()
See if trimming of values is enabled.- Returns:
- true if value trimming is enabled, false otherwise
-
setContinueOnEmptyTag
public void setContinueOnEmptyTag(boolean continueOnEmptyTag)
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
public boolean 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
public 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.- Parameters:
mergeSameTag
- true if tags will be merged, false otherwise
-
getMergeSameTag
public boolean 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
public TagValue parse(Object o) throws ParserException
- Specified by:
parse
in interfaceTagValueParser
- Throws:
ParserException
-
-