View Javadoc

1   /*
2    * $Id: TableConverter.java,v 1.2 2004/11/27 13:20:02 pah Exp $
3    * 
4    * Created on 10-Nov-2004 by Paul Harrison (pah@jb.man.ac.uk)
5    * Copyright 2004 AstroGrid. All rights reserved.
6    *
7    * This software is published under the terms of the AstroGrid 
8    * Software License version 1.2, a copy of which has been included 
9    * with this distribution in the LICENSE.txt file.  
10   *
11   */ 
12  
13  package org.astrogrid.applications.apps.tables;
14  
15  import java.io.IOException;
16  import java.io.InputStream;
17  import java.io.OutputStream;
18  
19  import uk.ac.starlink.table.StarTable;
20  import uk.ac.starlink.table.StarTableFactory;
21  import uk.ac.starlink.table.StarTableOutput;
22  import uk.ac.starlink.table.TableFormatException;
23  
24  /***
25   * @author Paul Harrison (pah@jb.man.ac.uk) 10-Nov-2004
26   * @version $Name: HEAD $
27   * @since iteration6
28   */
29  public class TableConverter {
30  
31     private final StarTableFactory factory;
32     private final StarTable inTable;
33  
34     /***
35      * @param stream
36      * @param inputFomat
37      * @throws IOException
38      * @throws TableFormatException
39      * 
40      */
41     public TableConverter(InputStream stream, String inputFormat) throws TableFormatException, IOException {
42        factory = new StarTableFactory();
43        inTable = factory.makeStarTable(new StreamDataSource(stream), inputFormat);
44        
45        
46     }
47     
48     public void  write(String outputFormat) throws TableFormatException, IOException
49     {
50        //TODO - it would be good if the writeStartable routine
51        	new StarTableOutput().writeStarTable(inTable, outputFormat, outputFormat);
52     }
53     
54  
55  }