All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ucar.units.UnitSystemManager Maven / Gradle / Ivy

Go to download

The ucar.units Java package is for decoding and encoding formatted unit specifications (e.g. "m/s"), converting numeric values between compatible units (e.g. between "m/s" and "knot"), and for performing arithmetic operations on units (e.g. dividing one unit by another, or raising a unit to a power).

The newest version!
/*
 * Copyright (c) 1998-2018 University Corporation for Atmospheric Research/Unidata
 * See LICENSE for license information.
 */
package ucar.units;

import java.io.Serializable;

/**
 * Provides support for managing a UnitSystem.
 * 
 * @author Steven R. Emmerson
 */
public final class UnitSystemManager implements Serializable {
	private static final long	serialVersionUID	= 1L;

	/**
	 * The singleton instance of the system of units.
	 * 
	 * @serial
	 */
	private static UnitSystem	instance;

	/**
	 * Returns an instance of the system of units.
	 * 
	 * @return An instance of the system of units.
	 */
	public static synchronized UnitSystem instance() throws UnitSystemException {
			if (instance == null) {
				instance = SI.instance();
		}
		return instance;
	}

	/**
	 * Sets the system of units. This must be called before any call to
	 * instance().
	 * 
	 * @param instance
	 *            The system of units.
	 * @throws UnitSystemException
	 *             instance() was called earlier.
	 */
	public static synchronized void setInstance(final UnitSystem instance)
			throws UnitSystemException {
		if (instance != null) {
			throw new UnitSystemException("Unit system already used");
		}
		UnitSystemManager.instance = instance;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy