View Javadoc

1   /*$Id: VotableInResults.java,v 1.3 2004/10/18 13:11:30 mch Exp $
2    * Created on 13-Nov-2003
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.datacenter.queriers;
12  
13  import java.io.*;
14  
15  import org.astrogrid.datacenter.queriers.QueryResults;
16  import org.astrogrid.datacenter.queriers.status.QuerierProcessingResults;
17  import org.astrogrid.io.Piper;
18  
19  /***
20   * A results wrapper around results that are already of VOTable form; eg
21   * those returned from another service, where the table is referred to by a
22   * stream rather than a parsed document.
23   *
24   */
25  public class VotableInResults extends QueryResults {
26  
27      protected final InputStream in;
28     
29      /***  Std Constructor. votableIn is a stream containing the votable
30       */
31      public VotableInResults(Querier querier, InputStream votableIn) {
32        super(querier);
33        this.in = votableIn;
34      }
35  
36      /***  Constructor where the votable is in the given string.
37       */
38      public VotableInResults(Querier querier, String votableDoc) {
39        super(querier);
40        this.in = new StringBufferInputStream(votableDoc);
41      }
42  
43      /***  Constructor where the votable is in the given File
44       */
45      public VotableInResults(Querier querier, File votableFile) throws IOException {
46        super(querier);
47        this.in = new FileInputStream(votableFile);
48      }
49      
50      public int getCount() {
51         return -1;
52      }
53      
54      /***
55       * Easy one - pipes out VOTable to writer
56       */
57      public void writeVotable(Writer out, QuerierProcessingResults querierStatus) throws IOException {
58          Piper.bufferedPipe(new InputStreamReader(in), out);
59      }
60  
61      /***
62       * Easy one - pipes out VOTable to writer
63       */
64      public void writeRaw(Writer out, QuerierProcessingResults querierStatus) throws IOException {
65          Piper.bufferedPipe(new InputStreamReader(in), out);
66      }
67      
68      /***
69       * Not quite so easy one - HTML
70       */
71      public void writeHtml(Writer out, QuerierProcessingResults querierStatus) throws IOException {
72          throw new UnsupportedOperationException("Not yet implemeneted");
73      }
74  
75      /***
76       * writes out VOTable to writer in CSV form
77       */
78      public void writeCSV(Writer out, QuerierProcessingResults querierStatus) throws IOException {
79          throw new UnsupportedOperationException("Not yet implemeneted");
80      }
81      
82  }
83  
84  
85  /*
86  $Log: VotableInResults.java,v $
87  Revision 1.3  2004/10/18 13:11:30  mch
88  Lumpy Merge
89  
90  Revision 1.2.6.1  2004/10/15 19:59:05  mch
91  Lots of changes during trip to CDS to improve int test pass rate
92  
93  Revision 1.2  2004/09/29 18:43:51  mch
94  doc change
95  
96  Revision 1.1  2004/09/28 15:02:13  mch
97  Merged PAL and server packages
98  
99  Revision 1.1  2004/09/07 00:54:20  mch
100 Tidied up Querier/Plugin/Results, and removed deprecated SPI-visitor-SQL-translator
101 
102 Revision 1.1  2004/09/06 21:37:26  mch
103 Factored out VotableResults
104 
105 Revision 1.3  2004/09/01 12:10:58  mch
106 added results.toHtml
107 
108 Revision 1.2  2004/03/14 03:04:57  mch
109 Added CSV writer
110 
111 Revision 1.1  2004/03/13 23:40:59  mch
112 Changes to adapt to It05 refactor
113 
114 Revision 1.2  2003/12/09 16:25:08  nw
115 wrote plugin documentation
116 
117 Revision 1.1  2003/11/18 11:23:49  nw
118 mavenized cds delegate
119 
120 Revision 1.1  2003/11/18 11:10:05  nw
121 mavenized cds delegate
122  
123 */