1 /*$Id: VotableInResults.java,v 1.2 2005/03/21 18:45:55 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.dataservice.queriers;
12
13 import java.io.*;
14
15 import org.astrogrid.dataservice.queriers.TableResults;
16 import org.astrogrid.dataservice.queriers.status.QuerierStatus;
17 import org.astrogrid.io.Piper;
18 import org.astrogrid.tableserver.out.TableWriter;
19 import org.astrogrid.tableserver.out.VoTableWriter;
20
21 /***
22 * A results wrapper around results that are already of VOTable form; eg
23 * those returned from another service, where the table is referred to by a
24 * stream rather than a parsed document.
25 *
26 */
27 public class VotableInResults extends TableResults {
28
29 protected final InputStream in;
30
31 /*** Std Constructor. votableIn is a stream containing the votable
32 */
33 public VotableInResults(Querier querier, InputStream votableIn) {
34 super(querier);
35 this.in = votableIn;
36 }
37
38 /*** Constructor where the votable is in the given string.
39 */
40 public VotableInResults(Querier querier, String votableDoc) {
41 super(querier);
42 this.in = new StringBufferInputStream(votableDoc);
43 }
44
45 /*** Constructor where the votable is in the given File
46 */
47 public VotableInResults(Querier querier, File votableFile) throws IOException {
48 super(querier);
49 this.in = new FileInputStream(votableFile);
50 }
51
52 public int getCount() {
53 return -1;
54 }
55
56 /*** Writes results to the given TableWriter */
57 public void writeTable(TableWriter tableWriter, QuerierStatus statusToUpdate) throws IOException {
58 if (tableWriter instanceof VoTableWriter) {
59 Piper.bufferedPipe(new InputStreamReader(in), ((VoTableWriter) tableWriter).getOut());
60 }
61 else {
62 throw new UnsupportedOperationException("Can only write to votables");
63 }
64 }
65
66
67 }
68
69
70 /*
71 $Log: VotableInResults.java,v $
72 Revision 1.2 2005/03/21 18:45:55 mch
73 Naughty big lump of changes
74
75 Revision 1.1.1.1 2005/02/17 18:37:35 mch
76 Initial checkin
77
78 Revision 1.1.1.1 2005/02/16 17:11:24 mch
79 Initial checkin
80
81 Revision 1.3.24.4 2004/12/08 18:36:40 mch
82 Added Vizier, rationalised SqlWriters etc, separated out TableResults from QueryResults
83
84 Revision 1.3.24.3 2004/11/30 01:04:02 mch
85 Rationalised tablewriters, reverted AxisDataService06 to string
86
87 Revision 1.3.24.2 2004/11/22 00:57:16 mch
88 New interfaces for SIAP etc and new slinger package
89
90 Revision 1.3.24.1 2004/11/17 17:56:07 mch
91 set mime type, switched results to taking targets
92
93 Revision 1.3 2004/10/18 13:11:30 mch
94 Lumpy Merge
95
96 Revision 1.2.6.1 2004/10/15 19:59:05 mch
97 Lots of changes during trip to CDS to improve int test pass rate
98
99 Revision 1.2 2004/09/29 18:43:51 mch
100 doc change
101
102 Revision 1.1 2004/09/28 15:02:13 mch
103 Merged PAL and server packages
104
105 Revision 1.1 2004/09/07 00:54:20 mch
106 Tidied up Querier/Plugin/Results, and removed deprecated SPI-visitor-SQL-translator
107
108 Revision 1.1 2004/09/06 21:37:26 mch
109 Factored out VotableResults
110
111 Revision 1.3 2004/09/01 12:10:58 mch
112 added results.toHtml
113
114 Revision 1.2 2004/03/14 03:04:57 mch
115 Added CSV writer
116
117 Revision 1.1 2004/03/13 23:40:59 mch
118 Changes to adapt to It05 refactor
119
120 Revision 1.2 2003/12/09 16:25:08 nw
121 wrote plugin documentation
122
123 Revision 1.1 2003/11/18 11:23:49 nw
124 mavenized cds delegate
125
126 Revision 1.1 2003/11/18 11:10:05 nw
127 mavenized cds delegate
128
129 */