View Javadoc

1   /*$Id: ScriptStarTable.java,v 1.3 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 java.io.IOException;
14  import java.util.Iterator;
15  
16  import uk.ac.starlink.table.ColumnInfo;
17  import uk.ac.starlink.table.StarTable;
18  
19  
20  
21  /*** A Scriptable Star Table - extends basic StarLink StarTable.
22   * See StarTable Javadoc - <a href="http://www.star.bristol.ac.uk/~mbt/stil/javadocs/uk/ac/starlink/table/StarTable.html">http://www.star.bristol.ac.uk/~mbt/stil/javadocs/uk/ac/starlink/table/StarTable.html</a>
23   * @author Noel Winstanley nw@jb.man.ac.uk 07-Dec-2004
24   *
25   */
26  public interface ScriptStarTable  extends StarTable, ExtraTableMethods{
27      /*** iterate over each row in the table. 
28       * @return an iterator that will return a {@link java.util.List} of the cells in each row
29       * @throws IOException*/
30      public abstract Iterator iterator() throws IOException;
31  
32      /***iterate over each cell in a column 
33       * @param col column to iterate over
34       * @return an iteratore that will return the value of each cell in this column.
35       * @throws IOException*/
36      public abstract Iterator columnIterator(final int col) throws IOException;
37      
38      /*** Return a mutable copy of this table.
39       * @return a mutable table that has the same structure and contents as the current table.
40       * @throws IOException
41       */
42      public MutableScriptStarTable asMutableTable() throws IOException;
43      
44      /***Return a new table, based on this table, but with one column removed
45       * @param index index of the column to remove.
46       * @return a new table, based on this one, with one less column.
47       */
48      public ScriptStarTable removeColumn(int index);
49      
50      /*** Return a new table, based on this one with an additional colum
51       * @param meta metadata for the new column
52       * @param colValue a value that defines the column value. May either be
53       * <ul>
54       *   <li>a static {@link java.lang.reflect.Method}, of type <code>Object method(Object[] arr)</code>. The method will be passed
55       * the values of the other cells in the row, and the result used as the value of the new cell</li>
56       *  <li>an instance of {@link ColumnFunction} whose method will be called to define the value of the new cell</li>
57       * <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
58       * returned by the closure will be used as the value of the new cell.
59       * <li>any other object - in which case it is used as a constant value for every cell in this column.
60       * </ul>
61       * @return a new table, same as this one, with an extra column at the end.
62       */
63      public ScriptStarTable addColumn(ColumnInfo meta,Object colValue);
64  }
65  
66  /* 
67   $Log: ScriptStarTable.java,v $
68   Revision 1.3  2004/12/07 16:50:33  jdt
69   merges from scripting-nww-805
70  
71   Revision 1.2.2.1  2004/12/07 14:47:58  nw
72   got table manipulation working.
73   
74   */