RinexFileType.java

  1. /* Copyright 2022-2025 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.utils;

  18. import java.util.HashMap;
  19. import java.util.Map;

  20. /** Enumerate for RINEX files types.
  21.  * @since 12.0
  22.  */
  23. public enum RinexFileType {

  24.     /** Rinex Observation. */
  25.     OBSERVATION("O"),

  26.     /** Rinex navigation (G is for Glonass navigation, in Rinex 2.X). */
  27.     NAVIGATION("N", "G");

  28.     /** Parsing map. */
  29.     private static final Map<String, RinexFileType> KEYS_MAP = new HashMap<>();
  30.     static {
  31.         for (final RinexFileType type : values()) {
  32.             for (final String key : type.keys) {
  33.                 KEYS_MAP.put(key, type);
  34.             }
  35.         }
  36.     }

  37.     /** Key of the file type. */
  38.     private final String[] keys;

  39.     /** Simple constructor.
  40.      * @param keys keys of the file type
  41.      */
  42.     RinexFileType(final String... keys) {
  43.         this.keys = keys.clone();
  44.     }

  45.     /** Parse the string to get the type.
  46.      * @param s string to parse (must correspond to a one-character key)
  47.      * @return the type corresponding to the string
  48.      */
  49.     public static RinexFileType parseRinexFileType(final String s) {
  50.         return KEYS_MAP.get(s);
  51.     }

  52. }