1   /* Copyright 2002-2025 CS GROUP
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.orekit.files.ccsds.utils.lexical;
18  
19  import java.util.Map;
20  
21  import org.orekit.data.DataSource;
22  import org.orekit.files.ccsds.utils.FileFormat;
23  
24  /** Parser for CCSDS messages.
25   * @param <T> type of the file
26   * @author Luc Maisonobe
27   * @since 11.0
28   */
29  public interface MessageParser<T> {
30  
31      /** Parse a data source.
32       * @param source data source to parse
33       * @return parsed file
34       */
35      T parseMessage(DataSource source);
36  
37      /** Get the key for format version.
38       * @return format version key
39       */
40      String getFormatVersionKey();
41  
42      /** Get the non-default token builders for special XML elements.
43       * @return map of token builders for special XML elements (keyed by XML element name)
44       */
45      Map<String, XmlTokenBuilder> getSpecialXmlElementsBuilders();
46  
47      /** Reset parser to initial state before parsing.
48       * @param fileFormat format of the file ready to be parsed
49       */
50      void reset(FileFormat fileFormat);
51  
52      /** Process a parse token.
53       * @param token token to process
54       */
55      void process(ParseToken token);
56  
57      /** Build the file from parsed entries.
58       * @return parsed file
59       */
60      T build();
61  
62      /** Get the file format of the last message parsed.
63       * @return file format of the last message parsed
64       * @since 12.0
65       */
66      FileFormat getFileFormat();
67  
68  }