Package com.igormaznitsa.jbbp
Interface JBBPCustomFieldTypeProcessor
- All Known Implementing Classes:
JBBPCustomFieldTypeProcessorAggregator
public interface JBBPCustomFieldTypeProcessor
Allows to define and process own custom field types during parsing.
- Since:
- 1.2.0
-
Method Summary
Modifier and TypeMethodDescriptionString[]Get custom types of fields supported by the custom type field processor.booleanisAllowed(JBBPFieldTypeParameterContainer fieldType, String fieldName, int extraData, boolean isArray) Called by compiler to check parameters for custom field.readCustomFieldType(JBBPBitInputStream in, JBBPBitOrder bitOrder, int parserFlags, JBBPFieldTypeParameterContainer customTypeFieldInfo, JBBPNamedFieldInfo fieldName, int extraData, boolean readWholeStream, int arrayLength, JBBPArraySizeLimiter arraySizeLimiter) Read custom field from stream and return the data as a JBBP field.
-
Method Details
-
getCustomFieldTypes
String[] getCustomFieldTypes()Get custom types of fields supported by the custom type field processor.- Returns:
- array of strings where every string is custom field type in lower-case.
-
isAllowed
boolean isAllowed(JBBPFieldTypeParameterContainer fieldType, String fieldName, int extraData, boolean isArray) Called by compiler to check parameters for custom field.- Parameters:
fieldType- field type info, it must not be nullfieldName- name of the field, it can be null for anonymous fieldsextraData- number placed as extra value for field, followed by ':' if not presented then zero, if it is expression then -1isArray- flag shows that the field describes an array- Returns:
- true if such configuration allowed, false otherwise
-
readCustomFieldType
JBBPAbstractField readCustomFieldType(JBBPBitInputStream in, JBBPBitOrder bitOrder, int parserFlags, JBBPFieldTypeParameterContainer customTypeFieldInfo, JBBPNamedFieldInfo fieldName, int extraData, boolean readWholeStream, int arrayLength, JBBPArraySizeLimiter arraySizeLimiter) throws IOException Read custom field from stream and return the data as a JBBP field.- Parameters:
in- the data source stream, must not be nullbitOrder- the bit order defined for parsing, must not be nullparserFlags- the flags defined for parsingcustomTypeFieldInfo- the current field type info, must not be nullfieldName- the field name info, it can be null if the field is anonymous oneextraData- extra numeric value for the field, followed by ':', if not presented then 0readWholeStream- if true then the field is array which should contain parse data for whole stream till the endarrayLength- -1 if it is not array else length of the array to be read.arraySizeLimiter- limiter to check number of elements during whole stream array read, must not be null- Returns:
- parsed data as JBBP field, must not be null
- Throws:
IOException- it can be thrown for transport errorsJBBPReachedArraySizeLimitException- thrown if reached limit for a whole stream array- Since:
- 2.1.0
- See Also:
-