java.lang.Object | ||
↳ | com.pnfsoftware.jeb.core.AbstractPlugin | |
↳ | com.pnfsoftware.jeb.core.units.AbstractUnitIdentifier |
Skeleton implementation for an IUnitIdentifier
class (aka, a Parser). It is recommended
parsers extend this class (or one of the its many subclasses) instead of implementing
IUnitIdentifier.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected IPropertyDefinitionManager | pdm | ||||||||||
protected IPropertyManager | pm | ||||||||||
protected double | priority | ||||||||||
protected String | type |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AbstractUnitIdentifier(String type, double priority)
Create a new unit identifier.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean |
acceptAnyInputBytes()
The default implementation returns false.
| ||||||||||
boolean |
canIdentify(IInput input, IUnitCreator parent, String name, Map<Object, Object> identmap)
This non-standard version provides the future unit name (if the identification is successful)
as well as an optional output map of key-values to be filled by the identifier, and provided
to prepare() on success.
| ||||||||||
boolean |
canIdentify(IInput input, IUnitCreator parent)
The default implementation simply calls
canIdentify(IInput, IUnitCreator, String, Map) . | ||||||||||
static boolean |
checkBytes(byte[] data, int offset, byte... marker)
Convenience method used to check for expected bytes at a specific offset within the provided
data buffer.
| ||||||||||
static boolean | checkBytes(byte[] data, int offset, int... marker) | ||||||||||
static boolean | checkBytes(IInput input, int offset, int... marker) | ||||||||||
static boolean | checkBytes(IInput input, int offset, byte... marker) | ||||||||||
static boolean | checkBytes(IInput input, int offset, String header) | ||||||||||
String |
getFormatType()
Retrieve the identity of the unit type.
| ||||||||||
double |
getPriority()
Get the identifier priority.
| ||||||||||
IPropertyDefinitionManager |
getPropertyDefinitionManager()
Retrieve the property definition manager (PDM) used by this plugin.
| ||||||||||
ITypeIdProvider |
getTypeIdProvider()
The type-id provider for this type of units.
| ||||||||||
void |
initialize(IPropertyDefinitionManager parentPdm)
Initialize the property manager for this identifier.
| ||||||||||
IUnit |
prepare(String name, IInput input, IUnitProcessor unitProcessor, IUnitCreator parent)
The default implementation simply calls
prepare(String, IInput, IUnitProcessor, IUnitCreator, Map) . | ||||||||||
IUnit |
prepare(String name, IInput input, IUnitProcessor unitProcessor, IUnitCreator parent, Map<Object, Object> identmap)
This non-standard version can take a map of key-values provided by a successful call to the
non-standard version of canIdentify.
| ||||||||||
static int |
readHeaderByte(IInput input, int offset)
Read a single header byte.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Create a new unit identifier.
type | mandatory type, which will be used as the sub-region type when the identifier is
initialized .
The type should be a valid region name, please see
PropertyDefinitionManager |
---|---|
priority | mandatory priority |
The default implementation returns false.
This non-standard version provides the future unit name (if the identification is successful) as well as an optional output map of key-values to be filled by the identifier, and provided to prepare() on success.
The default implementation simply calls canIdentify(IInput, IUnitCreator)
. A
sub-class must override one version of canIdentify().
The default implementation simply calls
canIdentify(IInput, IUnitCreator, String, Map)
. A sub-class must override one
version of canIdentify().
input | input data, may be null only if the parent is not null |
---|---|
parent | the parent |
prepare
on successful
identification, although identification may be bypassed
Convenience method used to check for expected bytes at a specific offset within the provided data buffer.
data | the input data buffer |
---|---|
offset | the offset |
marker | the bytes to check for |
header | converted to byte[] using encodeUTF8(String) |
---|
Retrieve the identity of the unit type. The type should be unique across all units.
Get the identifier priority. Priority can be negative. Priorities are used by identifier
managers (eg, Processors
) to ensure that identifiers are called in a
(partially) predictable order, if need be. The higher the number, the higher the priority.
Recommendation: typical priority is zero. Relying on priority for proper identification should be used as a last resort measure.
Retrieve the property definition manager (PDM) used by this plugin.
The type-id provider for this type of units. Currently, This method is not intended to use by third-party clients.
Initialize the property manager for this identifier. This method is usually called after construction on the identifier.
Overrides are allowed if a plugin needs to define its own properties, but a call to the superclass method should take place first.
parentPdm | the parent PDM |
---|
The default implementation simply calls
prepare(String, IInput, IUnitProcessor, IUnitCreator, Map)
. A sub-class must
override one version of prepare().
name | the unit name |
---|---|
input | the input binary data for that unit |
unitProcessor | the processor |
parent | the parent |
This non-standard version can take a map of key-values provided by a successful call to the non-standard version of canIdentify.
The default implementation simply calls
prepare(String, IInput, IUnitProcessor, IUnitCreator)
. A sub-class must override
one version of prepare().
Read a single header byte.
offset | offset within the getHeader() |
---|