View Javadoc

1   /*$Id: ExtraTableMethods.java,v 1.2 2004/12/07 16:50:33 jdt Exp $
2    * Created on 07-Dec-2004
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid 
7    * Software License version 1.2, a copy of which has been included 
8    * with this distribution in the LICENSE.txt file.  
9    *
10  **/
11  package org.astrogrid.scripting.table;
12  
13  import uk.ac.starlink.table.ColumnInfo;
14  
15  import java.io.IOException;
16  import java.util.Iterator;
17  
18  /*** This interface defines an additional set of methods that all {@link ScriptStarTable} instances support.
19   * @author Noel Winstanley nw@jb.man.ac.uk 07-Dec-2004
20   *
21   */
22  interface ExtraTableMethods {
23      /*** iterate over each row in the table. 
24       * @return an iterator that will return a {@link java.util.List} of the cells in each row
25       * @throws IOException*/
26      public abstract Iterator iterator() throws IOException;
27  
28      /***iterate over each cell in a column 
29       * @param col column to iterate over
30       * @return an iteratore that will return the value of each cell in this column.
31       * @throws IOException*/
32      public abstract Iterator columnIterator(final int col) throws IOException;
33      
34      /*** Return a mutable copy of this table.
35       * @return a mutable table that has the same structure and contents as the current table.
36       * @throws IOException
37       */
38      public MutableScriptStarTable asMutableTable() throws IOException;
39      
40      /***Return a new table, based on this table, but with one column removed
41       * @param index index of the column to remove.
42       * @return a new table, based on this one, with one less column.
43       */
44      public ScriptStarTable removeColumn(int index);
45      
46      /*** Return a new table, based on this one with an additional colum
47       * @param meta metadata for the new column
48       * @param colValue a value that defines the column value. May either be
49       * <ul>
50       *   <li>a static {@link java.lang.reflect.Method}, of type <code>Object method(Object[] arr)</code>. The method will be passed
51       * the values of the other cells in the row, and the result used as the value of the new cell</li>
52       *  <li>an instance of {@link ColumnFunction} whose method will be called to define the value of the new cell</li>
53       * <li>a <i>groovy closure</i> - which will be passed a single parameter - a list containing the values of the other cells in the row. The result
54       * returned by the closure will be used as the value of the new cell.
55       * <li>any other object - in which case it is used as a constant value for every cell in this column.
56       * </ul>
57       * @return a new table, same as this one, with an extra column at the end.
58       */
59      public ScriptStarTable addColumn(ColumnInfo meta,Object colValue);
60  }
61  
62  
63  /* 
64  $Log: ExtraTableMethods.java,v $
65  Revision 1.2  2004/12/07 16:50:33  jdt
66  merges from scripting-nww-805
67  
68  Revision 1.1.2.1  2004/12/07 14:47:58  nw
69  got table manipulation working.
70   
71  */