2.17.2: 2011-06-17

net.sf.basedb.core.data
Class UnitData

java.lang.Object
  extended by net.sf.basedb.core.data.BasicData
      extended by 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:
Unit
Last modified
$Date $
Hibernate: class
table="`Units`" lazy="true"

Field Summary
private  String description
           
private  String displaySymbol
           
static int MAX_SYMBOL_LENGTH
           
private  String name
           
private  QuantityData quantity
           
private  double referenceFactor
           
private  double referenceOffset
           
private  boolean removed
           
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
UnitData()
           
 
Method Summary
 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.
 Set<UnitSymbolData> getSymbols()
          This is the inverse end.
(package private)  Set<AnnotationTypeData> getUsedUnits()
          This is the inverse end.
 boolean isRemoved()
          Check if the removed flag is set for this item.
 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 setRemoved(boolean removed)
          Set the removed flag for this 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

removed

private boolean removed

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
Constructor Detail

UnitData

public UnitData()
Method Detail

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

isRemoved

public boolean isRemoved()
Description copied from interface: RemovableData
Check if the removed flag is set for this item.

Specified by:
isRemoved in interface RemovableData
Returns:
TRUE if the item is flagged as removed, FALSE otherwise

setRemoved

public void setRemoved(boolean removed)
Description copied from interface: RemovableData
Set the removed flag for this item.

Specified by:
setRemoved in interface RemovableData
Parameters:
removed - TRUE if the item should be flagged as removed, FALSE otherwise

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)

2.17.2: 2011-06-17