Class 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 Detail

      • AbstractMessageParser

        protected AbstractMessageParser​(String root,
                                        String formatVersionKey,
                                        Function<ParseToken,​List<ParseToken>>[] filters)
        Simple constructor.
        Parameters:
        root - root element for XML files
        formatVersionKey - key for format version
        filters - 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 parsed
        initialState - 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 interface MessageParser<T>
        Returns:
        file format of the last message parsed
      • parseMessage

        public T parseMessage​(DataSource source)
        Parse a data source.
        Specified by:
        parseMessage in interface MessageParser<T>
        Parameters:
        source - data source to parse
        Returns:
        parsed file
      • 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 interface MessageParser<T>
        Parameters:
        token - token to process