BEA Systems, Inc.

theory.smart.axiom.units
Class UnitConversionImpl

java.lang.Object
  |
  +--theory.smart.foundation.EntityImpl
        |
        +--theory.smart.foundation.ConfigurableEntityImpl
              |
              +--theory.smart.axiom.units.UnitConversionImpl

public class UnitConversionImpl
extends ConfigurableEntityImpl

The Unit Conversion provides the ability to convert from one unit of measurement to any other in the same classification. The category of a unit describes what type quality the unit is measuring (e.g. height, weight, product packaging sizes). For each quantity being converted "to" the count can be used to simplify the implementation of the most common conversions based on a simple ratio. It also provides support the use of individual instance methods so that more complex calculations can be implemented.

 Primary Key = theory.smart.axiom.units.UnitConversionPk
 

See Also:
UnitConversion, UnitConversionHome, UnitConversionValue, Serialized Form

Field Summary
 Unit atomic
           atomic [UnitConversion] <*>------> [theory.smart.axiom.units.Unit]
 java.lang.String category
           category [UnitConversion] <*>------> [String] (Primary Key)
 com.sun.java.util.collections.TreeMap tos
           to (Map) [UnitConversion] <*>------> [theory.smart.axiom.units.Quantity] 0..*
 
Fields inherited from class theory.smart.foundation.EntityImpl
ctx, isDirty, isLoaded
 
Constructor Summary
UnitConversionImpl()
           
 
Method Summary
 boolean containsToKey(java.lang.String key)
          Returns true if the to map contains a to for the specified key.
 boolean containsToValue(Quantity to)
          Returns true if the to map maps one or more keys to the specified to.
 Quantity convert(ConversionFunction policy, Quantity qty, Unit unit)
           
 Quantity convert(Quantity qty, Unit unit)
          Convert the specified quantity to the atomic unit and then into the specified units.
 void ejbActivate()
          ejbActivate method.
 UnitConversionPk ejbCreate(UnitConversionPk unitConversionPk)
           
 java.util.Enumeration ejbFindAll()
           
 UnitConversionPk ejbFindByPrimaryKey(UnitConversionPk pk)
           
 void ejbLoad()
          ejbLoad method.
 void ejbPassivate()
          ejbPassivate method.
 void ejbPostCreate(UnitConversionPk unitConversionPk)
           
 void ejbRemove()
          ejbRemove method.
 void ejbStore()
          ejbStore method.
 Unit getAtomic()
          Get the value of atomic
 java.lang.String getCategory()
           
 ConversionFunction getDefaultConversionPolicy()
           
 int getNumberOfTos()
          Returns the number of key-value mappings in the to map.
 Quantity getToByKey(java.lang.String key)
          Returns the to to which the to map maps the specified key.
 com.sun.java.util.collections.TreeMap getTos()
          Returns a copy all of the tos from the specified map to the to map.
 UnitConversionValue getUnitConversionByValue()
          Get all of UnitConversion's attributes.
 boolean isTosEmpty()
          Returns true if the to map contains no key-value mappings.
 void putTo(java.lang.String key, Quantity to)
          Associates the specified to with the specified key in the to map.
 void putTos(com.sun.java.util.collections.TreeMap tos)
          Copies all of the tos from the specified to map to this to map.
 void removeAllTos()
          Removes all tos from this to map.
 Quantity removeToByKey(java.lang.String key)
          Removes the to for this key from this to map if present.
 void setAtomic(Unit atomic)
          Set the value of atomic
 void setDefaultConversionPolicy(ConversionFunction cvt)
           
 void setEntityContext(javax.ejb.EntityContext ctx)
          setEntityContext method.
 void setUnitConversionByValue(UnitConversionValue value)
          Set all of UnitConversion's attributes to the passed in value.
 void unsetEntityContext()
          unsetEntityContext method.
 
Methods inherited from class theory.smart.foundation.ConfigurableEntityImpl
addBusinessPolicy, addProperty, ejbCreate, ejbPostCreate, getBusinessPolicy, getProperty, removeBusinessPolicy, removeProperty, setSuccessorAtClassLevel, setSuccessorAtInstanceLevel
 
Methods inherited from class theory.smart.foundation.EntityImpl
getEntityContext, isModified
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

category

public java.lang.String category
                  category
 [UnitConversion] <*>------> [String] (Primary Key)

 

atomic

public Unit atomic
                  atomic
 [UnitConversion] <*>------> [theory.smart.axiom.units.Unit] 

 

tos

public com.sun.java.util.collections.TreeMap tos
                  to (Map)
 [UnitConversion] <*>------> [theory.smart.axiom.units.Quantity] 
                     0..*
 
Constructor Detail

UnitConversionImpl

public UnitConversionImpl()
                   throws javax.ejb.CreateException
Method Detail

getUnitConversionByValue

public UnitConversionValue getUnitConversionByValue()
                                             throws java.rmi.RemoteException
Get all of UnitConversion's attributes.
Returns:
UnitConversionValue the UnitConversion value object

setUnitConversionByValue

public void setUnitConversionByValue(UnitConversionValue value)
                              throws java.rmi.RemoteException
Set all of UnitConversion's attributes to the passed in value. Note: Primary key attributes are not set.
Parameters:
UnitConversionValue - the UnitConversion value object

ejbCreate

public UnitConversionPk ejbCreate(UnitConversionPk unitConversionPk)
                           throws javax.ejb.CreateException,
                                  java.rmi.RemoteException

ejbPostCreate

public void ejbPostCreate(UnitConversionPk unitConversionPk)
                   throws javax.ejb.CreateException,
                          java.rmi.RemoteException

ejbLoad

public void ejbLoad()
             throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbLoad method.
Overrides:
ejbLoad in class ConfigurableEntityImpl

