com.zentense.step2.view
Class View

java.lang.Object
  extended by com.zentense.step2.view.View
Direct Known Subclasses:
DelegatedView, ResultSetView, RowView

public abstract class View
extends java.lang.Object

A view is a collection of rows, being a row a collection of columns, so views are a bidimentional table of data. A view can contain any number of rows (from 0 to N), and rows are ordered (there is a first row, a second one, a last one, etc). Each row can contain any number of columns (even 0, although a row without columns is an empty row), and can be expected that the columns will be the same across rows, although this is not enforced in the implementation. Columns are not ordered (there is no first or last column) and are accessed through it's name. Views are used mainly to show or process data.

This is the abstract view implementation. All the rest of views subclass this one.

Author:
kurt

Nested Class Summary
static class View.Empty
          An empty ResultSetView implementation
 
Field Summary
static View.Empty EMPTY
          An empty view instance
 
Constructor Summary
View()
          Default constructor
 
Method Summary
 DelegatedView asDelegated()
          Casts this view as a DelegatedView
 ResultSetView asDelegatedResultSet()
          Casts this view as a ResultSetView into a DelegatedView
 ResultSetView asResultSet()
          Casts this view as a ResultSetView
 void fillFromRow(java.util.Hashtable row)
          Fills current row from a Hashtable.
 void fillRowFromRequest(RequestRuntime vm)
          Fills current row from request parameters.
 View first()
           
abstract  java.lang.Object get(java.lang.String colName)
          Gets a column value
 boolean getBool(java.lang.String colName)
          Gets a boolean column
 VectorRowView getCachedClone()
          Return this view as a Vector of Hashtables, where each Hashtable is a row of the view
abstract  java.lang.String[] getCols()
          Returns view columns
 VectorRowView getColsAsView()
          Gets columns as a View
 int getCount()
          Gets results total size
 double getDouble(java.lang.String colName)
          Gets a double representation of a column
static java.lang.String getIndent(int ind)
          Gets a string composed of 'ind' spaces.
 int getInt(java.lang.String colName)
          Gets an integer representation of a column value
 int getOrdinal()
          Gets the current position of this view.
 java.util.Hashtable getRow()
          Gets current row as a Hashtable
 java.util.Hashtable getRow(java.lang.String[] cols)
          Gets current row as a Hashtable cols Columns to be included in returned Hashtable
abstract  int getSize()
          Gets results size.
 int getStart()
          Returns the first visible row in this view.
 double getSum(java.lang.String col)
          Gets the sum of a column
 void insertRow()
          Inserts row.
 boolean next()
          Advances the view to the next row.
 void open()
          Position the view before the first visible row
 void randomPosition()
          Moves to a random row from this view
abstract  void set(java.lang.String colName, java.lang.Object obj)
          Sets a (key, value) pair
 void setPageBounds(com.zentense.step2.deprecated.AppUnit unit)
          Sets page bounds.
 void setPageBounds(int begin, int step)
          Sets page bounds.
 void setPageBounds(int begin, int step, Pager pager)
          Sets page bounds.
 void setPageBounds(java.lang.String begin, int step, Pager pager)
          Sets page bounds.
 void setPosition(int pos)
          Moves to another row in view
 void updateRow()
          Updates row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final View.Empty EMPTY
An empty view instance

Constructor Detail

View

public View()
Default constructor

Method Detail

getSize

public abstract int getSize()
                     throws java.lang.Exception
Gets results size. For a paged view it returns the page size.

Returns:
Visible results size
Throws:
java.lang.Exception

getCount

public int getCount()
             throws java.lang.Exception
Gets results total size

Returns:
Number of results in view (even outside page).
Throws:
java.lang.Exception

set

public abstract void set(java.lang.String colName,
                         java.lang.Object obj)
                  throws java.lang.Exception
Sets a (key, value) pair

Parameters:
colName - Column name (key)
obj - Value
Throws:
java.lang.Exception

get

public abstract java.lang.Object get(java.lang.String colName)
                              throws java.lang.Exception
Gets a column value

Parameters:
colName - Column name (key)
Returns:
Column value
Throws:
java.lang.Exception

getInt

public final int getInt(java.lang.String colName)
                 throws java.lang.Exception
Gets an integer representation of a column value

Parameters:
colName - Column name (key)
Returns:
Integer representation of value
Throws:
java.lang.Exception

getBool

public final boolean getBool(java.lang.String colName)
                      throws java.lang.Exception
Gets a boolean column

