Commit 46a05dfa140bfeaf9f795b5a32c1b561775c768a

Authored by Nathanael Jourdane
1 parent 14900420
Exists in master and in 1 other branch b6.0.X

Improve Javadoc.

src/main/java/eu/omp/irap/vespa/votable/VOTableApp.java
... ... @@ -22,7 +22,7 @@ import java.util.logging.Logger;
22 22 import javax.swing.JFrame;
23 23 import javax.swing.SwingUtilities;
24 24  
25   -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
  25 +import eu.omp.irap.vespa.votable.controller.VOTableException;
26 26 import eu.omp.irap.vespa.votable.controller.VOTableController;
27 27 import eu.omp.irap.vespa.votable.utils.StringJoiner;
28 28 import eu.omp.irap.vespa.votable.view.VOTableView;
... ... @@ -37,6 +37,7 @@ public class VOTableApp {
37 37 /** The logger for the class VOTableApp. */
38 38 protected static final Logger LOGGER = Logger.getLogger(VOTableApp.class.getName());
39 39  
  40 + /** The message displayed to the user when the number of argument is incorrect. */
40 41 private static final String WRONG_COMMAND = "Usage: VOtableApp path/to/VOTable.xml\n"
41 42 + "OR: VOtableApp http://url.to.service/or/registry type language \"YOUR QUERY\"";
42 43  
... ... @@ -66,7 +67,7 @@ public class VOTableApp {
66 67  
67 68 try {
68 69 ctrl.readTable();
69   - } catch (CantGetVOTableException e) {
  70 + } catch (VOTableException e) {
70 71 VOTableApp.LOGGER.log(Level.WARNING, e.getMessage(), e);
71 72 return;
72 73 }
... ... @@ -76,6 +77,13 @@ public class VOTableApp {
76 77 SwingUtilities.invokeLater(VOTableApp.run(view, args[0]));
77 78 }
78 79  
  80 + /**
  81 + * Create the runnable to launch the application.
  82 + *
  83 + * @param voTableView The view of the VOTable, created by the VOTableController.
  84 + * @param title The title of the window displaying the VOTable.
  85 + * @return The Runnable.
  86 + */
79 87 private static Runnable run(final VOTableView voTableView, final String title) {
80 88 return new Runnable() {
81 89  
... ...
src/main/java/eu/omp/irap/vespa/votable/controller/VOTableController.java
... ... @@ -24,6 +24,8 @@ import eu.omp.irap.vespa.epntapclient.votable.model.Info;
24 24 import eu.omp.irap.vespa.epntapclient.votable.model.Table;
25 25 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
26 26 import eu.omp.irap.vespa.votable.Consts;
  27 +import eu.omp.irap.vespa.votable.controller.VOTableException.CantGetVOTableException;
  28 +import eu.omp.irap.vespa.votable.controller.VOTableException.VOTableIsNotValidException;
27 29 import eu.omp.irap.vespa.votable.utils.CantSendQueryException;
28 30 import eu.omp.irap.vespa.votable.utils.Network;
29 31 import eu.omp.irap.vespa.votable.view.VOTableViewListener;
... ... @@ -74,12 +76,12 @@ public class VOTableController implements VOTableViewListener {
74 76 this.query = query;
75 77 }
76 78  
77   - public void updateVOTable(String newVOTablePath) throws CantGetVOTableException {
  79 + public void updateVOTable(String newVOTablePath) throws VOTableException {
78 80 voTablePath = newVOTablePath;
79 81 readTable();
80 82 }
81 83  
82   - public void updateVOTable(String newTargetURL, String newQuery) throws CantGetVOTableException {
  84 + public void updateVOTable(String newTargetURL, String newQuery) throws VOTableException {
83 85 voTablePath = null;
84 86 targetURL = newTargetURL;
85 87 query = newQuery;
... ... @@ -87,11 +89,11 @@ public class VOTableController implements VOTableViewListener {
87 89 }
88 90  
89 91 /**
90   - * @param voTablePath The path of the VOTable file.
91   - * @throws CantDisplayVOTableException If the VOTable can not be filled.
92   - * @throws CantSendQueryException
  92 + * Download the VOTable, parse it, and save the content in voTableData.
  93 + *
  94 + * @throws VOTableException If the VOTable can not be filled.
93 95 */
94   - public void readTable() throws CantGetVOTableException {
  96 + public void readTable() throws VOTableException {
95 97 if (voTablePath == null) {
96 98 voTablePath = VOTableController.downloadVOTable(targetURL, query);
97 99 }
... ... @@ -106,34 +108,39 @@ public class VOTableController implements VOTableViewListener {
106 108 voTableData = dataCtrl.getData();
107 109 }
108 110  
109   - public static void checkVOTable(VOTABLE voTable) throws CantGetVOTableException {
  111 + /**
  112 + * Check the VOTable body.
  113 + *
  114 + * @param voTable The VOTable
  115 + * @throws VOTableException There is an error on the VOTable body.
  116 + */
  117 + public static void checkVOTable(VOTABLE voTable) throws VOTableException {
110 118 if (voTable.getRESOURCE().isEmpty()) {
111   - throw new CantGetVOTableException("The VOTable do not have any resource. "
  119 + throw new VOTableIsNotValidException("The VOTable do not have any resource. "
112 120 + "See the local file for more informations.");
113 121 }
114 122  
115 123 if (voTable.getRESOURCE().size() > 1) {
116   - throw new CantGetVOTableException(
  124 + throw new VOTableIsNotValidException(
117 125 "VOTable with more than one resource are not yet supported.");
118 126 }
119 127  
120 128 for (Info info : voTable.getRESOURCE().get(0).getINFO()) {
121 129 if ("ERROR".equals(info.getValueAttribute())) {
122   - throw new CantGetVOTableException("There is an error in the VOTable:\n"
  130 + throw new VOTableIsNotValidException("There is an error in the VOTable:\n"
123 131 + info.getValue() + "\nPlease check your ADQL query. ");
124 132 }
125 133 }
126 134  
127 135 if (voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().size() > 1) {
128   - throw new CantGetVOTableException(
  136 + throw new VOTableIsNotValidException(
129 137 "VOTable with more than one table are not yet supported. "
130 138 + "See the local file for more informations.");
131 139 }
132 140  
133 141 }
134 142  
135   - public static String downloadVOTable(String targetURL, String query)
136   - throws CantGetVOTableException {
  143 + public static String downloadVOTable(String targetURL, String query) throws VOTableException {
137 144 String url = targetURL + "/sync";
138 145  
139 146 SortedMap<String, String> parameters = new TreeMap<>();
... ...
src/main/java/eu/omp/irap/vespa/votable/controller/VOTableParser.java
... ... @@ -26,6 +26,7 @@ import javax.xml.bind.JAXBException;
26 26 import javax.xml.bind.Unmarshaller;
27 27  
28 28 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
  29 +import eu.omp.irap.vespa.votable.controller.VOTableException.CantReadVOTableException;
29 30 import eu.omp.irap.vespa.votable.utils.XMLUtils;
30 31  
31 32 /**
... ... @@ -55,13 +56,13 @@ public final class VOTableParser {
55 56 * @return The VOTable resulting of the XML document.
56 57 * @throws CantDisplayVOTableException VOTable is not valid or not writable.
57 58 */
58   - public static VOTABLE parseVOTable(String voTablePath) throws CantGetVOTableException {
  59 + public static VOTABLE parseVOTable(String voTablePath) throws VOTableException {
59 60 VOTABLE voTable;
60 61 JAXBContext jc;
61 62 try {
62 63 changeVOTableSchemaLocation(voTablePath);
63 64 } catch (IOException e) {
64   - throw new CantGetVOTableException("Can not modify the VOTable XML file " + voTablePath,
  65 + throw new CantReadVOTableException("Can not modify the VOTable XML file " + voTablePath,
65 66 e);
66 67 }
67 68 try {
... ... @@ -69,7 +70,8 @@ public final class VOTableParser {
69 70 Unmarshaller unmarshaller = jc.createUnmarshaller();
70 71 voTable = (VOTABLE) unmarshaller.unmarshal(new File(voTablePath));
71 72 } catch (JAXBException e) {
72   - throw new CantGetVOTableException("Can not get a VOTable object from the XML file.", e);
  73 + throw new CantReadVOTableException("Can not get a VOTable object from the XML file.",
  74 + e);
73 75 }
74 76  
75 77 return voTable;
... ...
src/main/java/eu/omp/irap/vespa/votable/votabledata/BinaryStreamParser.java
... ... @@ -28,7 +28,7 @@ import javax.xml.bind.DatatypeConverter;
28 28 import eu.omp.irap.vespa.epntapclient.votable.model.DataType;
29 29 import eu.omp.irap.vespa.epntapclient.votable.model.Field;
30 30 import eu.omp.irap.vespa.epntapclient.votable.model.Stream;
31   -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
  31 +import eu.omp.irap.vespa.votable.controller.VOTableException;
32 32 import eu.omp.irap.vespa.votable.utils.Debug;
33 33  
34 34 /**
... ... @@ -136,7 +136,7 @@ public final class BinaryStreamParser implements DataParser {
136 136 }
137 137  
138 138 @Override
139   - public List<Object[]> parse() throws CantGetVOTableException {
  139 + public List<Object[]> parse() throws VOTableException {
140 140 List<Object[]> data = new ArrayList<>();
141 141 int nbColumns = fieldsNodes.size();
142 142 BinaryStreamParser.LOGGER
... ...
src/main/java/eu/omp/irap/vespa/votable/votabledata/DataParser.java
... ... @@ -18,7 +18,7 @@ package eu.omp.irap.vespa.votable.votabledata;
18 18  
19 19 import java.util.List;
20 20  
21   -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
  21 +import eu.omp.irap.vespa.votable.controller.VOTableException;
22 22  
23 23 /**
24 24 * @author N. Jourdane
... ... @@ -30,7 +30,7 @@ public interface DataParser {
30 30 *
31 31 * @return A list of arrays representing each row of the data, where arrays elements are each
32 32 * column of the row.
33   - * @throws CantGetVOTableException The VOTable data can not be parsed.
  33 + * @throws VOTableException The VOTable data can not be parsed.
34 34 */
35   - public abstract List<Object[]> parse() throws CantGetVOTableException;
  35 + public abstract List<Object[]> parse() throws VOTableException;
36 36 }
... ...
src/main/java/eu/omp/irap/vespa/votable/votabledata/VOTableDataParser.java
... ... @@ -24,7 +24,8 @@ import java.util.logging.Logger;
24 24 import eu.omp.irap.vespa.epntapclient.votable.model.Data;
25 25 import eu.omp.irap.vespa.epntapclient.votable.model.Field;
26 26 import eu.omp.irap.vespa.epntapclient.votable.model.Table;
27   -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
  27 +import eu.omp.irap.vespa.votable.controller.VOTableException;
  28 +import eu.omp.irap.vespa.votable.controller.VOTableException.VOTableIsNotValidException;
28 29 import eu.omp.irap.vespa.votable.utils.StringJoiner;
29 30  
30 31 /**
... ... @@ -73,7 +74,7 @@ public class VOTableDataParser {
73 74 return columnsName;
74 75 }
75 76  
76   - public VOTableData parseData() throws CantGetVOTableException {
  77 + public VOTableData parseData() throws VOTableException {
77 78 DataParser parser;
78 79 if (dataNode.getBINARY() != null) {
79 80 parser = new BinaryStreamParser(dataNode.getBINARY().getSTREAM(), fieldsNodes);
... ... @@ -84,7 +85,7 @@ public class VOTableDataParser {
84 85 } else if (dataNode.getFITS() != null) {
85 86 parser = new FitsParser(dataNode.getFITS(), fieldsNodes);
86 87 } else {
87   - throw new CantGetVOTableException("Can not locate the data in the VOTable.");
  88 + throw new VOTableIsNotValidException("Can not locate the data in the VOTable.");
88 89 }
89 90 data.setData(parser.parse());
90 91  
... ...