Class MessageParserBase<T extends MessageBase>
java.lang.Object
com.sportradar.livedata.sdk.proto.common.MessageParserBase<T>
- All Implemented Interfaces:
MessageParser<T>
- Direct Known Subclasses:
JaxbMessageParser
public abstract class MessageParserBase<T extends MessageBase>
extends Object
implements MessageParser<T>
Represents a base class for message parsers.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMessageParserBase(MessageTokenizer tokenizer) Initializes a new instance of theMessageParserBaseclass. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes any data potentially left in the parser's buffer.protected voidnotifyMessageReady(T message) Notifies the attached observer that message was successfully parsed.protected abstract voidonDataReady(InputStream stream) When overridden in derived class, it processes the received data.final voidprocessData(InputStream stream) Processes passed data.voidsetListener(MessageParserListener<T> listener) Sets theMessageParserListenerinstance used to observe the currentMessageParserBaseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.sportradar.livedata.sdk.proto.common.MessageParser
getEncoding
-
Constructor Details
-
MessageParserBase
Initializes a new instance of theMessageParserBaseclass.- Parameters:
tokenizer- AMessageTokenizerimplementation used to tokenize received data, or a null reference.
-
-
Method Details
-
onDataReady
When overridden in derived class, it processes the received data.- Parameters:
stream- AInputStreamimplementation containing the received data.- Throws:
SdkException- thrown when an un-expected situation is encountered.
-
notifyMessageReady
Notifies the attached observer that message was successfully parsed.- Parameters:
message- the parsed message
-
processData
Processes passed data. If passed data and any previously stored data represent a whole message theMessageParserListener.onMessageReady(T)method is invoked- Specified by:
processDatain interfaceMessageParser<T extends MessageBase>- Parameters:
stream- AInputStreaminstance containing message data.- Throws:
IllegalArgumentException- thestreamis a null reference.ProtocolException- the data could not be processed either because the buffer is full, an un-expected character was encountered or there was an error while un-marshalling the messageSdkException
-
clear
public void clear()Removes any data potentially left in the parser's buffer.- Specified by:
clearin interfaceMessageParser<T extends MessageBase>
-
setListener
Sets theMessageParserListenerinstance used to observe the currentMessageParserBase- Specified by:
setListenerin interfaceMessageParser<T extends MessageBase>- Parameters:
listener- TheMessageParserListenerinstance used to observe the currentMessageParserBaseor a null reference.
-