View Javadoc
1   package org.djunits.unit.unitsystem;
2   
3   import java.io.Serializable;
4   
5   import org.djunits.locale.UnitLocale;
6   
7   /**
8    * Systems of Units such as SI, including SI-derived; cgs (centimeter-gram-second).
9    * <p>
10   * Copyright (c) 2015-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>
12   * </p>
13   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
14   */
15  public abstract class UnitSystem implements Serializable
16  {
17      /** */
18      private static final long serialVersionUID = 20140606L;
19  
20      /** CGS: centimeter-gram-second system. */
21      public static final CGS CGS;
22  
23      /** CGS_ESU: centimeter-gram-second system, electrostatic units. */
24      public static final CGS_ESU CGS_ESU;
25  
26      /** CGS_EMU: centimeter-gram-second system, electromagnetic units. */
27      public static final CGS_EMU CGS_EMU;
28  
29      /** Imperial system. */
30      public static final Imperial IMPERIAL;
31  
32      /** MTS: meter-tonne-second system. */
33      public static final MTS MTS;
34  
35      /** Other (or no) system. */
36      public static final Other OTHER;
37  
38      /** SI units, accepted for use in addition to SI. */
39      public static final SIAccepted SI_ACCEPTED;
40  
41      /** SI base units: temperature, time, length, mass, luminous intensity, amount of substance and electric current. */
42      public static final SIBase SI_BASE;
43  
44      /** SI derived units, by combining SI-base elements (and quantifiers such as milli or kilo). */
45      public static final SIDerived SI_DERIVED;
46  
47      /** US additions to the Imperial system. */
48      public static final USCustomary US_CUSTOMARY;
49  
50      /** AU: Atomic Unit system. */
51      public static final AU AU;
52  
53      static
54      {
55          CGS = new CGS("UnitSystem.CGS", "UnitSystem.centimeter-gram-second_system");
56          CGS_ESU = new CGS_ESU("UnitSystem.CGS_(ESU)", "UnitSystem.centimeter-gram-second_system,_electrostatic_units");
57          CGS_EMU = new CGS_EMU("UnitSystem.CGS_(EMU)", "UnitSystem.centimeter-gram-second_system,_electromagnetic_units");
58          IMPERIAL = new Imperial("UnitSystem.Imperial", "UnitSystem.Imperial_system");
59          MTS = new MTS("UnitSystem.MTS", "UnitSystem.meter-tonne-second_system");
60          OTHER = new Other("UnitSystem.Other", "UnitSystem.other_system");
61          SI_ACCEPTED = new SIAccepted("UnitSystem.SI_accepted", "UnitSystem.International_System_of_Units_(Accepted_Unit)");
62          SI_BASE = new SIBase("UnitSystem.SI", "UnitSystem.International_System_of_Units_(Base_Unit)");
63          SI_DERIVED = new SIDerived("UnitSystem.SI_derived", "UnitSystem.International_System_of_Units_(Derived_Unit)");
64          US_CUSTOMARY = new USCustomary("UnitSystem.US_customary", "UnitSystem.US_customary_system");
65          AU = new AU("UnitSystem.AU", "UnitSystem.Atomic_Unit_system");
66      }
67  
68      /** The abbreviation of the unit system, such as cgs. */
69      private final String abbreviationKey;
70  
71      /** The name of the unit system, such as centimeter-gram-second. */
72      private final String nameKey;
73  
74      /** Localization information. */
75      private static UnitLocale localization = new UnitLocale("unitsystem");
76  
77      /**
78       * Construct a new UnitSystem.
79       * @param abbreviationKey String; the abbreviation of the unit system, such as cgs
80       * @param nameKey String; the name of the unit system, such as centimeter-gram-second
81       */
82      protected UnitSystem(final String abbreviationKey, final String nameKey)
83      {
84          this.abbreviationKey = abbreviationKey;
85          this.nameKey = nameKey;
86      }
87  
88      /**
89       * Retrieve the name of this UnitSystem.
90       * @return String; the name of this UnitSystem, e.g. centimeter-gram-second
91       */
92      public final String getName()
93      {
94          return localization.getString(this.nameKey);
95      }
96  
97      /**
98       * Retrieve the name key of this UnitSystem.
99       * @return String; the name key of this UnitSystem, e.g. CGS.centimeter-gram-second
100      */
101     public final String getNameKey()
102     {
103         return this.nameKey;
104     }
105 
106     /**
107      * Retrieve the abbreviation of this UnitSystem.
108      * @return String; the abbreviation of this UnitSystem, e.g., CGS.cgs
109      */
110     public final String getAbbreviation()
111     {
112         return localization.getString(this.abbreviationKey);
113     }
114 
115     /**
116      * Retrieve the abbreviation key of this UnitSystem.
117      * @return String; the abbreviation key of this UnitSystem, e.g. cgs
118      */
119     public final String getAbbreviationKey()
120     {
121         return this.abbreviationKey;
122     }
123 
124     /** {@inheritDoc} */
125     @Override
126     public String toString()
127     {
128         return "UnitSystem [abbreviationKey=" + this.abbreviationKey + ", nameKey=" + this.nameKey + "]";
129     }
130 
131 }