public abstract class Dissector extends Object
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 |
|---|---|
abstract void |
dissect(Parsable<?> parsable,
String inputname)
This method must dissect the provided field from the parsable into 'smaller' pieces.
|
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.
|
abstract 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 abstract void |
initializeNewInstance(Dissector newInstance) |
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.
|
abstract void |
prepareForRun()
The framework will tell the dissector that it should get ready to run.
|
public abstract 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 abstract void prepareForRun()
throws InvalidDissectorException
InvalidDissectorExceptionpublic Dissector getNewInstance()
protected abstract void initializeNewInstance(Dissector newInstance)
Copyright © 2015. All Rights Reserved.