home *** CD-ROM | disk | FTP | other *** search
- '===========================================================================
- ' File: TableGenerator.vb
- '
- ' Summary: This is the base class for the CrossLang sample.
- '
- '----------------------------------------------------------------------------
- ' This file is part of the Microsoft NGWS Samples.
- '
- ' Copyright (C) 1998-2000 Microsoft Corporation. All rights reserved.
- '============================================================================
-
- Imports System
- Imports System.Text
-
- Namespace TableGen
- MustInherit Public Class TableGenerator
- '******************************************************************************
- 'Function : GetTable(byval param as String) as String
- '
- 'Abstract: This is the generic method that gets called by the client. The
- ' client passes in a String that represents the specific data it wants.
- ' Since this class is generic, it does not understand the
- ' nature of the data it is returning other than the fact that it is
- ' a table. It simply makes calls to the overrided methods and gets
- ' the real data from the derived classes.
- '
- 'Input Parameters: byval param as String = The String to pass to the derived class.
- '
- 'Returns: String = the HTML table to display in the client.
- '******************************************************************************
- public function GetTable(byval param as String) as String
-
- ' Tell derived class what the client wants to get back.
- SetParameter(param)
-
- ' Get Table Column and Row counts from derived class.
- dim columns as Integer
- columns = GetColumnCount()
- dim rows as Integer
- rows = GetRowCount()
-
- ' Create a new StringBuilder for use through the entire method
- dim tabletext as new StringBuilder
-
- ' Append the TABLE HTML tag
- tabletext.Append ("<TABLE RULES=ALL COLS=")
- tabletext.Append (columns)
- tabletext.Append (">")
-
- ' Append the TABLE HEADER
- tabletext.Append (GetHeader())
-
- ' str is used to hold the Cell value
- Dim str as String ' Had to place here instead of in for loop
-
- ' Append the Rows
- dim currentRow as Integer
- for currentRow = 0 to rows-1
- tabletext.Append ("<TR>")
-
- ' Append the Columns
- dim currentColumn as Integer
- for currentColumn = 0 to columns-1
- tabletext.Append ("<TD>")
-
- ' Get the cell data from the derived class
- str = GetCell(currentColumn, currentRow)
-
- ' Append the cell data to the StringBuilder
- tabletext.Append (str)
- tabletext.Append ("</TD>")
- next currentColumn
- tabletext.Append ("</TR>")
- next currentRow
-
- ' Append the TABLE FOOTER
- tabletext.Append (GetFooter())
-
- ' Append the </TABLE> tag to close the table
- tabletext.Append ("</TABLE>")
-
- ' Covert the StringBuilder to a String to return
- GetTable = tabletext.ToString()
- end function
-
- '******************************************************************************
- 'Function : SetParameter(byval param as String)
- '
- 'Abstract: This abstract method must be implemented by the derived class.
- ' This method is used by the derived class to determine what data
- ' the client wants.
- '
- 'Input Parameters: byval param as String = A String representation of what the
- ' client needs.
- '
- 'Returns: none.
- '******************************************************************************
- MustOverride public sub SetParameter(byval param as String)
-
-
- '******************************************************************************
- 'Function : GetColumnCount() as Integer
- '
- 'Abstract: This abstract method must be implemented by the derived class.
- ' This method returns the number of columns in this table.
- '
- 'Input Parameters: none.
- '
- 'Returns: Integer = the number of columns for this table.
- '******************************************************************************
- MustOverride public function GetColumnCount() as Integer
-
- '******************************************************************************
- 'Function : GetRowCount() as Integer
- '
- 'Abstract: This abstract method must be implemented by the derived class.
- ' This method returns the number of rows in this table.
- '
- 'Input Parameters: none.
- '
- 'Returns: Integer = the number of rows for this table.
- '******************************************************************************
- MustOverride public function GetRowCount() as Integer
-
- '******************************************************************************
- 'Function : GetCell(byval column as Integer, byval row as Integer) as String
- '
- 'Abstract: This abstract method must be implemented by the derived class.
- ' This method returns the cell data for the specified column and row.
- '
- 'Input Parameters: byval column as Integer, byval row as Integer = the column and row
- ' to retieve cell data.
- '
- 'Returns: String = the HTML data that represents the specified cell in this table.
- '******************************************************************************
- MustOverride public function GetCell(byval column as Integer, byval row as Integer) as String
-
- '******************************************************************************
- 'Function : GetHeader() as String
- '
- 'Abstract: This abstract method must be implemented by the derived class.
- ' This method returns the HTML header for this table.
- '
- 'Input Parameters: none.
- '
- 'Returns: String = the HTML header for this table.
- '******************************************************************************
- MustOverride public function GetHeader() as String
-
- '******************************************************************************
- 'Function : GetFooter() as String
- '
- 'Abstract: This abstract method must be implemented by the derived class.
- ' This method returns the HTML footer for this table.
- '
- 'Input Parameters: none.
- '
- 'Returns: String = the HTML footer for this table.
- '******************************************************************************
- MustOverride public function GetFooter() as String
-
-
- End Class
-
- End Namespace