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; 18 19 import java.util.List; 20 import java.util.Map; 21 import java.util.function.Function; 22 23 import org.orekit.data.DataContext; 24 import org.orekit.files.ccsds.ndm.NdmConstituent; 25 import org.orekit.files.ccsds.ndm.ParsedUnitsBehavior; 26 import org.orekit.files.ccsds.utils.lexical.ParseToken; 27 import org.orekit.files.ccsds.utils.lexical.XmlTokenBuilder; 28 import org.orekit.files.ccsds.utils.parsing.AbstractConstituentParser; 29 import org.orekit.time.AbsoluteDate; 30 import org.orekit.utils.IERSConventions; 31 32 /** 33 * Base class for Attitude Data Message parsers. 34 * <p> 35 * Note than starting with Orekit 11.0, CCSDS message parsers are 36 * mutable objects that gather the data being parsed, until the 37 * message is complete and the {@link #parseMessage(org.orekit.data.DataSource) 38 * parseMessage} method has returned. This implies that parsers 39 * should <em>not</em> be used in a multi-thread context. The recommended 40 * way to use parsers is to either dedicate one parser for each message 41 * and drop it afterwards, or to use a single-thread loop. 42 * </p> 43 * @param <T> type of the file 44 * @param <P> type of the parser 45 * @author Luc Maisonobe 46 * @since 11.0 47 */ 48 public abstract class AdmParser<T extends NdmConstituent<AdmHeader, ?>, P extends AbstractConstituentParser<AdmHeader, T, ?>> 49 extends AbstractConstituentParser<AdmHeader, T, P> { 50 51 /** Index rotation element name. */ 52 private static final String ROTATION_1 = "rotation1"; 53 54 /** Index rotation element name. */ 55 private static final String ROTATION_2 = "rotation2"; 56 57 /** Index rotation element name. */ 58 private static final String ROTATION_3 = "rotation3"; 59 60 /** Reference date for Mission Elapsed Time or Mission Relative Time time systems. */ 61 private final AbsoluteDate missionReferenceDate; 62 63 /** Complete constructor. 64 * @param root root element for XML files 65 * @param formatVersionKey key for format version 66 * @param conventions IERS Conventions 67 * @param simpleEOP if true, tidal effects are ignored when interpolating EOP 68 * @param dataContext used to retrieve frames, time scales, etc. 69 * @param missionReferenceDate reference date for Mission Elapsed Time or Mission Relative Time time systems 70 * (may be null if time system is absolute) 71 * @param parsedUnitsBehavior behavior to adopt for handling parsed units 72 * @param filters filters to apply to parse tokens 73 * @since 12.0 74 */ 75 protected AdmParser(final String root, final String formatVersionKey, final IERSConventions conventions, 76 final boolean simpleEOP, final DataContext dataContext, 77 final AbsoluteDate missionReferenceDate, final ParsedUnitsBehavior parsedUnitsBehavior, 78 final Function<ParseToken, List<ParseToken>>[] filters) { 79 super(root, formatVersionKey, conventions, simpleEOP, dataContext, parsedUnitsBehavior, filters); 80 this.missionReferenceDate = missionReferenceDate; 81 } 82 83 /** {@inheritDoc} */ 84 @Override 85 public Map<String, XmlTokenBuilder> getSpecialXmlElementsBuilders() { 86 87 final Map<String, XmlTokenBuilder> builders = super.getSpecialXmlElementsBuilders(); 88 89 // special handling of rotation elements 90 builders.put(ROTATION_1, new RotationXmlTokenBuilder()); 91 builders.put(ROTATION_2, new RotationXmlTokenBuilder()); 92 builders.put(ROTATION_3, new RotationXmlTokenBuilder()); 93 94 return builders; 95 96 } 97 98 /** 99 * Get reference date for Mission Elapsed Time and Mission Relative Time time systems. 100 * @return the reference date 101 */ 102 public AbsoluteDate getMissionReferenceDate() { 103 return missionReferenceDate; 104 } 105 106 }