Class AbstractMessageParser<T>
- java.lang.Object
-
- org.orekit.files.ccsds.utils.parsing.AbstractMessageParser<T>
-
- Type Parameters:
T
- type of the file
- All Implemented Interfaces:
MessageParser<T>
- Direct Known Subclasses:
AbstractConstituentParser
,NdmParser
public abstract class AbstractMessageParser<T> extends Object implements MessageParser<T>
Parser for CCSDS messages.Note than starting with Orekit 11.0, CCSDS message parsers are mutable objects that gather the data being parsed, until the message is complete and the
parseMessage
method has returned. This implies that parsers should not be used in a multi-thread context. The recommended way to use parsers is to either dedicate one parser for each message and drop it afterwards, or to use a single-thread loop.- Since:
- 11.0
- Author:
- Luc Maisonobe
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMessageParser(String root, String formatVersionKey, Function<ParseToken,List<ParseToken>>[] filters)
Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
anticipateNext(ProcessingState anticipated)
Anticipate what next processing state should be.ProcessingState
getCurrent()
Get the current processing state.FileFormat
getFileFormat()
Get the file format of the last message parsed.String
getFormatVersionKey()
Get the key for format version.Map<String,XmlTokenBuilder>
getSpecialXmlElementsBuilders()
Get the non-default token builders for special XML elements.T
parseMessage(DataSource source)
Parse a data source.void
process(ParseToken token)
Process a parse token.protected void
reset(FileFormat fileFormat, ProcessingState initialState)
Reset parser to initial state before parsing.void
setEndTagSeen(boolean endTagSeen)
Set the flag for XML end tag.void
setFallback(ProcessingState fallback)
Set fallback processing state.boolean
wasEndTagSeen()
Check if XML end tag has been seen.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.orekit.files.ccsds.utils.lexical.MessageParser
build, reset
-
-
-
-
Constructor Detail
-
AbstractMessageParser
protected AbstractMessageParser(String root, String formatVersionKey, Function<ParseToken,List<ParseToken>>[] filters)
Simple constructor.- Parameters:
root
- root element for XML filesformatVersionKey
- key for format versionfilters
- filters to apply to parse tokens- Since:
- 12.0
-
-
Method Detail
-
setFallback
public void setFallback(ProcessingState fallback)
Set fallback processing state.The fallback processing state is used if anticipated state fails to parse the token.
- Parameters:
fallback
- processing state to use if anticipated state does not work
-
reset
protected void reset(FileFormat fileFormat, ProcessingState initialState)
Reset parser to initial state before parsing.- Parameters:
fileFormat
- format of the file ready to be parsedinitialState
- initial processing state
-
setEndTagSeen
public void setEndTagSeen(boolean endTagSeen)
Set the flag for XML end tag.- Parameters:
endTagSeen
- if true, the XML end tag has been seen
-
wasEndTagSeen
public boolean wasEndTagSeen()
Check if XML end tag has been seen.- Returns:
- true if XML end tag has been seen
-
getCurrent
public ProcessingState getCurrent()
Get the current processing state.- Returns:
- current processing state
-
getFileFormat
public FileFormat getFileFormat()
Get the file format of the last message parsed.- Specified by:
getFileFormat
in interfaceMessageParser<T>
- Returns:
- file format of the last message parsed
-
parseMessage
public T parseMessage(DataSource source)
Parse a data source.- Specified by:
parseMessage
in interfaceMessageParser<T>
- Parameters:
source
- data source to parse- Returns:
- parsed file
-
getFormatVersionKey
public String getFormatVersionKey()
Get the key for format version.- Specified by:
getFormatVersionKey
in interfaceMessageParser<T>
- Returns:
- format version key
-
getSpecialXmlElementsBuilders
public Map<String,XmlTokenBuilder> getSpecialXmlElementsBuilders()
Get the non-default token builders for special XML elements.- Specified by:
getSpecialXmlElementsBuilders
in interfaceMessageParser<T>
- Returns:
- map of token builders for special XML elements (keyed by XML element name)
-
anticipateNext
public void anticipateNext(ProcessingState anticipated)
Anticipate what next processing state should be.- Parameters:
anticipated
- anticipated next processing state
-
process
public void process(ParseToken token)
Process a parse token.- Specified by:
process
in interfaceMessageParser<T>
- Parameters:
token
- token to process
-
-