1 /* Copyright 2002-2026 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
19 import java.util.Optional;
20
21 import org.orekit.annotation.Nullable;
22 import org.orekit.time.AbsoluteDate;
23
24 /**
25 * Header of a CCSDS Navigation Data Message.
26 * @author Bryan Cazabonne
27 * @since 10.2
28 */
29 public class Header extends CommentsContainer {
30
31 /** CCSDS Format version. */
32 private double formatVersion;
33
34 /** Classification. */
35 @Nullable
36 private String classification;
37
38 /** Message creation date and time in UTC. */
39 private AbsoluteDate creationDate;
40
41 /** Creating agency or operator. */
42 private String originator;
43
44 /** ID that uniquely identifies a message from a given originator. */
45 @Nullable
46 private String messageId;
47
48 /** Minimum version for {@link HeaderKey#MESSAGE_ID}. */
49 private final double minVersionMessageId;
50
51 /** Minimum version for {@link HeaderKey#CLASSIFICATION}. */
52 private final double minVersionClassification;
53
54 /**
55 * Constructor.
56 * @param minVersionMessageId minimum version for {@link HeaderKey#MESSAGE_ID}
57 * @param minVersionClassification minimum version for {@link HeaderKey#CLASSIFICATION}
58 */
59 public Header(final double minVersionMessageId,
60 final double minVersionClassification) {
61 this.formatVersion = Double.NaN;
62 this.minVersionMessageId = minVersionMessageId;
63 this.minVersionClassification = minVersionClassification;
64 }
65
66 /** {@inheritDoc} */
67 @Override
68 public void validate(final double version) {
69 super.validate(version);
70 checkNotNull(creationDate, HeaderKey.CREATION_DATE.name());
71 checkNotNull(originator, HeaderKey.ORIGINATOR.name());
72 checkAllowed(version, messageId, HeaderKey.MESSAGE_ID.name(),
73 minVersionMessageId, Double.POSITIVE_INFINITY);
74 checkAllowed(version, classification, HeaderKey.CLASSIFICATION.name(),
75 minVersionClassification, Double.POSITIVE_INFINITY);
76 }
77
78 /**
79 * Get the CCSDS NDM (ADM, ODM or TDM) format version.
80 * @return format version
81 */
82 public double getFormatVersion() {
83 return formatVersion;
84 }
85
86 /**
87 * Set the CCSDS NDM (ADM, ODM or TDM) format version.
88 * @param formatVersion the format version to be set
89 */
90 public void setFormatVersion(final double formatVersion) {
91 this.formatVersion = formatVersion;
92 }
93
94 /**
95 * Get the classification/caveats.
96 * @return classification/caveats.
97 */
98 public Optional<String> getClassification() {
99 return Optional.ofNullable(classification);
100 }
101
102 /**
103 * Set the classification/caveats.
104 * @param classification classification/caveats to be set
105 */
106 public void setClassification(final String classification) {
107 refuseFurtherComments();
108 this.classification = classification;
109 }
110
111 /**
112 * Get the message creation date and time in UTC.
113 * @return the message creation date and time in UTC.
114 */
115 public AbsoluteDate getCreationDate() {
116 return creationDate;
117 }
118
119 /**
120 * Set the message creation date and time in UTC.
121 * @param creationDate the creation date to be set
122 */
123 public void setCreationDate(final AbsoluteDate creationDate) {
124 refuseFurtherComments();
125 this.creationDate = creationDate;
126 }
127
128 /**
129 * Get the message originator.
130 * @return originator the message originator.
131 */
132 public String getOriginator() {
133 return originator;
134 }
135
136 /**
137 * Set the message originator.
138 * @param originator the originator to be set
139 */
140 public void setOriginator(final String originator) {
141 refuseFurtherComments();
142 this.originator = originator;
143 }
144
145 /**
146 * Get the ID that uniquely identifies a message from a given originator.
147 * @return ID that uniquely identifies a message from a given originator
148 */
149 public Optional<String> getMessageId() {
150 return Optional.ofNullable(messageId);
151 }
152
153 /**
154 * Set the ID that uniquely identifies a message from a given originator.
155 * @param messageId ID that uniquely identifies a message from a given originator
156 */
157 public void setMessageId(final String messageId) {
158 this.messageId = messageId;
159 }
160
161 }