Holger's
Java API

com.antelmann.math
Class DefaultUnit

java.lang.Object
  extended by com.antelmann.math.DefaultUnit
All Implemented Interfaces:
Unit, Localizable, Serializable
Direct Known Subclasses:
AreaUnit, BaseUnit, CurrencyUnit

public class DefaultUnit
extends Object
implements Unit

simple base implementation for a unit

Since:
04.06.2009, 15:01:03
Author:
Holger Antelmann
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.antelmann.util.Localizable
Localizable.Adapter
 
Field Summary
protected  String name
           
protected  String symbol
           
 
Constructor Summary
DefaultUnit(String symbol)
           
DefaultUnit(String symbol, String name)
          the symbol must not be null; if the name is null, the symbol is used as the name
 
Method Summary
 boolean equals(Object obj)
          instances are considered equals if the class and the symbol are the same
 Locale getLocale()
          allows access to the Locale that this instance currently uses to localize its messages,
 String getUnitName()
          provides the fully spelled name for this unit
 String getUnitSymbol()
          provides a short symbolic representation of this unit
 int hashCode()
          based on getUnitSymbol()
 void setLocale(Locale locale, Object context)
          sets the Locale for this object so that all subsequent return values of method calls to this instance can be localized accordingly until a different Locale is set.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

symbol

protected final String symbol

name

protected final String name
Constructor Detail

DefaultUnit

public DefaultUnit(String symbol)

DefaultUnit

public DefaultUnit(String symbol,
                   String name)
the symbol must not be null; if the name is null, the symbol is used as the name

Method Detail

getLocale

public Locale getLocale()
Description copied from interface: Localizable
allows access to the Locale that this instance currently uses to localize its messages,

Specified by:
getLocale in interface Localizable
Returns:
the current Locale that this instance uses to determine return values for its methods; if null is returned, this instance is expected to use the default Locale of the system.
See Also:
Localizable.setLocale(Locale, Object)

setLocale

public void setLocale(Locale locale,
                      Object context)
Description copied from interface: Localizable
sets the Locale for this object so that all subsequent return values of method calls to this instance can be localized accordingly until a different Locale is set.

Specified by:
setLocale in interface Localizable
Parameters:
locale - the Locale that is to be used to determine return values for all methods of this instance; if set to null, the default locale is to be used.
context - a context that may be required for this instance to load the resources for the given locale; this context may be null for objects that do not require an external context. Examples of a context may be a database, a resource file, some map or no context at all.
See Also:
Localizable.getLocale()

getUnitSymbol

public String getUnitSymbol()
Description copied from interface: Unit
provides a short symbolic representation of this unit

Specified by:
getUnitSymbol in interface Unit

getUnitName

public String getUnitName()
Description copied from interface: Unit
provides the fully spelled name for this unit

Specified by:
getUnitName in interface Unit

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
based on getUnitSymbol()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
instances are considered equals if the class and the symbol are the same

Overrides:
equals in class Object


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads