Class RegionService

java.lang.Object
com.kosdev.kos.commons.core.service.region.RegionService

public final class RegionService extends Object
Provides access to region information.

Package changed in api version 9.

Since:
1
Version:
9
  • Field Details

  • Method Details

    • addUnitSystem

      public void addUnitSystem(UnitSystem unitSystem)
      Adds a unit system to the service. If the ID of the system is the same as an existing system, the existing system is replaced. These unit systems are exposed to external systems for unit conversion from standard KOS units (SI) to display units. Java code can create UnitSystem instances for internal type conversion, as needed, as this is independent of display units.
      Parameters:
      unitSystem - the unit system to add
      Since:
      1
    • addTimeFormat

      public void addTimeFormat(TimeFormat timeFormat)
      Adds a time format to the service. If the ID of the format is the same as an existing format, the existing format is replaced.
      Since:
      1
    • addDateFormat

      public void addDateFormat(DateFormat dateFormat)
      Adds a date format to the service. If the ID of the format is the same as an existing format, the existing format is replaced.
      Since:
      1
    • regionsInstalled

      public boolean regionsInstalled()
      Return true if regions have been installed.
      Since:
      1
    • getRegions

      public Collection<BaseRegion> getRegions()
      Returns the list of known regions.
      Since:
      1
    • getActiveRegion

      public BaseRegion getActiveRegion()
      Return the currently active region.
      Since:
      1
    • setActiveRegion

      public void setActiveRegion(BaseRegion region)
      Set the currently active region.
      Parameters:
      region - the region to make active
      Since:
      1
    • setActiveRegion

      public void setActiveRegion(String regionId)
      Set the currently active region.
      Parameters:
      regionId - id of the region to make active
      Since:
      1
    • getFactoryRegion

      public BaseRegion getFactoryRegion()
      Returns the built-in "factory" region. This is a special region with an ID of BaseRegion.FACTORY_ID . This region is typically non-functional for normal operations, but is the default region used during factory installation.

      This simply calls getRegions() and returns the first region that returns true for isFactory() , which by default is true when the ID of the region is Region.FACTORY_ID . If no factory region is found, then an exception is thrown.

      Throws:
      IllegalStateException - if no factory region found
      Since:
      1
    • getUnit

      public Unit getUnit(String measure, String name)
      Return the Unit for the specified name / alias that is related to the specified measurement.
      Parameters:
      measure - the type of measure to search for (null for any)
      name - the unit name / alias
      Returns:
      matching unit or null
      Since:
      1
    • getTemperatureUnit

      public Unit getTemperatureUnit(String name)
      Return the Unit for the specified name / alias that measures temperature.
      Parameters:
      name - the unit name / alias
      Returns:
      matching unit or null
      Since:
      1
    • getVolumeUnit

      public Unit getVolumeUnit(String name)
      Return the Unit for the specified name / alias that measures volume.
      Parameters:
      name - the unit name / alias
      Returns:
      matching unit or null
      Since:
      1
    • getMassUnit

      public Unit getMassUnit(String name)
      Return the Unit for the specified name / alias that measures mass.
      Parameters:
      name - the unit name / alias
      Returns:
      matching unit or null
      Since:
      1
    • getPressureUnit

      public Unit getPressureUnit(String name)
      Return the Unit for the specified name / alias that measures pressure.
      Parameters:
      name - the unit name / alias
      Returns:
      matching unit or null
      Since:
      1