ApmDataSubStructureKey.java

  1. /* Copyright 2002-2024 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. import org.orekit.files.ccsds.utils.ContextBinding;
  19. import org.orekit.files.ccsds.utils.lexical.ParseToken;
  20. import org.orekit.files.ccsds.utils.lexical.TokenType;

  21. /** Keywords for APM data sub-structure.
  22.  * @author Luc Maisonobe
  23.  * @since 11.0
  24.  */
  25. enum ApmDataSubStructureKey {

  26.     /** General comment. */
  27.     COMMENT((token, context, parser) -> token.getType() == TokenType.ENTRY ? parser.addGeneralComment(token.getContentAsNormalizedString()) : true),

  28.     /** Epoch. */
  29.     EPOCH((token, context, parser) -> token.processAsDate(parser::setEpoch, context)),

  30.     /** Quaternion block. */
  31.     QUAT((token, context, parser) -> parser.manageQuaternionSection(token.getType() == TokenType.START)),

  32.     /** Quaternion section. */
  33.     quaternionState((token, context, parser) -> parser.manageQuaternionSection(token.getType() == TokenType.START)),

  34.     /** Euler elements. */
  35.     EULER((token, context, parser) -> parser.manageEulerElementsSection(token.getType() == TokenType.START)),

  36.     /** Euler elements. */
  37.     eulerAngleState((token, context, parser) -> parser.manageEulerElementsSection(token.getType() == TokenType.START)),

  38.     /** Angular velocity elements. */
  39.     ANGVEL((token, context, parser) -> parser.manageAngularVelocitylementsSection(token.getType() == TokenType.START)),

  40.     /** Angular velocity elements. */
  41.     angularVelocity((token, context, parser) -> parser.manageAngularVelocitylementsSection(token.getType() == TokenType.START)),

  42.     /** Euler elements / three axis stabilized section (ADM V1 only). */
  43.     eulerElementsThree((token, context, parser) -> parser.manageEulerElementsSection(token.getType() == TokenType.START)),

  44.     /** Euler elements /spin stabilized section (ADM V1 only). */
  45.     eulerElementsSpin((token, context, parser) -> parser.manageSpinElementsSection(token.getType() == TokenType.START)),

  46.     /** Spin elements. */
  47.     SPIN((token, context, parser) -> parser.manageSpinElementsSection(token.getType() == TokenType.START)),

  48.     /** Spin elements. */
  49.     spin((token, context, parser) -> parser.manageSpinElementsSection(token.getType() == TokenType.START)),

  50.     /** Spacecraft parameters section (ADM V1 only). */
  51.     spacecraftParameters((token, context, parser) -> parser.manageInertiaSection(token.getType() == TokenType.START)),

  52.     /** Inertia elements. */
  53.     INERTIA((token, context, parser) -> parser.manageInertiaSection(token.getType() == TokenType.START)),

  54.     /** Inertia elements. */
  55.     inertia((token, context, parser) -> parser.manageInertiaSection(token.getType() == TokenType.START)),

  56.     /** Maneuver parameters section. */
  57.     MAN((token, context, parser) -> parser.manageManeuverParametersSection(token.getType() == TokenType.START)),

  58.     /** Maneuver parameters section. */
  59.     maneuverParameters((token, context, parser) -> parser.manageManeuverParametersSection(token.getType() == TokenType.START));

  60.     /** Processing method. */
  61.     private final transient TokenProcessor processor;

  62.     /** Simple constructor.
  63.      * @param processor processing method
  64.      */
  65.     ApmDataSubStructureKey(final TokenProcessor processor) {
  66.         this.processor = processor;
  67.     }

  68.     /** Process one token.
  69.      * @param token token to process
  70.      * @param context context binding
  71.      * @param parser APM file parser
  72.      * @return true of token was accepted
  73.      */
  74.     public boolean process(final ParseToken token, final ContextBinding context, final ApmParser parser) {
  75.         return processor.process(token, context, parser);
  76.     }

  77.     /** Interface for processing one token. */
  78.     interface TokenProcessor {
  79.         /** Process one token.
  80.          * @param token token to process
  81.          * @param context context binding
  82.          * @param parser APM file parser
  83.          * @return true of token was accepted
  84.          */
  85.         boolean process(ParseToken token, ContextBinding context, ApmParser parser);
  86.     }

  87. }