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