ejbStore

public void ejbStore()
              throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbStore method.
Overrides:
ejbStore in class ConfigurableEntityImpl

ejbRemove

public void ejbRemove()
               throws java.rmi.RemoteException,
                      javax.ejb.RemoveException
Description copied from class: EntityImpl
ejbRemove method.
Overrides:
ejbRemove in class ConfigurableEntityImpl

ejbActivate

public void ejbActivate()
                 throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbActivate method.
Overrides:
ejbActivate in class ConfigurableEntityImpl

ejbPassivate

public void ejbPassivate()
                  throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbPassivate method.
Overrides:
ejbPassivate in class ConfigurableEntityImpl

setEntityContext

public void setEntityContext(javax.ejb.EntityContext ctx)
                      throws java.rmi.RemoteException
Description copied from class: EntityImpl
setEntityContext method.
Overrides:
setEntityContext in class EntityImpl

unsetEntityContext

public void unsetEntityContext()
                        throws java.rmi.RemoteException
Description copied from class: EntityImpl
unsetEntityContext method.
Overrides:
unsetEntityContext in class EntityImpl

ejbFindByPrimaryKey

public UnitConversionPk ejbFindByPrimaryKey(UnitConversionPk pk)
                                     throws javax.ejb.FinderException,
                                            java.rmi.RemoteException

ejbFindAll

public java.util.Enumeration ejbFindAll()
                                 throws javax.ejb.FinderException,
                                        java.rmi.RemoteException

getCategory

public java.lang.String getCategory()
                             throws java.rmi.RemoteException

getAtomic

public Unit getAtomic()
               throws java.rmi.RemoteException
Get the value of atomic
Returns:
atomic.

setAtomic

public void setAtomic(Unit atomic)
               throws java.rmi.RemoteException
Set the value of atomic
Parameters:
atomic - atomic to be added

containsToKey

public boolean containsToKey(java.lang.String key)
                      throws java.rmi.RemoteException
Returns true if the to map contains a to for the specified key.
Parameters:
key - key whose presence in the to map is to be tested.
Returns:
true if the to map contains a to for the specified key.
Throws:
ClassCastException - if the key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the to map uses natural ordering, or its comparator does not tolerate null keys.

containsToValue

public boolean containsToValue(Quantity to)
                        throws java.rmi.RemoteException
Returns true if the to map maps one or more keys to the specified to. This operation will probably require linear time.
Parameters:
to - value of to whose presence in the to map is to be tested.

getToByKey

public Quantity getToByKey(java.lang.String key)
                    throws java.rmi.RemoteException
Returns the to to which the to map maps the specified key. Returns null if the map contains no to for this key. A return value of null does not necessarily indicate that the map contains no to for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.
Parameters:
key - key whose associated to is to be returned.
Returns:
the to to which the to map maps the specified key, or null if the map contains no to for the key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the to map uses natural ordering, or its comparator does not tolerate null keys.
See Also:
#containsKey(Object)

getTos

public com.sun.java.util.collections.TreeMap getTos()
                                             throws java.rmi.RemoteException
Returns a copy all of the tos from the specified map to the to map. These tos replace any tos that the to map had for any of the keys currently in the specified map.
Parameters:
tos - a copy of the tos.
Throws:
ClassCastException - class of a key or to in the specified map prevents it from being stored in the to map.
NullPointerException - the to map does not permit null keys and a specified key is null.

getNumberOfTos

public int getNumberOfTos()
                   throws java.rmi.RemoteException
Returns the number of key-value mappings in the to map.
Returns:
the number of key-value mappings in the to map.

isTosEmpty

public boolean isTosEmpty()
                   throws java.rmi.RemoteException
Returns true if the to map contains no key-value mappings.

Returns:
true if the to map contains no key-value mappings.

putTo

public void putTo(java.lang.String key,
                  Quantity to)
           throws java.rmi.RemoteException
Associates the specified to with the specified key in the to map. If the map previously contained a to for this key, the old to is replaced.
Parameters:
key - key with which the specified to is to be associated.
to - to to be associated with the specified key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the to map uses natural order, or its comparator does not tolerate null keys.

putTos

public void putTos(com.sun.java.util.collections.TreeMap tos)
            throws java.rmi.RemoteException
Copies all of the tos from the specified to map to this to map. These tos replace any tos that this to map had for any of the keys currently in the specified map.
Parameters:
to - Tos to be stored in the to map.
Throws:
ClassCastException - class of a key or to in the specified map prevents it from being stored in the to map.
NullPointerException - the to map does not permit null keys and a specified key is null.

removeAllTos

public void removeAllTos()
                  throws java.rmi.RemoteException
Removes all tos from this to map.

removeToByKey

public Quantity removeToByKey(java.lang.String key)
                       throws java.rmi.RemoteException
Removes the to for this key from this to map if present.
Parameters:
key - key with which the specified to is associated.
Returns:
previous to associated with specified key, or null if there was no to for key. A null return can also indicate that the map previously associated null with the specified key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the to map uses natural order, or its comparator does not tolerate null keys.

convert

public Quantity convert(Quantity qty,
                        Unit unit)
                 throws java.rmi.RemoteException,
                        UnitConversionException
Convert the specified quantity to the atomic unit and then into the specified units. This method first check for the existence of individual instance methods

convert

public Quantity convert(ConversionFunction policy,
                        Quantity qty,
                        Unit unit)
                 throws java.rmi.RemoteException,
                        UnitConversionException

setDefaultConversionPolicy

public void setDefaultConversionPolicy(ConversionFunction cvt)
                                throws java.rmi.RemoteException

getDefaultConversionPolicy

public ConversionFunction getDefaultConversionPolicy()
                                              throws java.rmi.RemoteException

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved