KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > util > units > UnitSystemSI


1 /*
2  * UnitSystemSI.java, unit system for the "International System of Units" (abbr. SI).
3  * Copyright (C) Achim Westermann, created on 12.05.2005, 20:11:17
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * If you modify or optimize the code in a useful way please let me know.
20  * Achim.Westermann@gmx.de
21  *
22  */

23 package info.monitorenter.util.units;
24
25 /**
26  * The unit system for the "International System of Units" (SI).
27  * <p>
28  *
29  * @see info.monitorenter.util.units.AUnit
30  *
31  * @see info.monitorenter.util.units.UnitFactory
32  *
33  * @see info.monitorenter.util.units.IUnitSystem
34  *
35  * @author <a HREF='mailto:Achim.Westermann@gmx.de'>Achim Westermann </a>
36  *
37  * @version $Revision: 1.1 $
38  */

39 public final class UnitSystemSI implements IUnitSystem {
40
41   /** Singleton instance. */
42   private static IUnitSystem instance;
43
44   /** The unit classes of this system. */
45   private static final Class JavaDoc[] UNITS = new Class JavaDoc[] {UnitFemto.class, UnitNano.class,
46       UnitMicro.class, UnitMilli.class, UnitUnchanged.class, UnitKilo.class, UnitMega.class,
47       UnitGiga.class, UnitTera.class, UnitPeta.class };
48
49   /**
50    * Singleton retrieval method.
51    * <p>
52    *
53    * @return the unique instance within the current VM.
54    */

55   public static IUnitSystem getInstance() {
56     if (UnitSystemSI.instance == null) {
57       UnitSystemSI.instance = new UnitSystemSI();
58     }
59     return UnitSystemSI.instance;
60   }
61
62   /**
63    * Singleton constructor.
64    * <p>
65    *
66    */

67   private UnitSystemSI() {
68   }
69
70   /**
71    * @see info.monitorenter.util.units.IUnitSystem#getUnits()
72    */

73   public Class JavaDoc[] getUnits() {
74     return UnitSystemSI.UNITS;
75   }
76 }
77
Popular Tags