Class UnitData

java.lang.Object
net.sf.basedb.core.data.BasicData
net.sf.basedb.core.data.UnitData
All Implemented Interfaces:
IdentifiableData, NameableData, RemovableData

public class UnitData extends BasicData implements NameableData, RemovableData
This class holds information units. It is important to get the getReferenceFactor() and getReferenceOffset() correct. This is the formula to use:
1 reference unit * factor + offset = 1 of this unit
Examples:
1 meter * 0.001 + 0 = 1 millimeter
1 kelvin * 1 + 273.15 = 1 °Celsius
Version:
2.9
Author:
Nicklas
See Also:
Last modified
$Date $
Hibernate: class
table="`Units`" lazy="true"
  • Field Details

    • name

      private String name
    • description

      private String description
    • removedBy

      private Integer removedBy
    • quantity

      private QuantityData quantity
    • MAX_SYMBOL_LENGTH

      public static final int MAX_SYMBOL_LENGTH
      See Also:
    • displaySymbol

      private String displaySymbol
    • referenceFactor

      private double referenceFactor
    • referenceOffset

      private double referenceOffset
    • symbols

      private Set<UnitSymbolData> symbols
    • usedUnits

      private Set<AnnotationTypeData> usedUnits
  • Constructor Details

    • UnitData

      public UnitData()
  • Method Details

    • getName

      public String getName()
      Description copied from interface: NameableData
      Get the name of the item.
      Specified by:
      getName in interface NameableData
      Returns:
      A String with the name of the item
    • setName

      public void setName(String name)
      Description copied from interface: NameableData
      Set the name of the item. The name cannot be null and mustn't be longer than the value specified by the MAX_NAME_LENGTH constant.
      Specified by:
      setName in interface NameableData
      Parameters:
      name - The new name for the item
    • getDescription

      public String getDescription()
      Description copied from interface: NameableData
      Get the description for the item.
      Specified by:
      getDescription in interface NameableData
      Returns:
      A String with a description of the item
    • setDescription

      public void setDescription(String description)
      Description copied from interface: NameableData
      Set the description for the item. The description can be null but mustn't be longer than the value specified by the MAX_DESCRIPTION_LENGTH constant.
      Specified by:
      setDescription in interface NameableData
      Parameters:
      description - The new description for the item
    • getRemovedBy

      public Integer getRemovedBy()
      Description copied from interface: RemovableData
      Get the ID of the user that removed this item.
      Specified by:
      getRemovedBy in interface RemovableData
      Returns:
      The ID of a user or null if the item is not removed
    • setRemovedBy

      public void setRemovedBy(Integer removedBy)
      Description copied from interface: RemovableData
      Set the ID of the user that removed this item or null to restore the item.
      Specified by:
      setRemovedBy in interface RemovableData
    • getQuantity

      public QuantityData getQuantity()
      Get the quantity this unit belongs to. Can't be changed after creation.
      Hibernate: many-to-one
      column="`quantity_id`" not-null="true" outer-join="false" update="false"
    • setQuantity

      public void setQuantity(QuantityData quantity)
    • getDisplaySymbol

      public String getDisplaySymbol()
      The symbol to display together with values of this unit.
      Hibernate: property
      column="`display_symbol`" type="string" length="255" not-null="true"
    • setDisplaySymbol

      public void setDisplaySymbol(String displaySymbol)
    • getReferenceFactor

      public double getReferenceFactor()
      Factor that controls how this unit relates to the reference unit of the quantity. The factor tells us how many of the reference unit is needed to get this unit. For example, if the reference unit is 'kilogram' and this unit is 'gram', the factor is 0.001.
      See Also:
      Hibernate: property
      column="`reference_factor`" type="double" not-null="true"
    • setReferenceFactor

      public void setReferenceFactor(double referenceFactor)
    • getReferenceOffset

      public double getReferenceOffset()
      An offset that controls how this unit relates to the reference unit of the quantity. The offset tells us how to translate a between units. For example, if the reference unit is 'Kelvin' and this unit is 'Celsius', the offset is 273.15.
      See Also:
      Hibernate: property
      column="`reference_offset`" type="double" not-null="true"
    • setReferenceOffset

      public void setReferenceOffset(double referenceOffset)
    • getSymbols

      public Set<UnitSymbolData> getSymbols()
      This is the inverse end.
      See Also:
      Hibernate: set
      lazy="true" inverse="true" cascade="all-delete-orphan"
      Hibernate: collection-key
      column="`unit_id`"
      Hibernate: collection-one-to-many
      class="net.sf.basedb.core.data.UnitSymbolData"
    • setSymbols

      void setSymbols(Set<UnitSymbolData> symbols)
    • getUsedUnits

      Set<AnnotationTypeData> getUsedUnits()
      This is the inverse end. It has lazy="false" because we need automatic deletion from the AnnotationTypeUnits table
      See Also:
      Hibernate: set
      table="`AnnotationTypeUnits`" lazy="true"
      Hibernate: collection-key
      column="`unit_id`"
      Hibernate: collection-many-to-many
      column="`annotationtype_id`" class="net.sf.basedb.core.data.AnnotationTypeData"
    • setUsedUnits

      void setUsedUnits(Set<AnnotationTypeData> usedUnits)