Parameters:
colName - Column name (key)
Returns:
Boolean value
Throws:
java.lang.Exception

getDouble

public final double getDouble(java.lang.String colName)
                       throws java.lang.Exception
Gets a double representation of a column

Parameters:
colName - Column name (key)
Returns:
Double representation of the value
Throws:
java.lang.Exception

getIndent

public static final java.lang.String getIndent(int ind)
Gets a string composed of 'ind' spaces. Used for indent XML output.


getCols

public abstract java.lang.String[] getCols()
                                    throws java.lang.Exception
Returns view columns

Throws:
java.lang.Exception

getColsAsView

public final VectorRowView getColsAsView()
                                  throws java.lang.Exception
Gets columns as a View

Returns:
View with column names
Throws:
java.lang.Exception

getOrdinal

public int getOrdinal()
               throws java.lang.Exception
Gets the current position of this view. First is 0

Throws:
java.lang.Exception

setPageBounds

public final void setPageBounds(java.lang.String begin,
                                int step,
                                Pager pager)
                         throws java.lang.Exception
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.

Parameters:
begin - First row in page
step - Number of rows in page
pager - Pager to be initialized to represent this paging
Throws:
java.lang.Exception

setPageBounds

public final void setPageBounds(com.zentense.step2.deprecated.AppUnit unit)
                         throws java.lang.Exception
Sets page bounds. Bounds and pager are got from the AppUnit

Throws:
java.lang.Exception

setPageBounds

public void setPageBounds(int begin,
                          int step)
                   throws java.lang.Exception
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.

Parameters:
begin - First row in page
step - Number of rows in page
Throws:
java.lang.Exception

setPageBounds

public final void setPageBounds(int begin,
                                int step,
                                Pager pager)
                         throws java.lang.Exception
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.

Parameters:
begin - First row in page
step - Number of rows in page
pager - Pager to be initialized to represent this paging
Throws:
java.lang.Exception

getStart

public int getStart()
Returns the first visible row in this view.

See Also:
View#setPageBounds(Integer, Integer)

next

public boolean next()
             throws java.lang.Exception
Advances the view to the next row. Returns true while more rows are available

Throws:
java.lang.Exception

open

public void open()
          throws java.lang.Exception
Position the view before the first visible row

Throws:
java.lang.Exception

setPosition

public void setPosition(int pos)
                 throws java.lang.Exception
Moves to another row in view

Throws:
java.lang.Exception

randomPosition

public final void randomPosition()
                          throws java.lang.Exception
Moves to a random row from this view

Throws:
java.lang.Exception

getRow

public java.util.Hashtable getRow()
                           throws java.lang.Exception
Gets current row as a Hashtable

Throws:
java.lang.Exception

getRow

public final java.util.Hashtable getRow(java.lang.String[] cols)
                                 throws java.lang.Exception
Gets current row as a Hashtable cols Columns to be included in returned Hashtable

Throws:
java.lang.Exception

getSum

public double getSum(java.lang.String col)
              throws java.lang.Exception
Gets the sum of a column

Parameters:
col - Column name
Returns:
Total sum of the column along all rows
Throws:
java.lang.Exception

getCachedClone

public VectorRowView getCachedClone()
                             throws java.lang.Exception
Return this view as a Vector of Hashtables, where each Hashtable is a row of the view

Throws:
java.lang.Exception

asResultSet

public final ResultSetView asResultSet()
Casts this view as a ResultSetView


asDelegated

public final DelegatedView asDelegated()
Casts this view as a DelegatedView


asDelegatedResultSet

public final ResultSetView asDelegatedResultSet()
Casts this view as a ResultSetView into a DelegatedView


fillRowFromRequest

public final void fillRowFromRequest(RequestRuntime vm)
                              throws java.lang.Exception
Fills current row from request parameters. Only non-null values from request parameters whose name match with any of the view column names are updated in the view, and the rest are ignored

Throws:
java.lang.Exception

fillFromRow

public final void fillFromRow(java.util.Hashtable row)
                       throws java.lang.Exception
Fills current row from a Hashtable. Only values from Hashtable whose key match with any of the view column names are updated in the view, and the rest are ignored

Throws:
java.lang.Exception

insertRow

public void insertRow()
               throws java.lang.Exception
Inserts row. Works only for ResultSetViews

Throws:
java.lang.Exception

updateRow

public void updateRow()
               throws java.lang.Exception
Updates row. Works only for ResultSetViews

Throws:
java.lang.Exception

first

public View first()

 

© Zentense 2008