AcmMetadataKey.java

  1. /* Copyright 2022-2025 Luc Maisonobe
  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.acm;

  18. import org.orekit.files.ccsds.utils.ContextBinding;
  19. import org.orekit.files.ccsds.utils.lexical.ParseToken;
  20. import org.orekit.utils.units.Unit;


  21. /** Keys for {@link AcmMetadata ACM container} entries.
  22.  * @author Luc Maisonobe
  23.  * @since 12.0
  24.  */
  25. public enum AcmMetadataKey {

  26.     /** International designator for the object as assigned by the UN Committee
  27.      * on Space Research (COSPAR) and the US National Space Science Data Center (NSSDC). */
  28.     INTERNATIONAL_DESIGNATOR((token, context, container) -> token.processAsNormalizedString(container::setInternationalDesignator)),

  29.     /** Specification of satellite catalog source. */
  30.     CATALOG_NAME((token, context, container) -> token.processAsNormalizedString(container::setCatalogName)),

  31.     /** Unique satellite identification designator for the object. */
  32.     OBJECT_DESIGNATOR((token, context, container) -> token.processAsNormalizedString(container::setObjectDesignator)),

  33.     /** Programmatic Point Of Contact at originator. */
  34.     ORIGINATOR_POC((token, context, container) -> token.processAsFreeTextString(container::setOriginatorPOC)),

  35.     /** Position of Programmatic Point Of Contact at originator. */
  36.     ORIGINATOR_POSITION((token, context, container) -> token.processAsFreeTextString(container::setOriginatorPosition)),

  37.     /** Phone number of Programmatic Point Of Contact at originator. */
  38.     ORIGINATOR_PHONE((token, context, container) -> token.processAsFreeTextString(container::setOriginatorPhone)),

  39.     /** Email address of Programmatic Point Of Contact at originator. */
  40.     ORIGINATOR_EMAIL((token, context, container) -> token.processAsFreeTextString(container::setOriginatorEmail)),

  41.     /** Address of Programmatic Point Of Contact at originator. */
  42.     ORIGINATOR_ADDRESS((token, context, container) -> token.processAsFreeTextString(container::setOriginatorAddress)),

  43.     /** Unique identifier of Orbit Data Message linked to this Attitude Data Message. */
  44.     ODM_MSG_LINK((token, context, container) -> token.processAsFreeTextString(container::setOdmMessageLink)),

  45.     /** Default epoch to which <em>all</em> relative times are referenced in data blocks,
  46.      * unless overridden by block-specific {@link #EPOCH_TZERO} values. */
  47.     EPOCH_TZERO((token, context, container) -> token.processAsDate(container::setEpochT0, context)),

  48.     /** List of elements of information data blocks included in this message. */
  49.     ACM_DATA_ELEMENTS((token, context, container) -> token.processAsEnumsList(AcmElements.class, container::setAcmDataElements)),

  50.     /** Start time entry. */
  51.     START_TIME((token, context, container) -> token.processAsDate(container::setStartTime, context)),

  52.     /** Stop time entry. */
  53.     STOP_TIME((token, context, container) -> token.processAsDate(container::setStopTime, context)),

  54.     /** Difference (TAI – UTC) in seconds at epoch {@link #EPOCH_TZERO}. */
  55.     TAIMUTC_AT_TZERO((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
  56.                                                                           container::setTaimutcT0)),

  57.     /** Epoch of next leap second. */
  58.     NEXT_LEAP_EPOCH((token, context, container) -> token.processAsDate(container::setNextLeapEpoch, context)),

  59.     /** Difference (TAI – UTC) in seconds incorporated at {@link #NEXT_LEAP_EPOCH}. */
  60.     NEXT_LEAP_TAIMUTC((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
  61.                                                                            container::setNextLeapTaimutc));

  62.     /** Processing method. */
  63.     private final transient TokenProcessor processor;

  64.     /** Simple constructor.
  65.      * @param processor processing method
  66.      */
  67.     AcmMetadataKey(final TokenProcessor processor) {
  68.         this.processor = processor;
  69.     }

  70.     /** Process an token.
  71.      * @param token token to process
  72.      * @param context context binding
  73.      * @param container container to fill
  74.      * @return true of token was accepted
  75.      */
  76.     public boolean process(final ParseToken token, final ContextBinding context, final AcmMetadata container) {
  77.         return processor.process(token, context, container);
  78.     }

  79.     /** Interface for processing one token. */
  80.     interface TokenProcessor {
  81.         /** Process one token.
  82.          * @param token token to process
  83.          * @param context context binding
  84.          * @param container container to fill
  85.          * @return true of token was accepted
  86.          */
  87.         boolean process(ParseToken token, ContextBinding context, AcmMetadata container);
  88.     }

  89. }