1
2
3
4
5
6
7
8
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123