com.zentense.step2.view
Class VectorRowView

java.lang.Object
  extended by com.zentense.step2.view.View
      extended by com.zentense.step2.view.RowView
          extended by com.zentense.step2.view.VectorRowView

public class VectorRowView
extends RowView

This class implements a Vector of rows. Each row is a Hashtable.

Author:
kurt

Nested Class Summary
protected  class VectorRowView.ComparableComparer
          Performs comparisons over a vector of rows (used for sorting them)
 
Nested classes/interfaces inherited from class com.zentense.step2.view.View
View.Empty
 
Field Summary
protected  int ptr
          Number of row being read.
protected  java.util.Vector res
          Vector that holds all rows
 
Fields inherited from class com.zentense.step2.view.RowView
row
 
Fields inherited from class com.zentense.step2.view.View
EMPTY
 
Constructor Summary
VectorRowView()
          Creates an view with no rows
VectorRowView(java.util.Vector v)
          Constructor from a vector
VectorRowView(VectorRowView vrv)
          Constructor from another vector row view
 
Method Summary
 void add(View v)
          Appends the content of the given view at the end of this view.
 void addRow(java.util.Hashtable row)
          Appends a row to this view
 void addRow(java.lang.String[] cols, java.lang.Object[] values)
          Appends a row to this view.
 java.lang.Object get(int idx, java.lang.String colName)
          Gets a value
static java.lang.Object get(java.util.Vector v, int idx, java.lang.String colName)
          Gets a value from a vector of rows
 int getCount()
          Gets results total size
 double getDouble(int idx, java.lang.String colName)
          Gets value as a double
static double getDouble(java.util.Vector v, int idx, java.lang.String colName)
          Gets double value from a vector of rows
 int getInt(int idx, java.lang.String colName)
          Gets a value as integer
static int getInt(java.util.Vector v, int idx, java.lang.String colName)
          Gets integer value from a vector of rows
 int getOrdinal()
          Gets the current position of this view.
 java.util.Vector getResults()
          Gets results
 java.util.Hashtable getRowAt(int idx)
          Gets a row
 int getSize()
          Gets results size
 int getStart()
          Returns the first visible row in this view.
 void insertRowAt(java.util.Hashtable row, int pos)
          Inserts a row
 boolean next()
          Advances the view to the next row.
 void open()
          Position the view before the first visible row
 VectorRowView order(java.lang.String colname)
          Sorts the view
 void put(int idx, java.lang.String colName, java.lang.Object obj)
          Puts a value
 void removeRow(int idx)
          Removes a row
 VectorRowView reverse()
          Reverses the results
 void setPageBounds(int begin, int step)
          Sets page bounds.
 void setPosition(int pos)
          Moves to another row in view
 void setResults(java.util.Vector res)
          Sets results
 void setResults(VectorRowView vrv)
          Sets results
 java.lang.String toString()
          Gives a string representation of this object
 java.util.Vector toVectorRow()
           
 
Methods inherited from class com.zentense.step2.view.RowView
get, getCols, getRow, isEmpty, set, setRow, setRow, setRowOp
 
Methods inherited from class com.zentense.step2.view.View
asDelegated, asDelegatedResultSet, asResultSet, fillFromRow, fillRowFromRequest, first, getBool, getCachedClone, getColsAsView, getDouble, getIndent, getInt, getRow, getSum, insertRow, randomPosition, setPageBounds, setPageBounds, setPageBounds, updateRow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ptr

protected int ptr
Number of row being read. This is used by getOrdinal


res

protected java.util.Vector res
Vector that holds all rows

Constructor Detail

VectorRowView

public VectorRowView()
Creates an view with no rows


VectorRowView

public VectorRowView(VectorRowView vrv)
Constructor from another vector row view

Parameters:
vrv - A vector row view

VectorRowView

public VectorRowView(java.util.Vector v)
Constructor from a vector

Parameters:
v - A vector of rows
Method Detail

setResults

public void setResults(java.util.Vector res)
Sets results

Parameters:
res - A vector of rows

setResults

public void setResults(VectorRowView vrv)
Sets results

Parameters:
vrv - A vector row view

getResults

public final java.util.Vector getResults()
Gets results

Returns:
A vector of rows

getStart

public int getStart()
Description copied from class: View
Returns the first visible row in this view.

