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.ndm.cdm;
18  
19  import org.orekit.files.ccsds.utils.lexical.ParseToken;
20  import org.orekit.files.ccsds.utils.lexical.TokenType;
21  
22  /** Keywords for CDM data sub-structure in XML files.
23   * @author Melina Vanel
24   * @since 11.2
25   */
26  public enum XmlSubStructureKey {
27  
28      /** General comment. */
29      COMMENT((token, parser) -> token.getType() == TokenType.ENTRY ? parser.addGeneralComment(token.getContentAsNormalizedString()) : true),
30  
31      /** Relative Metadata section. */
32      relativeMetadataData((token, parser) -> parser.manageRelativeMetadataSection(token.getType() == TokenType.START)),
33  
34      /** Segment structure. */
35      segment((token, parser) -> true),
36  
37      /** Relative Metadata section. */
38      relativeStateVector((token, parser) -> parser.manageRelativeStateVectorSection(token.getType() == TokenType.START)),
39  
40      /** OD Parameters section. */
41      odParameters((token, parser) -> parser.manageODParametersSection(token.getType() == TokenType.START)),
42  
43      /** Additional Parameter section. */
44      additionalParameters((token, parser) -> parser.manageAdditionalParametersSection(token.getType() == TokenType.START)),
45  
46      /** State Vector section. */
47      stateVector((token, parser) -> parser.manageStateVectorSection(token.getType() == TokenType.START)),
48  
49      /** Covariance Matrix section. */
50      covarianceMatrix((token, parser) -> parser.manageXmlGeneralCovarianceSection(token.getType() == TokenType.START)),
51  
52          /** User-defined parameters section. */
53      userDefinedParameters((token, parser) -> parser.manageUserDefinedParametersSection(token.getType() == TokenType.START));
54  
55      /** Processing method. */
56      private final transient TokenProcessor processor;
57  
58      /** Simple constructor.
59       * @param processor processing method
60       */
61      XmlSubStructureKey(final TokenProcessor processor) {
62          this.processor = processor;
63      }
64  
65      /** Process one token.
66       * @param token token to process
67       * @param parser CDM file parser
68       * @return true of token was accepted
69       */
70      public boolean process(final ParseToken token, final CdmParser parser) {
71          return processor.process(token, parser);
72      }
73  
74      /** Interface for processing one token. */
75      interface TokenProcessor {
76          /** Process one token.
77           * @param token token to process
78           * @param parser CDM file parser
79           * @return true of token was accepted
80           */
81          boolean process(ParseToken token, CdmParser parser);
82      }
83  
84  }