1   /* Copyright 2002-2024 Luc Maisonobe
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.rinex.navigation;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.orekit.errors.OrekitIllegalArgumentException;
23  import org.orekit.errors.OrekitMessages;
24  
25  /** Enumerate for the UTC ids.
26   *
27   * @author Luc Maisonobe
28   * @since 12.0
29   */
30  public enum UtcId {
31  
32      /** UTC(USNO). */
33      USNO("UTC(USNO)"),
34  
35      /** UTC(SU). */
36      SU("UTC(SU)"),
37  
38      /** UTCGAL. */
39      GAL("UTCGAL"),
40  
41      /** UTC(NTSC). */
42      NTSC("UTC(NTSC)"),
43  
44      /** UTC(NICT). */
45      NICT("UTC(NICT)"),
46  
47      /** UTCIRN / UTC(NPLI). */
48      IRN("UTCIRN", "UTC(NPLI)"),
49  
50      /** UTC(OP). */
51      OP("UTC(OP)"),
52  
53      /** UTC(NIST).
54       * <p>
55       * In Rinex 4.00, this entry is not present in table 23, but appears in table A30.
56       * </p>
57       */
58      NIST("UTC(NIST)");
59  
60      /** Parsing map. */
61      private static final Map<String, UtcId> MAP = new HashMap<>();
62  
63      static {
64          for (final UtcId utc : values()) {
65              for (final String id : utc.ids) {
66                  MAP.put(id, utc);
67              }
68          }
69      }
70  
71      /** Valid ids. */
72      private final String[] ids;
73  
74      /** Simple constructor.
75       * @param ids valid ids
76       */
77      UtcId(final String... ids) {
78          this.ids = ids.clone();
79      }
80  
81      /** Parse a string to get the UTC id.
82       * @param id string to parse
83       * @return the UTC id
84       * @exception OrekitIllegalArgumentException if the string does not correspond to a UTC id
85       */
86      public static UtcId parseUtcId(final String id)
87          throws OrekitIllegalArgumentException {
88          final UtcId utcId = MAP.get(id);
89          if (utcId == null) {
90              throw new OrekitIllegalArgumentException(OrekitMessages.UNKNOWN_UTC_ID, id);
91          }
92          return utcId;
93      }
94  
95  }