001 /*****************************************************************************
002 * MODULE DESCRIPTION
003 ******************************************************************************
004 *
005 * NAME: HtmlColumn.java
006 * LANGUAGE: Java 2
007 * DATE: 11.02.2002
008 * AUTHOR: Miika Nurminen, University of Jyväskylä (JYU)
009 * PURPOSE: Abstraction of HTML table column
010 *
011 ******************************************************************************
012 * COPYRIGHT (C) Kiuru group
013 * Limited rights granted. Please refer to license
014 *****************************************************************************/
015
016 /*****************************************************************************
017 * UPDATES
018 ******************************************************************************
019 *
020 * 17.3.2003 / mn
021 * - Initial version
022 *
023 ******************************************************************************/
024 package kiurubeans;
025 import kotkabeans.RS2;
026
027 /**
028 * Representation of a column that consists of several db fields.
029 * Fields are put in sequence, separated by space.
030 */
031 public class HtmlCombinedColumn extends HtmlColumn {
032 /** HtmlColumns that constitute the combined column */
033 HtmlColumn[] columns;
034
035 /** Creates a new instance of HtmlCombinedColumn
036 * @param columns HtmlColumns that constitute the combined column
037 * @param title text to be shown in th
038 */
039 public HtmlCombinedColumn(HtmlColumn[] columns,String title) {
040 this.columns = columns;
041 StringBuffer f=new StringBuffer(this.columns.length*10);
042 for (int i=0; i<this.columns.length; i++) {
043 if (i>0) f.append(",");
044 f.append(columns[i].getFieldName());
045 }
046 assignValues(f.toString(),title);
047 }
048
049 /** Returns current table cell data as string
050 * @return data to be put in <td></td>
051 * @param rs RS2 where the data is retrieved
052 */
053 public String getCellData(RS2 rs) {
054 if ((this.columns==null) || (this.columns.length==0)) return "";
055 StringBuffer result = new StringBuffer(this.columns.length*10);
056 for (int i=0; i<this.columns.length; i++) {
057 if (i>0) result.append(" ");
058 result.append(this.columns[i].getCellData(rs));
059 }
060 return result.toString();
061 }
062
063 }
064 /***************************************************************************************************
065 * COPYRIGHT (C) KIURU -PROJECT GROUP
066 * Limited rights granted. Please refer to license.
067 **************************************************************************************************/