org.biojavax.bio.phylo.io.nexus
Class NexusBlockParser.Abstract

java.lang.Object
  extended by org.biojavax.bio.phylo.io.nexus.NexusBlockParser.Abstract
All Implemented Interfaces:
NexusBlockParser
Direct Known Subclasses:
CharactersBlockParser, DistancesBlockParser, TaxaBlockParser, TreesBlockParser
Enclosing interface:
NexusBlockParser

public abstract static class NexusBlockParser.Abstract
extends Object
implements NexusBlockParser

All block parsers should derive from this abstract parser.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.biojavax.bio.phylo.io.nexus.NexusBlockParser
NexusBlockParser.Abstract
 
Field Summary
 
Fields inherited from interface org.biojavax.bio.phylo.io.nexus.NexusBlockParser
UNKNOWN_BLOCK
 
Constructor Summary
NexusBlockParser.Abstract(NexusBlockListener blockListener)
           
 
Method Summary
 void beginComment()
          Opening a comment tag.
 void commentText(String comment)
          Receiving free text inside a comment tag.
 void endBlock()
          Notifies the parser that a block is ending.
 void endComment()
          Closing a comment tag.
 void endTokenGroup()
          Closing a line (semi-colon encountered).
 NexusBlockListener getBlockListener()
          Obtain the listener for this parser.
protected  String getBlockName()
           
abstract  void parseToken(String token)
          Notifies the parser of the next token.
protected abstract  void resetStatus()
          This function is called when the parser is reset before starting a new block.
 void startBlock(String blockName)
          Notifies the parser that a new block is starting.
 boolean wantsBracketsAndBraces()
          Does the listener want to know about brackets and braces as separate tokens?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NexusBlockParser.Abstract

public NexusBlockParser.Abstract(NexusBlockListener blockListener)
Method Detail

getBlockListener

public NexusBlockListener getBlockListener()
Description copied from interface: NexusBlockParser
Obtain the listener for this parser.

Specified by:
getBlockListener in interface NexusBlockParser
Returns:
the listener.

startBlock

public void startBlock(String blockName)
Description copied from interface: NexusBlockParser
Notifies the parser that a new block is starting.

Specified by:
startBlock in interface NexusBlockParser
Parameters:
blockName - the name of the block.

resetStatus

protected abstract void resetStatus()
This function is called when the parser is reset before starting a new block.


getBlockName

protected String getBlockName()

endBlock

public void endBlock()
Description copied from interface: NexusBlockParser
Notifies the parser that a block is ending.

Specified by:
endBlock in interface NexusBlockParser

beginComment

public void beginComment()
Description copied from interface: NexusBlockParser
Opening a comment tag.

Specified by:
beginComment in interface NexusBlockParser

endComment

public void endComment()
Description copied from interface: NexusBlockParser
Closing a comment tag.

Specified by:
endComment in interface NexusBlockParser

endTokenGroup

public void endTokenGroup()
Description copied from interface: NexusBlockParser
Closing a line (semi-colon encountered). This indicates that anything received after it is on the next logical line of the block.

Specified by:
endTokenGroup in interface NexusBlockParser

commentText

public void commentText(String comment)
                 throws ParseException
Description copied from interface: NexusBlockParser
Receiving free text inside a comment tag.

Specified by:
commentText in interface NexusBlockParser
Parameters:
comment - the text of the comment.
Throws:
ParseException

parseToken

public abstract void parseToken(String token)
                         throws ParseException
Description copied from interface: NexusBlockParser
Notifies the parser of the next token. Comment tokens will already have been parsed out and sent separately to the text() method of the listener. Quoted strings will have been parsed and underscores converted. What this token contains is the full string, after removal of quotes if necessary. The token will never be only whitespace.

Specified by:
parseToken in interface NexusBlockParser
Parameters:
token - the token to parse.
Throws:
ParseException - if the token is unparseable.

wantsBracketsAndBraces

public boolean wantsBracketsAndBraces()
Description copied from interface: NexusBlockParser
Does the listener want to know about brackets and braces as separate tokens?

Specified by:
wantsBracketsAndBraces in interface NexusBlockParser
Returns:
true if it does.