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