AdmParser.java

  1. /* Copyright 2002-2023 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;

  18. import java.util.List;
  19. import java.util.Map;
  20. import java.util.function.Function;

  21. import org.orekit.data.DataContext;
  22. import org.orekit.files.ccsds.ndm.NdmConstituent;
  23. import org.orekit.files.ccsds.ndm.ParsedUnitsBehavior;
  24. import org.orekit.files.ccsds.utils.lexical.ParseToken;
  25. import org.orekit.files.ccsds.utils.lexical.XmlTokenBuilder;
  26. import org.orekit.files.ccsds.utils.parsing.AbstractConstituentParser;
  27. import org.orekit.time.AbsoluteDate;
  28. import org.orekit.utils.IERSConventions;

  29. /**
  30.  * Base class for Attitude Data Message parsers.
  31.  * <p>
  32.  * Note than starting with Orekit 11.0, CCSDS message parsers are
  33.  * mutable objects that gather the data being parsed, until the
  34.  * message is complete and the {@link #parseMessage(org.orekit.data.DataSource)
  35.  * parseMessage} method has returned. This implies that parsers
  36.  * should <em>not</em> be used in a multi-thread context. The recommended
  37.  * way to use parsers is to either dedicate one parser for each message
  38.  * and drop it afterwards, or to use a single-thread loop.
  39.  * </p>
  40.  * @param <T> type of the file
  41.  * @param <P> type of the parser
  42.  * @author Luc Maisonobe
  43.  * @since 11.0
  44.  */
  45. public abstract class AdmParser<T extends NdmConstituent<AdmHeader, ?>, P extends AbstractConstituentParser<AdmHeader, T, ?>>
  46.     extends AbstractConstituentParser<AdmHeader, T, P> {

  47.     /** Index rotation element name. */
  48.     private static final String ROTATION_1 = "rotation1";

  49.     /** Index rotation element name. */
  50.     private static final String ROTATION_2 = "rotation2";

  51.     /** Index rotation element name. */
  52.     private static final String ROTATION_3 = "rotation3";

  53.     /** Reference date for Mission Elapsed Time or Mission Relative Time time systems. */
  54.     private final AbsoluteDate missionReferenceDate;

  55.     /** Complete constructor.
  56.      * @param root root element for XML files
  57.      * @param formatVersionKey key for format version
  58.      * @param conventions IERS Conventions
  59.      * @param simpleEOP if true, tidal effects are ignored when interpolating EOP
  60.      * @param dataContext used to retrieve frames, time scales, etc.
  61.      * @param missionReferenceDate reference date for Mission Elapsed Time or Mission Relative Time time systems
  62.      * (may be null if time system is absolute)
  63.      * @param parsedUnitsBehavior behavior to adopt for handling parsed units
  64.      * @param filters filters to apply to parse tokens
  65.      * @since 12.0
  66.      */
  67.     protected AdmParser(final String root, final String formatVersionKey, final IERSConventions conventions,
  68.                         final boolean simpleEOP, final DataContext dataContext,
  69.                         final AbsoluteDate missionReferenceDate, final ParsedUnitsBehavior parsedUnitsBehavior,
  70.                         final Function<ParseToken, List<ParseToken>>[] filters) {
  71.         super(root, formatVersionKey, conventions, simpleEOP, dataContext, parsedUnitsBehavior, filters);
  72.         this.missionReferenceDate = missionReferenceDate;
  73.     }

  74.     /** {@inheritDoc} */
  75.     @Override
  76.     public Map<String, XmlTokenBuilder> getSpecialXmlElementsBuilders() {

  77.         final Map<String, XmlTokenBuilder> builders = super.getSpecialXmlElementsBuilders();

  78.         // special handling of rotation elements
  79.         builders.put(ROTATION_1, new RotationXmlTokenBuilder());
  80.         builders.put(ROTATION_2, new RotationXmlTokenBuilder());
  81.         builders.put(ROTATION_3, new RotationXmlTokenBuilder());

  82.         return builders;

  83.     }

  84.     /**
  85.      * Get reference date for Mission Elapsed Time and Mission Relative Time time systems.
  86.      * @return the reference date
  87.      */
  88.     public AbsoluteDate getMissionReferenceDate() {
  89.         return missionReferenceDate;
  90.     }

  91. }