home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / CrossLang / TableGenerator.vb < prev   
Encoding:
Text File  |  2000-06-23  |  6.0 KB  |  165 lines

  1. '===========================================================================
  2. '  File:      TableGenerator.vb
  3. '  Summary:   This is the base class for the CrossLang sample.
  4. '----------------------------------------------------------------------------
  5. '  This file is part of the Microsoft NGWS Samples.
  6. '
  7. '  Copyright (C) 1998-2000 Microsoft Corporation.  All rights reserved.
  8. '============================================================================
  9.  
  10. Imports System
  11. Imports System.Text
  12.  
  13. Namespace TableGen
  14. MustInherit Public Class TableGenerator
  15. '******************************************************************************
  16. 'Function : GetTable(byval param as String) as String
  17. '
  18. 'Abstract: This is the generic method that gets called by the client.  The
  19. '       client passes in a String that represents the specific data it wants.
  20. '       Since this class is generic, it does not understand the
  21. '       nature of the data it is returning other than the fact that it is
  22. '       a table.  It simply makes calls to the overrided methods and gets
  23. '       the real data from the derived classes.
  24. '
  25. 'Input Parameters: byval param as String = The String to pass to the derived class.
  26. '
  27. 'Returns: String = the HTML table to display in the client.
  28. '******************************************************************************
  29. public function GetTable(byval param as String) as String
  30.    
  31.    ' Tell derived class what the client wants to get back.
  32.    SetParameter(param)
  33.    
  34.    ' Get Table Column and Row counts from derived class.
  35.    dim columns as Integer
  36.    columns = GetColumnCount()
  37.    dim rows as Integer
  38.    rows = GetRowCount()
  39.  
  40.    ' Create a new StringBuilder for use through the entire method
  41.    dim tabletext as new StringBuilder
  42.    
  43.    ' Append the TABLE HTML tag
  44.    tabletext.Append ("<TABLE RULES=ALL COLS=")
  45.    tabletext.Append (columns)
  46.    tabletext.Append (">")
  47.  
  48.    ' Append the TABLE HEADER
  49.    tabletext.Append (GetHeader())
  50.  
  51.    ' str is used to hold the Cell value
  52.    Dim str as String ' Had to place here instead of in for loop
  53.  
  54.    ' Append the Rows
  55.    dim currentRow as Integer
  56.    for currentRow = 0 to rows-1
  57.       tabletext.Append ("<TR>")
  58.       
  59.       ' Append the Columns
  60.       dim currentColumn as Integer
  61.       for currentColumn = 0 to columns-1
  62.          tabletext.Append ("<TD>")
  63.  
  64.      ' Get the cell data from the derived class
  65.          str = GetCell(currentColumn, currentRow)
  66.          
  67.      '  Append the cell data to the StringBuilder
  68.          tabletext.Append (str)
  69.          tabletext.Append ("</TD>")
  70.       next currentColumn
  71.       tabletext.Append ("</TR>")
  72.    next currentRow
  73.  
  74.    ' Append the TABLE FOOTER
  75.    tabletext.Append (GetFooter())
  76.  
  77.    ' Append the </TABLE> tag to close the table
  78.    tabletext.Append ("</TABLE>")
  79.  
  80.    ' Covert the StringBuilder to a String to return
  81.    GetTable = tabletext.ToString()
  82. end function
  83.  
  84. '******************************************************************************
  85. 'Function : SetParameter(byval param as String)
  86. '
  87. 'Abstract: This abstract method must be implemented by the derived class.
  88. '       This method is used by the derived class to determine what data
  89. '       the client wants.
  90. '
  91. 'Input Parameters: byval param as String = A String representation of what the
  92. '           client needs.
  93. '
  94. 'Returns: none.
  95. '******************************************************************************
  96. MustOverride public sub SetParameter(byval param as String)
  97.  
  98.  
  99. '******************************************************************************
  100. 'Function : GetColumnCount() as Integer
  101. '
  102. 'Abstract: This abstract method must be implemented by the derived class.
  103. '       This method returns the number of columns in this table.
  104. '
  105. 'Input Parameters: none.
  106. '
  107. 'Returns: Integer = the number of columns for this table.
  108. '******************************************************************************
  109. MustOverride public function GetColumnCount() as Integer
  110.  
  111. '******************************************************************************
  112. 'Function : GetRowCount() as Integer
  113. '
  114. 'Abstract: This abstract method must be implemented by the derived class.
  115. '       This method returns the number of rows in this table.
  116. '
  117. 'Input Parameters: none.
  118. '
  119. 'Returns: Integer = the number of rows for this table.
  120. '******************************************************************************
  121. MustOverride public function GetRowCount() as Integer
  122.  
  123. '******************************************************************************
  124. 'Function : GetCell(byval column as Integer, byval row as Integer) as String
  125. '
  126. 'Abstract: This abstract method must be implemented by the derived class.
  127. '       This method returns the cell data for the specified column and row.
  128. '
  129. 'Input Parameters: byval column as Integer, byval row as Integer = the column and row
  130. '           to retieve cell data.
  131. '
  132. 'Returns: String = the HTML data that represents the specified cell in this table.
  133. '******************************************************************************
  134. MustOverride public function GetCell(byval column as Integer, byval row as Integer) as String
  135.  
  136. '******************************************************************************
  137. 'Function : GetHeader() as String
  138. '
  139. 'Abstract: This abstract method must be implemented by the derived class.
  140. '       This method returns the HTML header for this table.
  141. '
  142. 'Input Parameters: none.
  143. '
  144. 'Returns: String = the HTML header for this table.
  145. '******************************************************************************
  146. MustOverride public function GetHeader() as String
  147.  
  148. '******************************************************************************
  149. 'Function : GetFooter() as String
  150. '
  151. 'Abstract: This abstract method must be implemented by the derived class.
  152. '       This method returns the HTML footer for this table.
  153. '
  154. 'Input Parameters: none.
  155. '
  156. 'Returns: String = the HTML footer for this table.
  157. '******************************************************************************
  158. MustOverride public function GetFooter() as String
  159.     
  160.  
  161. End Class
  162.  
  163. End Namespace