diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java index 0d909fb..9ae19d2 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java @@ -21,13 +21,13 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import eu.omp.irap.vespa.epntapclient.utils.Const; import eu.omp.irap.vespa.epntapclient.utils.Queries; import eu.omp.irap.vespa.epntapclient.view.EpnTapMainView; import eu.omp.irap.vespa.epntapclient.view.EpnTapMainView.MainViewListener; import eu.omp.irap.vespa.epntapclient.view.Event; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableController; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException; +import eu.omp.irap.vespa.epntapclient.votable.utils.Const; /** * The main controller which manage views and controllers. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Const.java b/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Const.java deleted file mode 100644 index 523feab..0000000 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Const.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is a part of EpnTAPClient. - * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. - * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 - * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * - * This program is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public License as published - * by the Free Software Foundation, either version 3 of the License, or (at your option) any later - * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. You should have received a copy of - * the GNU General Public License along with this program. If not, see - * . - */ - -package eu.omp.irap.vespa.epntapclient.utils; - -/** - * This class defines widely-used constants. - * - * @author N. Jourdane - */ -public class Const { - /** The character set used (for http requests, writing in files, etc.). */ - public static final String CHARACTER_SET = "UTF-8"; - - /** The temporary directory path. */ - public static final String TMP_DIR = System.getProperty("java.io.tmpdir"); - - /** The URL of the registry used by default to get the services. */ - public static final String DEFAULT_REGISTRY_URL = "http://dc.zah.uni-heidelberg.de/tap"; - // http://reg.g-vo.org/tap - // http://dc.zah.uni-heidelberg.de/tap - // http://gavo.aip.de/tap - // http://voparis-cdpp.obspm.fr/tap - - /** Constructor to hide the implicit public one. */ - private Const() { - } -} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java b/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java index 2d9e620..3b3977e 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Map; import java.util.logging.Logger; -import eu.omp.irap.vespa.epntapclient.votable.Utils.StringJoiner; +import eu.omp.irap.vespa.epntapclient.votable.utils.Utils.StringJoiner; /** * Defines the queries and the query patterns usually used in the application. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/Utils.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/Utils.java deleted file mode 100644 index fbf69e7..0000000 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/Utils.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file is a part of EpnTAPClient. - * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. - * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 - * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * - * This program is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public License as published - * by the Free Software Foundation, either version 3 of the License, or (at your option) any later - * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. You should have received a copy of - * the GNU General Public License along with this program. If not, see - * . - */ - -package eu.omp.irap.vespa.epntapclient.votable; - -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import eu.omp.irap.vespa.epntapclient.utils.Const; - -/** - * @author N. Jourdane - */ -public class Utils { - /** The logger for the class Utils. */ - private static final Logger logger = Logger.getLogger(Utils.class.getName()); - - /** Private constructor to hide the implicit public one. */ - private Utils() { - } - - /** - * StringJoiner has the same purpose of Java 8 StringJoiner, it has been rewritten for Java7 - * compatibility. - * - * @author N. Jourdane - */ - public static class StringJoiner { - /** A list of words to join, ie. ["foo", "bar"]. */ - List list; - /** The string joiner separator to put between each word, ie. ';'. */ - String separator; - /** The resulting string, ie. "foo;bar". */ - String string; - - /** - * Method constructor for the String joiner. - * - * @param separator The string joiner separator to put between each word, ie. ';'. - */ - public StringJoiner(String separator) { - this.separator = separator; - this.list = new ArrayList<>(); - string = ""; - } - - /** - * add a new word to the joiner. - * - * @param text The word to add. - */ - public void add(String text) { - if ("".equals(string)) { - string = text; - } else { - string += separator + text; - } - } - - @Override - public String toString() { - return string; - } - } - - /** - * Print the specified object in JSON format in a file on the temporary directory. - * - * @param title The name of the file. - * @param obj the object to print in a file. - * @return The path of the file. - */ - public static String printObject(String title, Object obj) { - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - String json = gson.toJson(obj); - String path = Const.TMP_DIR + "/" + title + ".json"; - try (FileWriter writer = new FileWriter(path)) { - writer.write(json); - - } catch (IOException e) { - logger.warning("Can not print in the file " + path + e); - } - logger.info("A json file representing " + title + " (" + obj.getClass().getName() - + ") has been created on " + path); - - return path; - } -} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java index fb9fc46..7a9d2e0 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java @@ -30,13 +30,13 @@ import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; -import eu.omp.irap.vespa.epntapclient.utils.Const; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException.BadResponseCodeException; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException.CantGetErrorStream; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException.CantGetResponseCode; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException.CantOpenConnectionException; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException.CantPrintRequestResultException; +import eu.omp.irap.vespa.epntapclient.votable.utils.Const; /** * This class provide HTTP connection support to send requests through POST / GET protocols. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java index 6f03795..139aa64 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java @@ -28,12 +28,12 @@ import javax.xml.bind.DatatypeConverter; import com.google.gson.Gson; -import eu.omp.irap.vespa.epntapclient.votable.Utils; import eu.omp.irap.vespa.epntapclient.votable.model.DataType; import eu.omp.irap.vespa.epntapclient.votable.model.Field; import eu.omp.irap.vespa.epntapclient.votable.model.Stream; import eu.omp.irap.vespa.epntapclient.votable.model.Table; import eu.omp.irap.vespa.epntapclient.votable.model.TableData; +import eu.omp.irap.vespa.epntapclient.votable.utils.Utils; /** * @author N. Jourdane diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Const.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Const.java new file mode 100644 index 0000000..69af4f6 --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Const.java @@ -0,0 +1,41 @@ +/* + * This file is a part of EpnTAPClient. + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. + * + * This program is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of + * the GNU General Public License along with this program. If not, see + * . + */ + +package eu.omp.irap.vespa.epntapclient.votable.utils; + +/** + * This class defines widely-used constants. + * + * @author N. Jourdane + */ +public class Const { + /** The character set used (for http requests, writing in files, etc.). */ + public static final String CHARACTER_SET = "UTF-8"; + + /** The temporary directory path. */ + public static final String TMP_DIR = System.getProperty("java.io.tmpdir"); + + /** The URL of the registry used by default to get the services. */ + public static final String DEFAULT_REGISTRY_URL = "http://dc.zah.uni-heidelberg.de/tap"; + // http://reg.g-vo.org/tap + // http://dc.zah.uni-heidelberg.de/tap + // http://gavo.aip.de/tap + // http://voparis-cdpp.obspm.fr/tap + + /** Constructor to hide the implicit public one. */ + private Const() { + } +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Utils.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Utils.java new file mode 100644 index 0000000..99114b6 --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Utils.java @@ -0,0 +1,105 @@ +/* + * This file is a part of EpnTAPClient. + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. + * + * This program is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of + * the GNU General Public License along with this program. If not, see + * . + */ + +package eu.omp.irap.vespa.epntapclient.votable.utils; + +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * @author N. Jourdane + */ +public class Utils { + /** The logger for the class Utils. */ + private static final Logger logger = Logger.getLogger(Utils.class.getName()); + + /** Private constructor to hide the implicit public one. */ + private Utils() { + } + + /** + * StringJoiner has the same purpose of Java 8 StringJoiner, it has been rewritten for Java7 + * compatibility. + * + * @author N. Jourdane + */ + public static class StringJoiner { + /** A list of words to join, ie. ["foo", "bar"]. */ + List list; + /** The string joiner separator to put between each word, ie. ';'. */ + String separator; + /** The resulting string, ie. "foo;bar". */ + String string; + + /** + * Method constructor for the String joiner. + * + * @param separator The string joiner separator to put between each word, ie. ';'. + */ + public StringJoiner(String separator) { + this.separator = separator; + this.list = new ArrayList<>(); + string = ""; + } + + /** + * add a new word to the joiner. + * + * @param text The word to add. + */ + public void add(String text) { + if ("".equals(string)) { + string = text; + } else { + string += separator + text; + } + } + + @Override + public String toString() { + return string; + } + } + + /** + * Print the specified object in JSON format in a file on the temporary directory. + * + * @param title The name of the file. + * @param obj the object to print in a file. + * @return The path of the file. + */ + public static String printObject(String title, Object obj) { + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + String json = gson.toJson(obj); + String path = Const.TMP_DIR + "/" + title + ".json"; + try (FileWriter writer = new FileWriter(path)) { + writer.write(json); + + } catch (IOException e) { + logger.warning("Can not print in the file " + path + e); + } + logger.info("A json file representing " + title + " (" + obj.getClass().getName() + + ") has been created on " + path); + + return path; + } +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java index 9ad0b31..bb9f856 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java @@ -28,7 +28,7 @@ import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableModel; -import eu.omp.irap.vespa.epntapclient.votable.Utils; +import eu.omp.irap.vespa.epntapclient.votable.utils.Utils; /** * The main class of the View of the application. -- libgit2 0.21.2