NdmConstituent.java

  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;

  18. import java.util.Collections;
  19. import java.util.List;

  20. import org.orekit.data.DataContext;
  21. import org.orekit.errors.OrekitException;
  22. import org.orekit.errors.OrekitMessages;
  23. import org.orekit.files.ccsds.section.Header;
  24. import org.orekit.files.ccsds.section.Segment;
  25. import org.orekit.utils.IERSConventions;

  26. /**
  27.  * Constituents of a CCSDS Navigation Data Message.
  28.  * Constituents may be Attitude Data Message (ADM), Orbit Data Message (ODM),
  29.  * Tracking Data Message (TDM)…
  30.  * Each constituent has its own header and a list of segments.
  31.  * @param <H> type of the header
  32.  * @param <S> type of the segments
  33.  * @author Bryan Cazabonne
  34.  * @since 10.2
  35.  */
  36. public abstract class NdmConstituent<H extends Header, S extends Segment<?, ?>> {

  37.     /** Header. */
  38.     private H header;

  39.     /** segments list. */
  40.     private List<S> segments;

  41.     /** IERS conventions used. */
  42.     private final IERSConventions conventions;

  43.     /** Data context. */
  44.     private final DataContext dataContext;

  45.     /**
  46.      * Constructor.
  47.      * @param header file header
  48.      * @param segments file segments
  49.      * @param conventions IERS conventions
  50.      * @param dataContext used for creating frames, time scales, etc.
  51.      */
  52.     protected NdmConstituent(final H header, final List<S> segments,
  53.                              final IERSConventions conventions, final DataContext dataContext) {
  54.         this.header      = header;
  55.         this.segments    = segments;
  56.         this.conventions = conventions;
  57.         this.dataContext = dataContext;
  58.     }

  59.     /**
  60.      * Get the header.
  61.      * @return header
  62.      * @since 11.0
  63.      */
  64.     public H getHeader() {
  65.         return header;
  66.     }

  67.     /**
  68.      * Set the header.
  69.      * @param header the header
  70.      */
  71.     public void setHeader(final H header) {
  72.         this.header = header;
  73.     }

  74.     /**
  75.      * Get the segments.
  76.      * @return segments
  77.      * @since 11.0
  78.      */
  79.     public List<S> getSegments() {
  80.         return Collections.unmodifiableList(segments);
  81.     }

  82.     /**
  83.      * Set the segments.
  84.      * @param segments the segments
  85.      */
  86.     public void setSegments(final List<S> segments) {
  87.         this.segments = segments;
  88.     }

  89.     /**
  90.      * Get IERS conventions.
  91.      * @return IERS conventions
  92.      */
  93.     public IERSConventions getConventions() {
  94.         if (conventions != null) {
  95.             return conventions;
  96.         } else {
  97.             throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  98.         }
  99.     }

  100.     /**
  101.      * Get the data context.
  102.      * @return the data context used for creating frames, time scales, etc.
  103.      */
  104.     public DataContext getDataContext() {
  105.         return dataContext;
  106.     }

  107.     /**
  108.      * Validate the file message for required and forbidden entries.
  109.      * <p>
  110.      * This method throws an exception if file does not meet format requirements.
  111.      * The requirements may depend on format version, which is found in header.
  112.      * </p>
  113.      */
  114.     public void validate() {
  115.         header.validate(header.getFormatVersion());
  116.         for (final S segment : segments) {
  117.             segment.getMetadata().validate(header.getFormatVersion());
  118.             segment.getData().validate(header.getFormatVersion());
  119.         }
  120.     }
  121. }