public class NexusCommandReaderFactory extends java.lang.Object
NexusCommandEventReader
. Each Nexus command can have a
specific reader, which can be created by an instance of this class. The readers that can be created by a factory
instance depend on the registered reader classes (see below).
An instance of this class needs to be passed to the constructor of NexusEventReader
. The readers added to
this factory determine the Nexus commands that will be supported by that reader instance.
Any class of command reader can be added to this factory to be associated with a certain Nexus command in a
certain Nexus block. The method addJPhyloIOReaders()
can be used to add all command readers that
are defined in JPhyloIO to an instance. If additional custom readers are defined on application level,
these can be added using addReaderClass(Class)
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALL_BLOCKS_IDENTIFIER |
static char |
BLOCK_COMMAND_CONNECTOR |
Constructor and Description |
---|
NexusCommandReaderFactory()
Creates a new empty instance of this class.
|
Modifier and Type | Method and Description |
---|---|
void |
addJPhyloIOReaders()
Adds all Nexus command readers available in JPhyloIO to this instance.
|
void |
addReaderClass(java.lang.Class<? extends NexusCommandEventReader> readerClass)
Adds a new type of reader to this factory instance.
|
NexusCommandEventReader |
createReader(java.lang.String blockName,
java.lang.String commandName,
NexusReaderStreamDataProvider streamDataProvider)
Creates a new reader instance that is able to parse the specified command in the specified block, if
an according class was registered in this factory instance.
|
static NexusCommandReaderFactory |
newJPhyloIOInstance()
Returns a new instance of this class, already containing all command readers available in
the core module of JPhyloIO.
|
public static final java.lang.String ALL_BLOCKS_IDENTIFIER
public static final char BLOCK_COMMAND_CONNECTOR
public NexusCommandReaderFactory()
addJPhyloIOReaders()
,
newJPhyloIOInstance()
public static NexusCommandReaderFactory newJPhyloIOInstance()
addJPhyloIOReaders()
is called internally.)public void addJPhyloIOReaders()
public void addReaderClass(java.lang.Class<? extends NexusCommandEventReader> readerClass) throws java.lang.IllegalArgumentException
readerClass
- the class of the Nexus command reader type to be addedjava.lang.IllegalArgumentException
- if the specified class does not offer an constructor as described in
NexusCommandEventReader
public NexusCommandEventReader createReader(java.lang.String blockName, java.lang.String commandName, NexusReaderStreamDataProvider streamDataProvider)
blockName
- the name of the block the command to parse is contained incommandName
- the name of the command to be parsedstreamDataProvider
- the stream and data provider to be used by the returned readernull
if no according reader was found in this factory