Class RegionService

All Implemented Interfaces:
CtxEventListener, ContextHandleAware, HandleAware, Ready, ReadyListener

public final class RegionService extends AbstractService
Provides access to region information.
Since:
1.0
Version:
2023-03-06
  • 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
    • 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.
    • 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.
    • getRegions

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

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

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

      public void setActiveRegion(String regionId)
      Set the currently active region.
      Parameters:
      regionId - id of the region to make active
    • 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 using 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
    • 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
    • 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
    • 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
    • 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
    • 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