com.ds.fw.beans
Class FwBaseBean

java.lang.Object
  |
  +--com.ds.fw.beans.FwBaseBean
Direct Known Subclasses:
FwDBBean

public class FwBaseBean
extends java.lang.Object

The FwBaseBean class is the base (parent) class for all Beans. This class used for transfer information between servlets controler and jsp view part of MVC architecture. FwBaseBean implements the model. Authors: Boyan Bontchev, Slav Danev and Nikolay S.


Field Summary
static boolean DEBUG_QUERY
           
protected  com.ds.fw.types.FwHashVector result
          This FwHashVector holds all information in the bean.
 
Constructor Summary
FwBaseBean()
          The constructor of this bean.
 
Method Summary
 void clear()
          Clears the resultset FwHashVector
 int findIndexOf(java.lang.String key, java.lang.Object elem)
          Returns the index of an element in a column
 java.lang.Object get(long col, long k)
           
 java.lang.Object get(java.lang.String key)
          Gets the object at position 0 (i.e the first Object) in the Vector corresponding to the column Key.
 java.lang.Object get(java.lang.String key, long k)
          Basic get() method.
 java.math.BigDecimal getBigDecimal(java.lang.String key, long k)
          Gets the k'th element in the column Key as an long.
 java.util.Vector getColumn(long col)
           
 java.util.Vector getColumn(java.lang.String key)
          Gets the column (as a Vector) corresponding to Key
 java.util.Vector getColumnNames()
           
 java.util.Date getDate(java.lang.String key, long k)
          Gets the k'th element in the column Key as an Date.
 java.lang.Double getDouble(java.lang.String key, long k)
          Gets the k'th element in the column Key as an double.
 java.lang.Float getFloat(java.lang.String key, long k)
          Gets the k'th element in the column Key as an int.
 int getInt(java.lang.String key, long k)
          Gets the k'th element in the column Key as an int.
 long getLong(java.lang.String key, long k)
          Gets the k'th element in the column Key as an long.
 java.lang.Number getNumber(java.lang.String key, long k)
          Gets the k'th element in the column Key as an long.
 int getNumRows()
          Returns the size of the dataset
 int getNumRows(java.lang.String key)
          Returns the size of the dataset of a column corresponding to Key
 com.ds.fw.types.FwHashVector getResult()
          Returns the resultset FwHashVector
 java.lang.String getString(java.lang.String key, long k)
          Gets the k'th element of the Vector pointed by this key and returns it as a String.
 int lastIndexOf(java.lang.String key, java.lang.Object elem)
          Returns the last index of an element in a column
 void set(long col, java.lang.Object set, long k)
           
 void set(java.lang.String key, java.lang.Object set)
          Sets the first Object in the column Key
 void set(java.lang.String key, java.lang.Object set, long k)
          Basic set method.
 void setBigDecimal(java.lang.String key, java.math.BigDecimal bd, long k)
          Sets i as an BigDecimal object at position k corresponding to Key
 void setColumn(long col, java.util.Vector column)
           
 void setColumn(java.lang.String key, java.util.Vector column)
          Sets the column corresponding to Key to a given vector.
 void setDate(java.lang.String key, java.util.Date date, long k)
          Sets date as an Date object at position k corresponding to Key
 void setDouble(java.lang.String key, double i, long k)
          Sets i as an Double object at position k corresponding to Key
 void setFloat(java.lang.String key, float i, long k)
          Sets i as an Float object at position k corresponding to Key
 void setInt(java.lang.String key, int i, long k)
          Sets i as an Integer object at position k corresponding to Key
 void setLong(java.lang.String key, long i, long k)
          Sets i as an Long object at position k corresponding to Key
 void setNumber(java.lang.String key, java.lang.Number n, long k)
          Sets i as an Number object at position k corresponding to Key
 void setResult(com.ds.fw.types.FwHashVector r)
          Sets the resultset FwHashVector to an appropriate value
 void setString(java.lang.String key, java.lang.String value, long k)
          Sets i as an String object at position k corresponding to Key
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG_QUERY

public static boolean DEBUG_QUERY

result

protected com.ds.fw.types.FwHashVector result
This FwHashVector holds all information in the bean. The keys are the column names. The values are vectors which hold the records of the column pointed to by the corresponding key. The Vectors contain elements of type Object, which can be cast to an appropriate type.

Constructor Detail

FwBaseBean

public FwBaseBean()
The constructor of this bean. Needed to initialize class fields

Method Detail

get

public java.lang.Object get(java.lang.String key,
                            long k)
Basic get() method. Used by other specific get() methods. Returns the object at position k from the Vector of elements of this column indicated by given Key.

Parameters:
key - the column name
k - the position of the Object in the column Vector
Returns:
the Object at position k in the column denoted by key

get

public java.lang.Object get(long col,
                            long k)

set

public void set(java.lang.String key,
                java.lang.Object set,
                long k)
Basic set method. Used by other specific set() methods. Sets the Object set at position k in the column indicated by given Key. The method adds the Object in the Vector in case k is >= column Vector size.

Parameters:
key - the column name
set - the Object to be set in the column's Vector
k - the position where the Object is to be set at.

set

public void set(long col,
                java.lang.Object set,
                long k)

get

public java.lang.Object get(java.lang.String key)
Gets the object at position 0 (i.e the first Object) in the Vector corresponding to the column Key.

Parameters:
key - the column name

set

public void set(java.lang.String key,
                java.lang.Object set)
Sets the first Object in the column Key

Parameters:
key - the column name
set - the Object to be set

getColumn

public java.util.Vector getColumn(java.lang.String key)
Gets the column (as a Vector) corresponding to Key


