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-2018 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: 2018-01-28 03:17:44 +0100 (Sun, 28 Jan 2018) $, @version $Revision: 256 $, by $Author: averbraeck $,
14   * initial 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 = new CGS_EMU("UnitSystem.CGS_(EMU)", "UnitSystem.centimeter-gram-second_system,_electromagnetic_units");
60          IMPERIAL = new Imperial("UnitSystem.Imperial", "UnitSystem.Imperial_system");
61          MTS = new MTS("UnitSystem.MTS", "UnitSystem.meter-tonne-second_system");
62          OTHER = new Other("UnitSystem.Other", "UnitSystem.other_system");
63          SI_ACCEPTED = new SIAccepted("UnitSystem.SI_accepted", "UnitSystem.International_System_of_Units_(Accepted_Unit)");
64          SI_BASE = new SIBase("UnitSystem.SI", "UnitSystem.International_System_of_Units_(Base_Unit)");
65          SI_DERIVED = new SIDerived("UnitSystem.SI_derived", "UnitSystem.International_System_of_Units_(Derived_Unit)");
66          US_CUSTOMARY = new USCustomary("UnitSystem.US_customary", "UnitSystem.US_customary_system");
67          AU = new AU("UnitSystem.AU", "UnitSystem.Atomic_Unit_system");
68      }
69  
70      /** the abbreviation of the unit system, such as cgs. */
71      private final String abbreviationKey;
72  
73      /** the name of the unit system, such as centimeter-gram-second. */
74      private final String nameKey;
75  
76      /** localization information. */
77      private static Localization localization = new Localization("localeunitsystem");
78  
79      /**
80       * @param abbreviationKey the abbreviation of the unit system, such as cgs
81       * @param nameKey the name of the unit system, such as centimeter-gram-second
82       */
83      protected UnitSystem(final String abbreviationKey, final String nameKey)
84      {
85          this.abbreviationKey = abbreviationKey;
86          this.nameKey = nameKey;
87      }
88  
89      /**
90       * @return name, e.g. centimeter-gram-second
91       */
92      public final String getName()
93      {
94          return localization.getString(this.nameKey);
95      }
96  
97      /**
98       * @return name key, e.g. CGS.centimeter-gram-second
99       */
100     public final String getNameKey()
101     {
102         return this.nameKey;
103     }
104 
105     /**
106      * @return abbreviation, e.g., CGS.cgs
107      */
108     public final String getAbbreviation()
109     {
110         return localization.getString(this.abbreviationKey);
111     }
112 
113     /**
114      * @return abbreviation key, e.g. cgs
115      */
116     public final String getAbbreviationKey()
117     {
118         return this.abbreviationKey;
119     }
120 
121 }