Header.java

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

  18. import org.orekit.time.AbsoluteDate;

  19. /**
  20.  * Header of a CCSDS Navigation Data Message.
  21.  * @author Bryan Cazabonne
  22.  * @since 10.2
  23.  */
  24. public class Header extends CommentsContainer {

  25.     /** CCSDS Format version. */
  26.     private double formatVersion;

  27.     /** File creation date and time in UTC. */
  28.     private AbsoluteDate creationDate;

  29.     /** Creating agency or operator. */
  30.     private String originator;

  31.     /** ID that uniquely identifies a message from a given originator. */
  32.     private String messageId;

  33.     /** Minimum version for {@link HeaderKey#MESSAGE_ID}. */
  34.     private final double minVersionMessageId;

  35.     /**
  36.      * Constructor.
  37.      * @param minVersionMessageId minimum version for {@link HeaderKey#MESSAGE_ID}
  38.      */
  39.     public Header(final double minVersionMessageId) {
  40.         this.formatVersion       = Double.NaN;
  41.         this.minVersionMessageId = minVersionMessageId;
  42.     }

  43.     /** {@inheritDoc} */
  44.     @Override
  45.     public void validate(final double version) {
  46.         super.validate(version);
  47.         checkNotNull(creationDate, HeaderKey.CREATION_DATE);
  48.         checkNotNull(originator,   HeaderKey.ORIGINATOR);
  49.         checkAllowed(version, messageId, HeaderKey.MESSAGE_ID, minVersionMessageId, Double.POSITIVE_INFINITY);
  50.     }

  51.     /**
  52.      * Get the CCSDS NDM (ADM, ODM or TDM) format version.
  53.      * @return format version
  54.      */
  55.     public double getFormatVersion() {
  56.         return formatVersion;
  57.     }

  58.     /**
  59.      * Set the CCSDS NDM (ADM, ODM or TDM) format version.
  60.      * @param formatVersion the format version to be set
  61.      */
  62.     public void setFormatVersion(final double formatVersion) {
  63.         this.formatVersion = formatVersion;
  64.     }

  65.     /**
  66.      * Get the file creation date and time in UTC.
  67.      * @return the file creation date and time in UTC.
  68.      */
  69.     public AbsoluteDate getCreationDate() {
  70.         return creationDate;
  71.     }

  72.     /**
  73.      * Set the file creation date and time in UTC.
  74.      * @param creationDate the creation date to be set
  75.      */
  76.     public void setCreationDate(final AbsoluteDate creationDate) {
  77.         refuseFurtherComments();
  78.         this.creationDate = creationDate;
  79.     }

  80.     /**
  81.      * Get the file originator.
  82.      * @return originator the file originator.
  83.      */
  84.     public String getOriginator() {
  85.         return originator;
  86.     }

  87.     /**
  88.      * Set the file originator.
  89.      * @param originator the originator to be set
  90.      */
  91.     public void setOriginator(final String originator) {
  92.         refuseFurtherComments();
  93.         this.originator = originator;
  94.     }

  95.     /**
  96.      * Get the ID that uniquely identifies a message from a given originator.
  97.      * @return ID that uniquely identifies a message from a given originator
  98.      */
  99.     public String getMessageId() {
  100.         return messageId;
  101.     }

  102.     /**
  103.      * Set the ID that uniquely identifies a message from a given originator.
  104.      * @param messageId ID that uniquely identifies a message from a given originator
  105.      */
  106.     public void setMessageId(final String messageId) {
  107.         this.messageId = messageId;
  108.     }

  109. }