public abstract class Dissector extends Object implements Serializable
A Dissector is a class capable of chopping a String into multiple values of specific types.
The lifecycle:
Parser setup
Parser using
Parser.addDissector(Dissector) Parser calls getInputType() and getPossibleOutput() to know
what this dissector can deliver.The parser now constructs a tree based on the available Dissectors
and what was requested.
Dissectors setup
For each node in the tree a new instance of the required dissector is created by calling getNewInstance()
which calls initializeNewInstance(Dissector). Note that only Dissectors
that are actually needed will be in the parse tree.
For each of those instances in the tree:
prepareForDissect(String, String) is called.
This can be used to avoid needless CPU cycles during the actual run.prepareForRun() is done as an indication that all preparation input has been
provided. A Dissector can use this to finalize the runtime data structures so doing the actual dissecting faster.Dissecting
dissect(nl.basjes.parse.core.Parsable<?>, java.lang.String) many times.dissect(Parsable, String) the actual value to be worked on must be retrieved using
Parsable.getParsableField(String, String)Parsable.addDissection(String, String, String, String)| Constructor and Description |
|---|
Dissector() |
| Modifier and Type | Method and Description |
|---|---|
<RECORD> void |
createAdditionalDissectors(Parser<RECORD> parser)
If a dissector really needs to add an additional dissector to the set this method is the
place to do so.
|
abstract void |
dissect(Parsable<?> parsable,
String inputname)
This method must dissect the provided field from the parsable into 'smaller' pieces.
|
String |
extractFieldName(String inputname,
String outputname) |
abstract String |
getInputType() |
Dissector |
getNewInstance()
Create an additional instance of this dissector.
|
abstract List<String> |
getPossibleOutput()
What are all possible outputs that can be provided.
|
boolean |
initializeFromSettingsParameter(String settings)
If a Dissector is loaded through an external language then this is the
method that is called to set all the parameters.
|
protected void |
initializeNewInstance(Dissector newInstance)
This is called after instantiating the class that is actually in the parsetree.
|
abstract EnumSet<Casts> |
prepareForDissect(String inputname,
String outputname)
This tells the dissector that it should prepare that we will call it soon
with 'inputname' and expect to get 'inputname.outputname' because
inputname is of the type returned by getInputType and outputname
was part of the answer from getPossibleOutput.
|
void |
prepareForRun()
The framework will tell the dissector that it should get ready to run.
|
void |
setInputType(String s) |
String |
toString() |
public boolean initializeFromSettingsParameter(String settings)
public abstract void dissect(Parsable<?> parsable, String inputname) throws DissectionFailure
DissectionFailurepublic abstract String getInputType()
public abstract List<String> getPossibleOutput()
public abstract EnumSet<Casts> prepareForDissect(String inputname, String outputname)
public void prepareForRun()
throws InvalidDissectorException
InvalidDissectorExceptionpublic Dissector getNewInstance()
protected void initializeNewInstance(Dissector newInstance) throws InvalidDissectorException
newInstance - The new instances of this class that must be initializedInvalidDissectorExceptionpublic <RECORD> void createAdditionalDissectors(Parser<RECORD> parser)
RECORD - The type of the record.parser - The instance of the parser where the extra dissector is to be added to.public void setInputType(String s) throws InvalidDissectorException
InvalidDissectorExceptionCopyright © 2020. All rights reserved.