getColumn

public java.util.Vector getColumn(long col)

setColumn

public void setColumn(java.lang.String key,
                      java.util.Vector column)
Sets the column corresponding to Key to a given vector.

Parameters:
key - the column name
column - the column to insert at key

setColumn

public void setColumn(long col,
                      java.util.Vector column)

getString

public java.lang.String getString(java.lang.String key,
                                  long k)
Gets the k'th element of the Vector pointed by this key and returns it as a String.

Parameters:
key - the column name
k - the position in the Vector

setString

public void setString(java.lang.String key,
                      java.lang.String value,
                      long k)
Sets i as an String object at position k corresponding to Key

Parameters:
key - the column name
k - the integer value

getInt

public int getInt(java.lang.String key,
                  long k)
           throws java.lang.ClassCastException,
                  java.lang.NullPointerException
Gets the k'th element in the column Key as an int. In case the corresponding Object is not of class Integer the method throws ClassCastException.

Parameters:
key - the column name
Throws:
java.lang.ClassCastException - in case the corresponding Object is not of class Integer.
java.lang.NullPointerException - in case the corresponding Object is null.

setInt

public void setInt(java.lang.String key,
                   int i,
                   long k)
Sets i as an Integer object at position k corresponding to Key

Parameters:
key - the column name
i - the integer value
k - the integer value

getFloat

public java.lang.Float getFloat(java.lang.String key,
                                long k)
                         throws java.lang.ClassCastException
Gets the k'th element in the column Key as an int. In case the corresponding Object is not of class Float the method throws ClassCastException.

Parameters:
key - the column name
Throws:
java.lang.ClassCastException - in case the corresponding Object is not of class Float.

setFloat

public void setFloat(java.lang.String key,
                     float i,
                     long k)
Sets i as an Float object at position k corresponding to Key

Parameters:
key - the column name
i - the float value
k - the integer value

getDouble

public java.lang.Double getDouble(java.lang.String key,
                                  long k)
                           throws java.lang.ClassCastException
Gets the k'th element in the column Key as an double. In case the corresponding Object is not of class Double the method throws ClassCastException.

Parameters:
key - the column name
Throws:
java.lang.ClassCastException - in case the corresponding Object is not of class Double.

setDouble

public void setDouble(java.lang.String key,
                      double i,
                      long k)
Sets i as an Double object at position k corresponding to Key

Parameters:
key - the column name
i - the double value
k - the integer value

getDate

public java.util.Date getDate(java.lang.String key,
                              long k)
                       throws java.lang.ClassCastException
Gets the k'th element in the column Key as an Date. In case the corresponding Object is not of class Date the method throws ClassCastException.

Parameters:
key - the column name
Throws:
java.lang.ClassCastException - in case the corresponding Object is not of class Date.

setDate

public void setDate(java.lang.String key,
                    java.util.Date date,
                    long k)
Sets date as an Date object at position k corresponding to Key

Parameters:
key - the column name
date - the Date value
k - the integer value

getLong

public long getLong(java.lang.String key,
                    long k)
             throws java.lang.ClassCastException
Gets the k'th element in the column Key as an long. In case the corresponding Object is not of class Long the method throws ClassCastException.

Parameters:
key - the column name
Throws:
java.lang.ClassCastException - in case the corresponding Object is not of class Long.

setLong

public void setLong(java.lang.String key,
                    long i,
                    long k)
Sets i as an Long object at position k corresponding to Key

Parameters:
key - the column name
i - the long value
k - the integer value

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String key,
                                          long k)
                                   throws java.lang.ClassCastException
Gets the k'th element in the column Key as an long. In case the corresponding Object is not of class BigDecimal the method throws ClassCastException.

Parameters:
key - the column name
Throws:
java.lang.ClassCastException - in case the corresponding Object is not of class BigDecimal.

setBigDecimal

public void setBigDecimal(java.lang.String key,
                          java.math.BigDecimal bd,
                          long k)
Sets i as an BigDecimal object at position k corresponding to Key

Parameters:
key - the column name
bd - the long value
k - the integer value

getNumber

public java.lang.Number getNumber(java.lang.String key,
                                  long k)
                           throws java.lang.ClassCastException
Gets the k'th element in the column Key as an long. In case the corresponding Object is not of class BigDecimal the method throws ClassCastException.

Parameters:
key - the column name
Throws:
java.lang.ClassCastException - in case the corresponding Object is not of class Number.

setNumber

public void setNumber(java.lang.String key,
                      java.lang.Number n,
                      long k)
Sets i as an Number object at position k corresponding to Key

Parameters:
key - the column name
n - the long value
k - the integer value

getNumRows

public int getNumRows(java.lang.String key)
Returns the size of the dataset of a column corresponding to Key

Parameters:
key - the column name

getNumRows

public int getNumRows()
Returns the size of the dataset


size

public int size()

getResult

public com.ds.fw.types.FwHashVector getResult()
Returns the resultset FwHashVector


setResult

public void setResult(com.ds.fw.types.FwHashVector r)
Sets the resultset FwHashVector to an appropriate value

Parameters:
r - the FwHashVector to set

lastIndexOf

public int lastIndexOf(java.lang.String key,
                       java.lang.Object elem)
Returns the last index of an element in a column

Parameters:
key - the column name
elem - the element to search for

findIndexOf

public int findIndexOf(java.lang.String key,
                       java.lang.Object elem)
Returns the index of an element in a column

Parameters:
key - the column name
elem - the element to search for

clear

public void clear()
Clears the resultset FwHashVector


getColumnNames

public java.util.Vector getColumnNames()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object