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
parseMessagemethod 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 protectedAbstractMessageParser(String root, String formatVersionKey, Function<ParseToken,List<ParseToken>>[] filters)Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidanticipateNext(ProcessingState anticipated)Anticipate what next processing state should be.ProcessingStategetCurrent()Get the current processing state.FileFormatgetFileFormat()Get the file format of the last message parsed.StringgetFormatVersionKey()Get the key for format version.Map<String,XmlTokenBuilder>getSpecialXmlElementsBuilders()Get the non-default token builders for special XML elements.TparseMessage(DataSource source)Parse a data source.voidprocess(ParseToken token)Process a parse token.protected voidreset(FileFormat fileFormat, ProcessingState initialState)Reset parser to initial state before parsing.voidsetEndTagSeen(boolean endTagSeen)Set the flag for XML end tag.voidsetFallback(ProcessingState fallback)Set fallback processing state.booleanwasEndTagSeen()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:
getFileFormatin interfaceMessageParser<T>- Returns:
- file format of the last message parsed
-
parseMessage
public T parseMessage(DataSource source)
Parse a data source.- Specified by:
parseMessagein interfaceMessageParser<T>- Parameters:
source- data source to parse- Returns:
- parsed file
-
getFormatVersionKey
public String getFormatVersionKey()
Get the key for format version.- Specified by:
getFormatVersionKeyin interfaceMessageParser<T>- Returns:
- format version key
-
getSpecialXmlElementsBuilders
public Map<String,XmlTokenBuilder> getSpecialXmlElementsBuilders()
Get the non-default token builders for special XML elements.- Specified by:
getSpecialXmlElementsBuildersin 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:
processin interfaceMessageParser<T>- Parameters:
token- token to process
-
-