Commit d3a65e87de26117b1b41712f37b2d21891496cdc
1 parent
4164c074
Exists in
master
Improve Javadoc.
Showing
6 changed files
with
72 additions
and
105 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java
... | ... | @@ -43,7 +43,7 @@ import com.google.gson.JsonObject; |
43 | 43 | import com.google.gson.JsonParser; |
44 | 44 | |
45 | 45 | import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableConnection; |
46 | -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.SendQueryException; | |
46 | +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException; | |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * A field used to set a service parameter to build the query (in the parameter panel). ParamField |
... | ... | @@ -353,9 +353,9 @@ public abstract class ParamField extends JPanel { |
353 | 353 | * |
354 | 354 | * @param begining The beginning of the target_name. |
355 | 355 | * @return An array of Strings corresponding to the target names got. |
356 | - * @throws SendQueryException If the resolver do not work. | |
356 | + * @throws CantSendQueryException If the resolver do not work. | |
357 | 357 | */ |
358 | - static String[] getItems(String begining) throws SendQueryException { | |
358 | + static String[] getItems(String begining) throws CantSendQueryException { | |
359 | 359 | StringBuilder resolverResult = null; |
360 | 360 | resolverResult = VOTableConnection.sendGet(RESOLVER_URL, "q=\"" + begining + "\""); |
361 | 361 | JsonObject root = new JsonParser().parse(resolverResult.toString()).getAsJsonObject(); |
... | ... | @@ -386,7 +386,7 @@ public abstract class ParamField extends JPanel { |
386 | 386 | for (String s : getItems(content)) { |
387 | 387 | comboBox.addItem(s); |
388 | 388 | } |
389 | - } catch (SendQueryException e) { | |
389 | + } catch (CantSendQueryException e) { | |
390 | 390 | logger.log(Level.WARNING, "Can't get table names for the resolver", e); |
391 | 391 | } |
392 | 392 | comboBox.getEditor().setItem(content); | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/votable/Utils.java
... | ... | @@ -34,17 +34,36 @@ public class Utils { |
34 | 34 | /** The logger for the class Utils. */ |
35 | 35 | private static final Logger logger = Logger.getLogger(Utils.class.getName()); |
36 | 36 | |
37 | + /** | |
38 | + * StringJoiner has the same purpose of Java 8 StringJoiner, it has been rewritten for Java7 | |
39 | + * compatibility. | |
40 | + * | |
41 | + * @author N. Jourdane | |
42 | + */ | |
37 | 43 | public static class StringJoiner { |
38 | - String separator; | |
44 | + /** A list of words to join, ie. ["foo", "bar"]. */ | |
39 | 45 | List<String> list; |
46 | + /** The string joiner separator to put between each word, ie. ';'. */ | |
47 | + String separator; | |
48 | + /** The resulting string, ie. "foo;bar". */ | |
40 | 49 | String string; |
41 | 50 | |
51 | + /** | |
52 | + * Method constructor for the String joiner. | |
53 | + * | |
54 | + * @param separator The string joiner separator to put between each word, ie. ';'. | |
55 | + */ | |
42 | 56 | public StringJoiner(String separator) { |
43 | 57 | this.separator = separator; |
44 | 58 | this.list = new ArrayList<>(); |
45 | 59 | string = ""; |
46 | 60 | } |
47 | 61 | |
62 | + /** | |
63 | + * add a new word to the joiner. | |
64 | + * | |
65 | + * @param text The word to add. | |
66 | + */ | |
48 | 67 | public void add(String text) { |
49 | 68 | if ("".equals(string)) { |
50 | 69 | string = text; |
... | ... | @@ -60,7 +79,7 @@ public class Utils { |
60 | 79 | } |
61 | 80 | |
62 | 81 | /** |
63 | - * Print the specified object in JSON format in a file on the temp directory. | |
82 | + * Print the specified object in JSON format in a file on the temporary directory. | |
64 | 83 | * |
65 | 84 | * @param title The name of the file. |
66 | 85 | * @param obj the object to print in a file. | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java
... | ... | @@ -19,11 +19,11 @@ package eu.omp.irap.vespa.epntapclient.votable.controller; |
19 | 19 | import java.io.IOException; |
20 | 20 | import java.util.logging.Logger; |
21 | 21 | |
22 | -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException; | |
23 | -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException.CantModifyVOTableException; | |
24 | -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException.ErrorMessageInVOTableException; | |
25 | -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException.SeveralResourcesException; | |
26 | -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException.SeveralTablesException; | |
22 | +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException; | |
23 | +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException.CantModifyVOTableException; | |
24 | +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException.ErrorMessageInVOTableException; | |
25 | +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException.SeveralResourcesException; | |
26 | +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException.SeveralTablesException; | |
27 | 27 | import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException; |
28 | 28 | import eu.omp.irap.vespa.epntapclient.votable.model.Table; |
29 | 29 | import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; |
... | ... | @@ -82,20 +82,21 @@ public class VOTableController { |
82 | 82 | * @param queryLanguage The language used for the queries (ie. "ADQL"). |
83 | 83 | * @param query The query to ask to the registry. |
84 | 84 | * @throws CantSendQueryException If the query can not be sent. |
85 | - * @throws CantFillTableException If the table can not be filled. @see CantFillTableException | |
85 | + * @throws CantDisplayVOTableException If the table can not be filled. @see | |
86 | + * CantFillTableException | |
86 | 87 | */ |
87 | 88 | public void fillTable(String targetURL, String queryLanguage, String query) |
88 | - throws CantFillTableException, CantSendQueryException { | |
89 | + throws CantDisplayVOTableException, CantSendQueryException { | |
89 | 90 | String voTablePath = VOTableConnection.sendQuery(targetURL, queryLanguage, query); |
90 | 91 | fillTable(voTablePath); |
91 | 92 | } |
92 | 93 | |
93 | 94 | /** |
94 | 95 | * @param voTablePath The path of the VOTable file. |
95 | - * @throws CantFillTableException If the VOTable can not be filled. | |
96 | + * @throws CantDisplayVOTableException If the VOTable can not be filled. | |
96 | 97 | */ |
97 | 98 | public void fillTable(String voTablePath) |
98 | - throws CantFillTableException { | |
99 | + throws CantDisplayVOTableException { | |
99 | 100 | |
100 | 101 | voTable = VOTableParser.parseVOTable(voTablePath); |
101 | 102 | |
... | ... | @@ -121,7 +122,7 @@ public class VOTableController { |
121 | 122 | dataParser = new VOTableDataParser(table); |
122 | 123 | view.fillTable(dataParser.getColumnsName(), dataParser.getDataArray()); |
123 | 124 | } catch (IOException e) { |
124 | - throw new CantModifyVOTableException(e); | |
125 | + throw new CantModifyVOTableException(voTablePath, e); | |
125 | 126 | } |
126 | 127 | } |
127 | 128 | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java
... | ... | @@ -30,8 +30,6 @@ public abstract class VOTableException extends Exception { |
30 | 30 | private static final long serialVersionUID = -5707662871529583209L; |
31 | 31 | |
32 | 32 | /** |
33 | - * Method constructor | |
34 | - * | |
35 | 33 | * @param message The message describing the exception displayed in the error dialog. |
36 | 34 | */ |
37 | 35 | public VOTableException(String message) { |
... | ... | @@ -39,8 +37,6 @@ public abstract class VOTableException extends Exception { |
39 | 37 | } |
40 | 38 | |
41 | 39 | /** |
42 | - * Method constructor | |
43 | - * | |
44 | 40 | * @param message The message describing the exception displayed in the error dialog. |
45 | 41 | * @param e The exception thrown. |
46 | 42 | */ |
... | ... | @@ -48,16 +44,10 @@ public abstract class VOTableException extends Exception { |
48 | 44 | super(message, e); |
49 | 45 | } |
50 | 46 | |
51 | - /** | |
52 | - * Abstract exception for when the application can not send the query. | |
53 | - * | |
54 | - * @author N. Jourdane | |
55 | - */ | |
47 | + /** Abstract exception for when the application can not send the query. */ | |
56 | 48 | public abstract static class CantSendQueryException extends VOTableException { |
57 | 49 | |
58 | 50 | /** |
59 | - * Method constructor with a message. | |
60 | - * | |
61 | 51 | * @param message The message describing the exception displayed in the error dialog. |
62 | 52 | */ |
63 | 53 | public CantSendQueryException(String message) { |
... | ... | @@ -65,8 +55,6 @@ public abstract class VOTableException extends Exception { |
65 | 55 | } |
66 | 56 | |
67 | 57 | /** |
68 | - * Method constructor with a message and and exception. | |
69 | - * | |
70 | 58 | * @param message The message describing the exception displayed in the error dialog. |
71 | 59 | * @param e The exception thrown. |
72 | 60 | */ |
... | ... | @@ -74,13 +62,10 @@ public abstract class VOTableException extends Exception { |
74 | 62 | super(message, e); |
75 | 63 | } |
76 | 64 | |
77 | - /** | |
78 | - * @author N. Jourdane | |
79 | - */ | |
65 | + /** The URL is not correctly formated. */ | |
80 | 66 | public static class MalformedURLException extends CantSendQueryException { |
67 | + | |
81 | 68 | /** |
82 | - * Method constructor | |
83 | - * | |
84 | 69 | * @param uri The URI sent to the server. |
85 | 70 | * @param e The exception thrown. |
86 | 71 | */ |
... | ... | @@ -89,13 +74,10 @@ public abstract class VOTableException extends Exception { |
89 | 74 | } |
90 | 75 | } |
91 | 76 | |
92 | - /** | |
93 | - * @author N. Jourdane | |
94 | - */ | |
77 | + /** Can not print the result in the file. */ | |
95 | 78 | public static class CantPrintRequestResultException extends CantSendQueryException { |
79 | + | |
96 | 80 | /** |
97 | - * Method constructor | |
98 | - * | |
99 | 81 | * @param resultFilePath The path of the file where the query results should be stored. |
100 | 82 | * @param e The exception thrown. |
101 | 83 | */ |
... | ... | @@ -104,13 +86,10 @@ public abstract class VOTableException extends Exception { |
104 | 86 | } |
105 | 87 | } |
106 | 88 | |
107 | - /** | |
108 | - * @author N. Jourdane | |
109 | - */ | |
89 | + /** Can not open an HTTP connection to the specified URL. */ | |
110 | 90 | public static class CantOpenConnectionException extends CantSendQueryException { |
91 | + | |
111 | 92 | /** |
112 | - * Method constructor | |
113 | - * | |
114 | 93 | * @param uri The URI sent to the server. |
115 | 94 | * @param e The exception thrown. |
116 | 95 | */ |
... | ... | @@ -119,13 +98,10 @@ public abstract class VOTableException extends Exception { |
119 | 98 | } |
120 | 99 | } |
121 | 100 | |
122 | - /** | |
123 | - * @author N. Jourdane | |
124 | - */ | |
101 | + /** Can not get the server response code for the request. */ | |
125 | 102 | public static class CantGetResponseCode extends CantSendQueryException { |
103 | + | |
126 | 104 | /** |
127 | - * Method constructor | |
128 | - * | |
129 | 105 | * @param uri The URI sent to the server. |
130 | 106 | * @param e The exception thrown. |
131 | 107 | */ |
... | ... | @@ -134,13 +110,10 @@ public abstract class VOTableException extends Exception { |
134 | 110 | } |
135 | 111 | } |
136 | 112 | |
137 | - /** | |
138 | - * @author N. Jourdane | |
139 | - */ | |
113 | + /** The server returned the bad response code (but not 400). */ | |
140 | 114 | public static class BadResponseCodeException extends CantSendQueryException { |
115 | + | |
141 | 116 | /** |
142 | - * Method constructor | |
143 | - * | |
144 | 117 | * @param uri The URI sent to the server. |
145 | 118 | * @param responseCode The HTTP GET response code, which is bad. |
146 | 119 | */ |
... | ... | @@ -150,13 +123,10 @@ public abstract class VOTableException extends Exception { |
150 | 123 | } |
151 | 124 | } |
152 | 125 | |
153 | - /** | |
154 | - * @author N. Jourdane | |
155 | - */ | |
126 | + /** Can not get the input stream of the result, neither the error stream. */ | |
156 | 127 | public static class CantGetErrorStream extends CantSendQueryException { |
128 | + | |
157 | 129 | /** |
158 | - * Method constructor | |
159 | - * | |
160 | 130 | * @param uri The URI sent to the server. |
161 | 131 | * @param e The exception thrown. |
162 | 132 | */ |
... | ... | @@ -168,14 +138,10 @@ public abstract class VOTableException extends Exception { |
168 | 138 | |
169 | 139 | } |
170 | 140 | |
171 | - /** | |
172 | - * @author N. Jourdane | |
173 | - */ | |
141 | + /** Abstract exception for when the application can not display the VOTable. */ | |
174 | 142 | public abstract static class CantDisplayVOTableException extends VOTableException { |
175 | 143 | |
176 | 144 | /** |
177 | - * Method constructor | |
178 | - * | |
179 | 145 | * @param message The message describing the exception displayed in the error dialog. |
180 | 146 | * @param e The exception thrown. |
181 | 147 | */ |
... | ... | @@ -184,22 +150,17 @@ public abstract class VOTableException extends Exception { |
184 | 150 | } |
185 | 151 | |
186 | 152 | /** |
187 | - * Method constructor | |
188 | - * | |
189 | 153 | * @param message The message describing the exception displayed in the error dialog. |
190 | 154 | */ |
191 | 155 | public CantDisplayVOTableException(String message) { |
192 | 156 | super(message); |
193 | 157 | } |
194 | 158 | |
195 | - /** | |
196 | - * @author N. Jourdane | |
197 | - */ | |
159 | + /** Can not parse the VOTable because it doesn't match with the VOTable schema. */ | |
198 | 160 | public static class VOTableIsNotValidException extends CantDisplayVOTableException { |
199 | 161 | |
200 | 162 | /** |
201 | - * Method constructor | |
202 | - * | |
163 | + * @param voTablePath The path of the VOTable. | |
203 | 164 | * @param e The exception thrown. |
204 | 165 | */ |
205 | 166 | public VOTableIsNotValidException(String voTablePath, Exception e) { |
... | ... | @@ -208,15 +169,11 @@ public abstract class VOTableException extends Exception { |
208 | 169 | } |
209 | 170 | } |
210 | 171 | |
211 | - /** | |
212 | - * @author N. Jourdane | |
213 | - */ | |
172 | + /** VOTable with more than one resource are not yet supported. */ | |
214 | 173 | public static class SeveralResourcesException extends CantDisplayVOTableException { |
215 | 174 | |
216 | 175 | /** |
217 | - * Method constructor | |
218 | - * | |
219 | - * @param voTablePath | |
176 | + * @param voTablePath The path of the VOTable. | |
220 | 177 | */ |
221 | 178 | public SeveralResourcesException(String voTablePath) { |
222 | 179 | super("VOTable with more than one resource are not yet supported. \n" |
... | ... | @@ -224,15 +181,11 @@ public abstract class VOTableException extends Exception { |
224 | 181 | } |
225 | 182 | } |
226 | 183 | |
227 | - /** | |
228 | - * @author N. Jourdane | |
229 | - */ | |
184 | + /** VOTable with more than one resource are not yet supported. */ | |
230 | 185 | public static class SeveralTablesException extends CantDisplayVOTableException { |
231 | 186 | |
232 | 187 | /** |
233 | - * Method constructor | |
234 | - * | |
235 | - * @param voTablePath | |
188 | + * @param voTablePath The path of the VOTable. | |
236 | 189 | */ |
237 | 190 | public SeveralTablesException(String voTablePath) { |
238 | 191 | super("VOTable with more than one resource are not yet supported. \n" |
... | ... | @@ -240,13 +193,10 @@ public abstract class VOTableException extends Exception { |
240 | 193 | } |
241 | 194 | } |
242 | 195 | |
243 | - /** | |
244 | - * @author N. Jourdane | |
245 | - */ | |
196 | + /** Can not change schema location on the VOTable file. */ | |
246 | 197 | public static class CantModifyVOTableException extends CantDisplayVOTableException { |
247 | 198 | /** |
248 | - * Method constructor | |
249 | - * | |
199 | + * @param voTablePath The path of the VOTable. | |
250 | 200 | * @param e The exception thrown. |
251 | 201 | */ |
252 | 202 | public CantModifyVOTableException(String voTablePath, Exception e) { |
... | ... | @@ -254,14 +204,11 @@ public abstract class VOTableException extends Exception { |
254 | 204 | } |
255 | 205 | } |
256 | 206 | |
257 | - /** | |
258 | - * @author N. Jourdane | |
259 | - */ | |
207 | + /** There is an error in the VOTable. */ | |
260 | 208 | public static class ErrorMessageInVOTableException extends CantDisplayVOTableException { |
261 | 209 | /** |
262 | - * Method constructor | |
263 | - * | |
264 | - * @param errorInfo | |
210 | + * @param errorInfo The information about the error, which comes from the VOTable itself | |
211 | + * from the "INFO" node. | |
265 | 212 | */ |
266 | 213 | public ErrorMessageInVOTableException(String errorInfo) { |
267 | 214 | super("There is an error in the VOTable:\n" + errorInfo | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableParser.java
... | ... | @@ -36,7 +36,9 @@ import org.w3c.dom.Document; |
36 | 36 | import org.w3c.dom.NamedNodeMap; |
37 | 37 | import org.xml.sax.SAXException; |
38 | 38 | |
39 | -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException.VOTableParsingException; | |
39 | +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException; | |
40 | +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException.CantModifyVOTableException; | |
41 | +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException.VOTableIsNotValidException; | |
40 | 42 | import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; |
41 | 43 | |
42 | 44 | /** |
... | ... | @@ -65,24 +67,23 @@ public final class VOTableParser { |
65 | 67 | /** |
66 | 68 | * @param voTablePath The path of the VOTable. |
67 | 69 | * @return The VOTable resulting of the XML document. |
68 | - * @throws VOTableParsingException Can not parse the VOTable. | |
70 | + * @throws CantDisplayVOTableException VOTable is not valid or not writable. | |
69 | 71 | */ |
70 | - public static VOTABLE parseVOTable(String voTablePath) throws VOTableParsingException { | |
72 | + public static VOTABLE parseVOTable(String voTablePath) throws CantDisplayVOTableException { | |
73 | + // TODO: Change the name of the 2nd INFO tag instead of editing the XSD file. | |
74 | + VOTABLE voTable; | |
75 | + JAXBContext jc; | |
71 | 76 | try { |
72 | 77 | changeVOTableSchemaLocation(voTablePath); |
73 | 78 | } catch (IOException e) { |
74 | - throw new VOTableParsingException("Can not change the VOTable schema location.", e); | |
79 | + throw new CantModifyVOTableException(voTablePath, e); | |
75 | 80 | } |
76 | - | |
77 | - // TODO: Change the name of the 2nd INFO tag instead of editing the XSD file. | |
78 | - VOTABLE voTable; | |
79 | - JAXBContext jc; | |
80 | 81 | try { |
81 | 82 | jc = JAXBContext.newInstance(VOTABLE_MODEL_PACKAGE); |
82 | 83 | Unmarshaller unmarshaller = jc.createUnmarshaller(); |
83 | 84 | voTable = (VOTABLE) unmarshaller.unmarshal(new File(voTablePath)); |
84 | 85 | } catch (JAXBException e) { |
85 | - throw new VOTableParsingException("Can not change the VOTable schema location.", e); | |
86 | + throw new VOTableIsNotValidException(voTablePath, e); | |
86 | 87 | } |
87 | 88 | |
88 | 89 | return voTable; |
... | ... | @@ -114,7 +115,6 @@ public final class VOTableParser { |
114 | 115 | logger.info("VOTable version is " + version + ", everything is ok."); |
115 | 116 | } |
116 | 117 | |
117 | - // write the content into xml file | |
118 | 118 | Transformer transformer = TransformerFactory.newInstance().newTransformer(); |
119 | 119 | StreamResult result = new StreamResult(new File(voTablePath)); |
120 | 120 | transformer.transform(new DOMSource(doc), result); | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java
... | ... | @@ -39,7 +39,7 @@ public class VOTableView extends JPanel implements TableModelListener { |
39 | 39 | /** The logger for the class VOTableView. */ |
40 | 40 | static final Logger logger = Logger.getLogger(VOTableView.class.getName()); |
41 | 41 | |
42 | - // TODO: Create classes VOTableGUI and VOTableCLI which implements an interface VOTableView | |
42 | + // TODO: Create class VOTableCLI the view for a CLI usage | |
43 | 43 | /** The serial version UID (affected with a random number). */ |
44 | 44 | private static final long serialVersionUID = -6131752938586134234L; |
45 | 45 | ... | ... |