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.utils.units;
18  
19  import org.hipparchus.fraction.Fraction;
20  
21  /** Unit token.
22   * @author Luc Maisonobe
23   * @since 11.0
24   */
25  class Token {
26  
27      /** String value. */
28      private final CharSequence subString;
29  
30      /** Token type. */
31      private final TokenType type;
32  
33      /** Integer value. */
34      private final int integer;
35  
36      /** Fraction value. */
37      private final Fraction fraction;
38  
39      /** Build a token.
40       * @param subString substring corresponding to the token
41       * @param type token type
42       * @param integer integer value
43       * @param fraction fraction value
44       */
45      Token(final CharSequence subString, final TokenType type, final int integer, final Fraction fraction) {
46          this.subString = subString;
47          this.type      = type;
48          this.integer   = integer;
49          this.fraction  = fraction;
50      }
51  
52      /** Get the substring corresponding to the token.
53       * @return substring corresponding to the token
54       */
55      public CharSequence getSubString() {
56          return subString;
57      }
58  
59      /** Get the token type.
60       * @return token type
61       */
62      public TokenType getType() {
63          return type;
64      }
65  
66      /** Get the integer value (numerator in case of fraction).
67       * @return integer value
68       */
69      public int getInt() {
70          return integer;
71      }
72  
73      /** Get the fraction value.
74       * @return fraction value
75       */
76      public Fraction getFraction() {
77          return fraction;
78      }
79  
80  }