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
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 unitExamples:
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 Summary
Modifier and TypeFieldDescriptionprivate String
private String
static final int
private String
private QuantityData
private double
private double
private Integer
private Set<UnitSymbolData>
private Set<AnnotationTypeData>
Fields inherited from interface net.sf.basedb.core.data.NameableData
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the description for the item.The symbol to display together with values of this unit.getName()
Get the name of the item.Get the quantity this unit belongs to.double
Factor that controls how this unit relates to the reference unit of the quantity.double
An offset that controls how this unit relates to the reference unit of the quantity.Get the ID of the user that removed this item.This is the inverse end.(package private) Set<AnnotationTypeData>
This is the inverse end.void
setDescription
(String description) Set the description for the item.void
setDisplaySymbol
(String displaySymbol) void
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 Details
-
name
-
description
-
removedBy
-
quantity
-
MAX_SYMBOL_LENGTH
public static final int MAX_SYMBOL_LENGTH- See Also:
-
displaySymbol
-
referenceFactor
private double referenceFactor -
referenceOffset
private double referenceOffset -
symbols
-
usedUnits
-
-
Constructor Details
-
UnitData
public UnitData()
-
-
Method Details
-
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
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
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
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
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
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
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
-
getDisplaySymbol
The symbol to display together with values of this unit.- Hibernate: property
- column="`display_symbol`" type="string" length="255" not-null="true"
-
setDisplaySymbol
-
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
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
-
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
-