Package net.sf.basedb.core.data
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 thegetReferenceFactor()
andgetReferenceOffset()
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:
Unit
, Developer documentation: Annotations- Last modified
- $Date $
- Hibernate: class
- table="`Units`" lazy="true"
-
-
Field Summary
Fields Modifier and Type Field Description private String
description
private String
displaySymbol
static int
MAX_SYMBOL_LENGTH
private String
name
private QuantityData
quantity
private double
referenceFactor
private double
referenceOffset
private Integer
removedBy
private Set<UnitSymbolData>
symbols
private Set<AnnotationTypeData>
usedUnits
-
Fields inherited from interface net.sf.basedb.core.data.NameableData
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
-
-
Constructor Summary
Constructors Constructor Description UnitData()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getDescription()
Get the description for the item.String
getDisplaySymbol()
The symbol to display together with values of this unit.String
getName()
Get the name of the item.QuantityData
getQuantity()
Get the quantity this unit belongs to.double
getReferenceFactor()
Factor that controls how this unit relates to the reference unit of the quantity.double
getReferenceOffset()
An offset that controls how this unit relates to the reference unit of the quantity.Integer
getRemovedBy()
Get the ID of the user that removed this item.Set<UnitSymbolData>
getSymbols()
This is the inverse end.(package private) Set<AnnotationTypeData>
getUsedUnits()
This is the inverse end.void
setDescription(String description)
Set the description for the item.void
setDisplaySymbol(String displaySymbol)
void
setName(String name)
Set the name of the item.void
setQuantity(QuantityData quantity)
void
setReferenceFactor(double referenceFactor)
void
setReferenceOffset(double referenceOffset)
void
setRemovedBy(Integer removedBy)
Set the ID of the user that removed this item or null to restore the item.(package private) void
setSymbols(Set<UnitSymbolData> symbols)
(package private) void
setUsedUnits(Set<AnnotationTypeData> usedUnits)
-
Methods inherited from class net.sf.basedb.core.data.BasicData
equals, getId, getVersion, hashCode, setId, setVersion, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.basedb.core.data.IdentifiableData
getId, getVersion
-
-
-
-
Field Detail
-
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:
- Constant Field Values
-
displaySymbol
private String displaySymbol
-
referenceFactor
private double referenceFactor
-
referenceOffset
private double referenceOffset
-
symbols
private Set<UnitSymbolData> symbols
-
usedUnits
private Set<AnnotationTypeData> usedUnits
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:NameableData
Get the name of the item.- Specified by:
getName
in interfaceNameableData
- 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 theMAX_NAME_LENGTH
constant.- Specified by:
setName
in interfaceNameableData
- 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 interfaceNameableData
- 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 theMAX_DESCRIPTION_LENGTH
constant.- Specified by:
setDescription
in interfaceNameableData
- 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 interfaceRemovableData
- 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 interfaceRemovableData
-
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:
getReferenceOffset()
- 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:
getReferenceFactor()
- 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:
UnitSymbolData.getUnit()
- 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:
AnnotationTypeData.getUsableUnits()
- 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)
-
-