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 booleangetContinueOnEmptyTag()Report whether empty tags will be treated as continuations of the last non -empty tag.StringgetEndOfRecord()Get the explicit end-of-record string.booleangetMergeSameTag()Report whether empty tags will be treated as continuations of the last non -empty tag.PatterngetPattern()Get the Pattern currently used to split lines.intgetTagGroup()Get the group number that matches the tag.booleangetTrimTag()See if trimming of tags is enabled.booleangetTrimValue()See if trimming of values is enabled.intgetValueGroup()Get the group number that matches the value.TagValueparse(Object o)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 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:
parsein interfaceTagValueParser- Throws:
ParserException
-
-