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.adm.apm;
18  
19  import org.orekit.files.ccsds.utils.ContextBinding;
20  import org.orekit.files.ccsds.utils.lexical.ParseToken;
21  import org.orekit.files.ccsds.utils.lexical.TokenType;
22  
23  /** Keywords for APM data sub-structure.
24   * @author Luc Maisonobe
25   * @since 11.0
26   */
27  enum ApmDataSubStructureKey {
28  
29      /** General comment. */
30      COMMENT((token, context, parser) -> token.getType() == TokenType.ENTRY ? parser.addGeneralComment(token.getContentAsNormalizedString()) : true),
31  
32      /** Epoch. */
33      EPOCH((token, context, parser) -> token.processAsDate(parser::setEpoch, context)),
34  
35      /** Quaternion block. */
36      QUAT((token, context, parser) -> parser.manageQuaternionSection(token.getType() == TokenType.START)),
37  
38      /** Quaternion section. */
39      quaternionState((token, context, parser) -> parser.manageQuaternionSection(token.getType() == TokenType.START)),
40  
41      /** Euler elements. */
42      EULER((token, context, parser) -> parser.manageEulerElementsSection(token.getType() == TokenType.START)),
43  
44      /** Euler elements. */
45      eulerAngleState((token, context, parser) -> parser.manageEulerElementsSection(token.getType() == TokenType.START)),
46  
47      /** Angular velocity elements. */
48      ANGVEL((token, context, parser) -> parser.manageAngularVelocitylementsSection(token.getType() == TokenType.START)),
49  
50      /** Angular velocity elements. */
51      angularVelocity((token, context, parser) -> parser.manageAngularVelocitylementsSection(token.getType() == TokenType.START)),
52  
53      /** Euler elements / three axis stabilized section (ADM V1 only). */
54      eulerElementsThree((token, context, parser) -> parser.manageEulerElementsSection(token.getType() == TokenType.START)),
55  
56      /** Euler elements /spin stabilized section (ADM V1 only). */
57      eulerElementsSpin((token, context, parser) -> parser.manageSpinElementsSection(token.getType() == TokenType.START)),
58  
59      /** Spin elements. */
60      SPIN((token, context, parser) -> parser.manageSpinElementsSection(token.getType() == TokenType.START)),
61  
62      /** Spin elements. */
63      spin((token, context, parser) -> parser.manageSpinElementsSection(token.getType() == TokenType.START)),
64  
65      /** Spacecraft parameters section (ADM V1 only). */
66      spacecraftParameters((token, context, parser) -> parser.manageInertiaSection(token.getType() == TokenType.START)),
67  
68      /** Inertia elements. */
69      INERTIA((token, context, parser) -> parser.manageInertiaSection(token.getType() == TokenType.START)),
70  
71      /** Inertia elements. */
72      inertia((token, context, parser) -> parser.manageInertiaSection(token.getType() == TokenType.START)),
73  
74      /** Maneuver parameters section. */
75      MAN((token, context, parser) -> parser.manageManeuverParametersSection(token.getType() == TokenType.START)),
76  
77      /** Maneuver parameters section. */
78      maneuverParameters((token, context, parser) -> parser.manageManeuverParametersSection(token.getType() == TokenType.START));
79  
80      /** Processing method. */
81      private final transient TokenProcessor processor;
82  
83      /** Simple constructor.
84       * @param processor processing method
85       */
86      ApmDataSubStructureKey(final TokenProcessor processor) {
87          this.processor = processor;
88      }
89  
90      /** Process one token.
91       * @param token token to process
92       * @param context context binding
93       * @param parser APM file parser
94       * @return true of token was accepted
95       */
96      public boolean process(final ParseToken token, final ContextBinding context, final ApmParser parser) {
97          return processor.process(token, context, parser);
98      }
99  
100     /** Interface for processing one token. */
101     interface TokenProcessor {
102         /** Process one token.
103          * @param token token to process
104          * @param context context binding
105          * @param parser APM file parser
106          * @return true of token was accepted
107          */
108         boolean process(ParseToken token, ContextBinding context, ApmParser parser);
109     }
110 
111 }