Overrides:
getStart in class View
See Also:
View#setPageBounds(Integer, Integer)

getSize

public final int getSize()
Gets results size

Overrides:
getSize in class RowView
Returns:
Number of rows

getCount

public int getCount()
Description copied from class: View
Gets results total size

Overrides:
getCount in class View
Returns:
Number of results in view (even outside page).

getOrdinal

public final int getOrdinal()
Description copied from class: View
Gets the current position of this view. First is 0

Overrides:
getOrdinal in class View

setPosition

public final void setPosition(int pos)
Description copied from class: View
Moves to another row in view

Overrides:
setPosition in class View

open

public final void open()
                throws java.lang.Exception
Description copied from class: View
Position the view before the first visible row

Overrides:
open in class View
Throws:
java.lang.Exception

next

public final boolean next()
                   throws java.lang.Exception
Description copied from class: View
Advances the view to the next row. Returns true while more rows are available

Overrides:
next in class View
Throws:
java.lang.Exception

setPageBounds

public final void setPageBounds(int begin,
                                int step)
                         throws java.sql.SQLException
Description copied from class: View
Sets page bounds. The page begins at row 'begin' and has a size of 'step' rows. After this method is called only the rows inside the page will be shown. Not all the views support this method.

Overrides:
setPageBounds in class View
Parameters:
begin - First row in page
step - Number of rows in page
Throws:
java.sql.SQLException

put

public void put(int idx,
                java.lang.String colName,
                java.lang.Object obj)
Puts a value

Parameters:
idx - Row index
colName - Column name
obj - New value

get

public final java.lang.Object get(int idx,
                                  java.lang.String colName)
Gets a value

Parameters:
idx - Row index
colName - Column name
Returns:
Value

getInt

public final int getInt(int idx,
                        java.lang.String colName)
Gets a value as integer

Parameters:
idx - Row index
colName - Column name
Returns:
Value as integer

getDouble

public final double getDouble(int idx,
                              java.lang.String colName)
Gets value as a double

Parameters:
idx - Row index
colName - Column name
Returns:
Value as a double

get

public static final java.lang.Object get(java.util.Vector v,
                                         int idx,
                                         java.lang.String colName)
Gets a value from a vector of rows

Parameters:
v - Vector of rows
idx - Row index
colName - Column name
Returns:
Value

getInt

public static final int getInt(java.util.Vector v,
                               int idx,
                               java.lang.String colName)
Gets integer value from a vector of rows

Parameters:
v - Vector of rows
idx - Row index
colName - Column name
Returns:
Integer value

getDouble

public static final double getDouble(java.util.Vector v,
                                     int idx,
                                     java.lang.String colName)
Gets double value from a vector of rows

Parameters:
v - Vector of rows
idx - Row index
colName - Column name
Returns:
Value

reverse

public final VectorRowView reverse()
Reverses the results

Returns:
this VectorRowView

order

public final VectorRowView order(java.lang.String colname)
Sorts the view

Parameters:
colname - Column name used for sorting
Returns:
This vector row view

toString

public java.lang.String toString()
Gives a string representation of this object

Overrides:
toString in class RowView
Returns:
A string

toVectorRow

public java.util.Vector toVectorRow()
                             throws java.lang.Exception
Throws:
java.lang.Exception

insertRowAt

public final void insertRowAt(java.util.Hashtable row,
                              int pos)
Inserts a row

Parameters:
row - Row to be inserted
pos - Index row

addRow

public final void addRow(java.util.Hashtable row)
Appends a row to this view

Parameters:
row - Row to be appended

addRow

public final void addRow(java.lang.String[] cols,
                         java.lang.Object[] values)
Appends a row to this view. Row is constructed from arrays of names and values.

Parameters:
cols - Array of column names
values - Array of values

add

public final void add(View v)
               throws java.lang.Exception
Appends the content of the given view at the end of this view. Columns can or cannot match, and repeated rows will also be appended as anything is checked..

Parameters:
v - View to be appended
Throws:
java.lang.Exception

getRowAt

public final java.util.Hashtable getRowAt(int idx)
Gets a row

Parameters:
idx - Row index
Returns:
The row

removeRow

public final void removeRow(int idx)
Removes a row

Parameters:
idx - Row index

 

© Zentense 2008